📄 netbuf.h
字号:
/*
* FILENAME: netbuf.h
*
* Copyright 1998- 2000 By InterNiche Technologies Inc. All rights reserved
*
* Descriptions of the packet buffer structure, etc.
*
* MODULE: INET
*
*
* PORTABLE: yes
*/
/* Additional Copyrights: */
/* Portions Copyright 1990-1993 by NetPort Software.
* Portions Copyright 1986 by Carnegie Mellon
* Portions Copyright 1983 by the Massachusetts Institute of
* Technology
*/
/* Each buffer is in a
* queue, either the free queue or the used queue (or the buffer is
* currently being used by a user program or the interrupt level
* routines, in which case it does not appear in a queue). When a
* buffer is in a queue, it has a pointer to the next buffer in the
* queue. If there is no next buffer, its pointer points at null.
* Also, each buffer knows its own length.
*/
#ifndef _NETBUF_H
#define _NETBUF_H 1
/* This include file gives the structure of PACKET buffers.
* INCOMING: Incoming packets are always front-aligned in the
* nb_buff field. The nb_prot pointer is set to nb_buff by the
* receiver and advanced by each layer of the stack before
* upcalling the next; ie the ethernet driver bumps the prot field
* by 14 and decrements plen by 14. PACKETs are pk_alloc()ed by
* the receiving net layer and pk_free()ed by the transport layer
* or application when it's finished with them. OUTGOING:
* Protocols install data into nb_buff with a front pad big enough
* to accomadate the biggest likely protocol headers, ususally
* about 62 bytes (14 ether + 24 IP + 24 TCP, where IP & TCP each
* have option fields.) prot plen are set for this data, and the
* protocol headers are prepended as the packet goes down the
* stack. nb_buff is not used in this case except for overflow
* checks. PACKETs are pk_alloc()ed by the sending protocol and
* freed by the lower layer level that dispatches them, usually
* net link layer driver. They can be held by ARP for several
* seconds while awaiting arp replys on initial sends to a new IP
* host, and the ARP code will free them when a reply comes in or
* times out.
*/
struct netbuf
{
struct netbuf * next; /* queue link */
char * nb_buff; /* beginning of raw buffer */
unsigned nb_blen; /* length of raw buffer */
char * nb_prot; /* beginning of protocol data */
unsigned nb_plen; /* length of protocol data */
long nb_tstamp; /* packet timestamp */
struct net * net; /* the interface (net) it came in on, 0-n */
ip_addr fhost; /* IP address asociated with packet */
unsigned short type; /* IP==0800 filled in by recever(rx) or net layer.(tx) */
unsigned inuse; /* use count, for cloning buffer */
#ifdef PPP_MULTILINK
void * link; /* which of Multiple links to use */
#endif /* PPP_MULTILINK */
#ifdef MINI_TCP /* Mini TCP has no mbuf wrappers, so: */
char * m_data; /* pointer to TCP data in nb_buff */
unsigned m_len; /* length of m_data */
struct netbuf * m_next; /* sockbuf que link */
#endif /* MINI_TCP */
#ifdef IP_MULTICAST
struct ip_moptions * imo; /* IP multicast options */
#endif
};
typedef struct netbuf * PACKET; /* struct netbuf in netbuf.h */
/* count & sizes for the fre buffer queues */
extern unsigned lilbufs; /* number of small bufs to init */
extern unsigned lilbufsiz; /* big enough for average packet */
extern unsigned bigbufs; /* number of big bufs to init */
extern unsigned bigbufsiz; /* big enough for max. ethernet packet */
/* Pack buffer routines, Defined in the new system for each port: */
PACKET pk_alloc(unsigned size); /* allocate a packet for sending */
void pk_free(PACKET);
int pk_init(void); /* call at init time to set up for pk_allocs */
#endif /* _NETBUF_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -