Network Buffer
[Network Devices]

Collaboration diagram for Network Buffer:


Detailed Description

Network buffer support.

The network buffer handling is designed to make life easy when it comes to handling ISO-layered communications. By this we're thinking about communications structures that are hierarchically organized.

The idea is that network buffer structures are allocated every time a new packet is either received or ready for sending. The various fields of the network buffer are then handled by matching layers within the appropriate protocol stack.

Linked list of NETBUF structures:

inline_dotgraph_3


Data Structures

struct  _NBDATA
 Data part of a network buffer structure. More...
struct  _NETBUF
 Network buffer structure. More...
struct  _NBDATA
 Data part of a network buffer structure. More...
struct  _NETBUF
 Network buffer structure. More...

Defines

#define NBAF_DATALINK   0x10
 Datalink buffer allocated flag.
#define NBAF_NETWORK   0x20
 Network buffer allocated flag.
#define NBAF_TRANSPORT   0x40
 Transport buffer allocated flag.
#define NBAF_APPLICATION   0x80
 Application buffer allocated flag.
#define NBAF_ALL   0xf0
 Masks allocated buffer flags flag.

Typedefs

typedef _NETBUF NETBUF
 Network buffer type.
typedef _NBDATA NBDATA
 Network buffer data type.

Functions

NETBUFNutNetBufAlloc (NETBUF *nb, u_char type, u_short size)
 Allocate or re-allocate a network buffer part.
NETBUFNutNetBufClone (NETBUF *nb)
 Create a copy of an existing network buffer structure.
int NutNetBufFree (NETBUF *nb)
 Release a network buffer structure.


Define Documentation

#define NBAF_DATALINK   0x10

Datalink buffer allocated flag.

Definition at line 109 of file netbuf.h.

Referenced by CSNICrx(), NutEtherOutput(), NutNetBufAlloc(), NutNetBufClone(), and NutPppOutput().

#define NBAF_NETWORK   0x20

Network buffer allocated flag.

Definition at line 110 of file netbuf.h.

Referenced by NutArpAllocNetBuf(), NutIpcpOutput(), NutIpOutput(), NutLcpOutput(), NutNetBufAlloc(), NutNetBufClone(), and NutPapOutput().

#define NBAF_TRANSPORT   0x40

Transport buffer allocated flag.

Definition at line 111 of file netbuf.h.

Referenced by NutIcmpReply(), NutIgmpOutput(), NutNetBufAlloc(), NutNetBufClone(), NutTcpOutput(), and NutUdpOutput().

#define NBAF_APPLICATION   0x80

Application buffer allocated flag.

Definition at line 112 of file netbuf.h.

Referenced by IpcpTxConfReq(), LcpTxConfReq(), LcpTxProtRej(), NutIcmpResponse(), NutNetBufAlloc(), NutNetBufClone(), NutTcpOutput(), NutUdpSendTo(), and PapTxAuthReq().

#define NBAF_ALL   0xf0

Masks allocated buffer flags flag.

Definition at line 113 of file netbuf.h.


Typedef Documentation

typedef struct _NETBUF NETBUF

Network buffer type.

Definition at line 118 of file netbuf.h.

typedef struct _NBDATA NBDATA

Network buffer data type.

Definition at line 123 of file netbuf.h.


Function Documentation

NETBUF* NutNetBufAlloc ( NETBUF nb,
u_char  type,
u_short  size 
)

Allocate or re-allocate a network buffer part.

Parameters:
nb Points to an existing network buffer structure or NULL, if a new structure should be created. An existing buffer must not be used any further if this function returns a null pointer.
type Part of the buffer to be allocated. This can be any of the following:
  • NBAF_DATALINK
  • NBAF_NETWORK
  • NBAF_TRANSPORT
  • NBAF_APPLICATION
size Size of the part to be allocated.
Returns:
Pointer to the allocated network buffer structure. A null pointer is returned if not enough memory is available and the whole structure is released.

Definition at line 168 of file netbuf.c.

References _NETBUF::nb_ap, _NETBUF::nb_dl, _NETBUF::nb_flags, _NETBUF::nb_nw, _NETBUF::nb_tp, NBAF_APPLICATION, NBAF_DATALINK, NBAF_NETWORK, NBAF_TRANSPORT, NutHeapAllocClear(), NutNetBufFree(), and _NBDATA::sz.

Referenced by CSNICrx(), IpcpTxConfReq(), LcpTxConfReq(), LcpTxProtRej(), NutArpAllocNetBuf(), NutEtherOutput(), NutIcmpReply(), NutIcmpResponse(), NutIgmpOutput(), NutIpcpOutput(), NutIpOutput(), NutLcpOutput(), NutNetBufFree(), NutPapOutput(), NutPppOutput(), NutTcpOutput(), NutUdpOutput(), NutUdpSendTo(), and PapTxAuthReq().

NETBUF* NutNetBufClone ( NETBUF nb  ) 

Create a copy of an existing network buffer structure.

Parameters:
nb Points to an existing network buffer structure, previously allocated by NutNetBufAlloc().
Returns:
Pointer to a newly allocated copy.

Definition at line 266 of file netbuf.c.

References memcpy(), _NETBUF::nb_ap, _NETBUF::nb_dl, _NETBUF::nb_flags, _NETBUF::nb_nw, _NETBUF::nb_tp, NBAF_APPLICATION, NBAF_DATALINK, NBAF_NETWORK, NBAF_TRANSPORT, NutHeapAllocClear(), NutNetBufFree(), _NBDATA::sz, and _NBDATA::vp.

Referenced by NutTcpOutput().

int NutNetBufFree ( NETBUF nb  ) 

Release a network buffer structure.

Returns all memory previously allocated by a network buffer to the available heap space.

Parameters:
nb Points to an existing network buffer structure, previously allocated by NutNetBufAlloc().
Returns:
0 if successfull or -1 if the structure contains previously released memory space.

Definition at line 321 of file netbuf.c.

References _NETBUF::nb_flags, NutHeapFree(), and NutNetBufAlloc().

Referenced by IpcpRxConfAck(), IpcpRxConfReq(), IpcpRxTermReq(), LcpTxProtRej(), NutArpInput(), NutEtherInput(), NutEtherOutput(), NutIcmpInput(), NutIgmpInput(), NutIpcpInput(), NutIpcpOutput(), NutIpInput(), NutLcpInput(), NutLcpOutput(), NutNetBufAlloc(), NutNetBufClone(), NutPapInput(), NutPapOutput(), NutPppInput(), NutPppOutput(), NutTcpDiscardBuffers(), NutTcpOutput(), NutTcpReceive(), NutTcpReject(), NutTcpStateMachine(), NutUdpDestroySocket(), NutUdpInput(), NutUdpReceiveFrom(), and NutUdpSendTo().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/