Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
NETWIB_PKT(3)		    Library Functions Manual		   NETWIB_PKT(3)

NAME
     netwib - section pkt

HTML DOC
     If  you  have a browser, read netwib-5.38.0-doc_html.tgz which is easier to
     read than this manpage.

PRESENTATION
     This manpage contains a concatenation of includes for section PKT.

MODULE TYPES
     #ifndef NETWIB_PKT_TYPES_INCLUDED
     #define NETWIB_PKT_TYPES_INCLUDED 1

     /*-------------------------------------------------------------*/
     /* Protocol values */
     typedef enum {
       NETWIB_IPPROTO_IP = 0,	     /* Dummy protocol for TCP */
       NETWIB_IPPROTO_HOPOPTS = 0,   /* IPv6 Hop-by-Hop options */
       NETWIB_IPPROTO_ICMP4 = 1,     /* Internet Control Message Protocol */
       NETWIB_IPPROTO_IGMP = 2,      /* Internet Group Management Protocol */
       NETWIB_IPPROTO_IPIP = 4,      /* IPIP tunnels */
       NETWIB_IPPROTO_TCP = 6,	     /* Transmission Control Protocol */
       NETWIB_IPPROTO_EGP = 8,	     /* Exterior Gateway Protocol */
       NETWIB_IPPROTO_PUP = 12,      /* PUP protocol */
       NETWIB_IPPROTO_UDP = 17,      /* User Datagram Protocol */
       NETWIB_IPPROTO_IDP = 22,      /* XNS IDP protocol */
       NETWIB_IPPROTO_TP = 29,	     /* SO Transport Protocol Class 4 */
       NETWIB_IPPROTO_IP6 = 41,      /* IPv6 header */
       NETWIB_IPPROTO_ROUTING = 43,  /* IPv6 routing header */
       NETWIB_IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header */
       NETWIB_IPPROTO_RSVP = 46,     /* Reservation Protocol */
       NETWIB_IPPROTO_GRE = 47,      /* General Routing Encapsulation */
       NETWIB_IPPROTO_ESP = 50,      /* encapsulating security payload */
       NETWIB_IPPROTO_AH = 51,	     /* authentication header */
       NETWIB_IPPROTO_ICMP6 = 58,    /* ICMPv6 */
       NETWIB_IPPROTO_NONE = 59,     /* IPv6 no next header */
       NETWIB_IPPROTO_DSTOPTS = 60,  /* IPv6 destination options */
       NETWIB_IPPROTO_MTP = 92,      /* Multicast Transport Protocol */
       NETWIB_IPPROTO_ENCAP = 98,    /* Encapsulation Header */
       NETWIB_IPPROTO_PIM = 103,     /* Protocol Independent Multicast */
       NETWIB_IPPROTO_COMP = 108,    /* Compression Header Protocol */
       NETWIB_IPPROTO_RAW = 255      /* Raw IP packets */
     } netwib_ipproto;

     /*-------------------------------------------------------------*/
     #define netwib__data_append_uint8(data,u) *(data)++=(netwib_byte)(u)
     #define netwib__data_append_uint16(data,u) *(data)++=netwib_c2_uint16_0(u);*(data)++=netwib_c2_uint16_1(u)
     #define netwib__data_append_uint32(data,u) *(data)++=netwib_c2_uint32_0(u);*(data)++=netwib_c2_uint32_1(u);*(data)++=netwib_c2_uint32_2(u);*(data)++=netwib_c2_uint32_3(u)
     #define netwib__data_append_uint64(data,u) *(data)++=netwib_c2_uint64_0(u);*(data)++=netwib_c2_uint64_1(u);*(data)++=netwib_c2_uint64_2(u);*(data)++=netwib_c2_uint64_3(u);*(data)++=netwib_c2_uint64_4(u);*(data)++=netwib_c2_uint64_5(u);*(data)++=netwib_c2_uint64_6(u);*(data)++=netwib_c2_uint64_7(u)
     /* for structures created with little endian processors */
     #define netwib__data_append_uint8_le(data,u) netwib__data_append_uint8(data,u)
     #define netwib__data_append_uint16_le(data,u) *(data)++=netwib_c2_uint16_1(u);*(data)++=netwib_c2_uint16_0(u)
     #define netwib__data_append_uint32_le(data,u) *(data)++=netwib_c2_uint32_3(u);*(data)++=netwib_c2_uint32_2(u);*(data)++=netwib_c2_uint32_1(u);*(data)++=netwib_c2_uint32_0(u)
     #define netwib__data_append_uint64_le(data,u) *(data)++=netwib_c2_uint64_7(u);*(data)++=netwib_c2_uint64_6(u);*(data)++=netwib_c2_uint64_5(u);*(data)++=netwib_c2_uint64_4(u);*(data)++=netwib_c2_uint64_3(u);*(data)++=netwib_c2_uint64_2(u);*(data)++=netwib_c2_uint64_1(u);*(data)++=netwib_c2_uint64_0(u)

     /*-------------------------------------------------------------*/
     #define netwib__data_decode_uint8t(data,u,type) u=(type)(*(data)++)
     #define netwib__data_decode_uint8t_le(data,u,type) netwib__data_decode_uint8t(data,u,type)
     #define netwib__data_decode_uint16t(data,u,type) u=(type)((*(data)++)<<8);u=(type)((u)|*(data)++)
     #define netwib__data_decode_uint16t_le(data,u,type) u=(type)(*(data)++);u=(type)(((*(data)++)<<8)|(u))
     #define netwib__data_decode_uint32t(data,u,type) u=(type)((*(data)++)<<24);u=(type)((u)|((*(data)++)<<16));u=(type)((u)|((*(data)++)<<8));u=(type)((u)|*(data)++)
     #define netwib__data_decode_uint32t_le(data,u,type) u=(type)(*(data)++);u=(type)(((*(data)++)<<8)|(u));u=(type)(((*(data)++)<<16)|(u));u=(type)(((*(data)++)<<24)|(u))
     #if NETWIB_INT64_FAKE == 0
      #define netwib__data_decode_uint64t(data,u,type) u=(type)((netwib_uint64)(*(data)++)<<56);u=(type)((u)|((netwib_uint64)(*(data)++)<<48));u=(type)((u)|((netwib_uint64)(*(data)++)<<40));u=(type)((u)|((netwib_uint64)(*(data)++)<<32));u=(type)((u)|((netwib_uint64)(*(data)++)<<24));u=(type)((u)|((netwib_uint64)(*(data)++)<<16));u=(type)((u)|((netwib_uint64)(*(data)++)<<8));u=(type)((u)|(netwib_uint64)(*(data)++))
      #define netwib__data_decode_uint64t_le(data,u,type) u=(type)(netwib_uint64)(*(data)++);u=(type)(((netwib_uint64)(*(data)++)<<8)|(u));u=(type)(((netwib_uint64)(*(data)++)<<16)|(u));u=(type)(((netwib_uint64)(*(data)++)<<24)|(u));u=(type)(((netwib_uint64)(*(data)++)<<32)|(u));u=(type)(((netwib_uint64)(*(data)++)<<40)|(u));u=(type)(((netwib_uint64)(*(data)++)<<48)|(u));u=(type)(((netwib_uint64)(*(data)++)<<56)|(u))
     #else
      #define netwib__data_decode_uint64t(data,u,type) netwib__data_decode_uint32(data,(u).high);netwib__data_decode_uint32(data,(u).low)
      #define netwib__data_decode_uint64t_le(data,u,type) netwib__data_decode_uint32_le(data,(u).low);netwib__data_decode_uint32_le(data,(u).high)
     #endif
     #define netwib__data_decode_uint8(data,u) netwib__data_decode_uint8t(data,u,netwib_uint8)
     #define netwib__data_decode_uint8_le(data,u) netwib__data_decode_uint8(data,u)
     #define netwib__data_decode_uint16(data,u) netwib__data_decode_uint16t(data,u,netwib_uint16)
     #define netwib__data_decode_uint16_le(data,u) netwib__data_decode_uint16t_le(data,u,netwib_uint16)
     #define netwib__data_decode_uint32(data,u) netwib__data_decode_uint32t(data,u,netwib_uint32)
     #define netwib__data_decode_uint32_le(data,u) netwib__data_decode_uint32t_le(data,u,netwib_uint32)
     #define netwib__data_decode_uint64(data,u) netwib__data_decode_uint64t(data,u,netwib_uint64)
     #define netwib__data_decode_uint64_le(data,u) netwib__data_decode_uint64t_le(data,u,netwib_uint64)

     #endif

MODULE LINKHDR
     /*-------------------------------------------------------------*/
     /* Ethernet header (NETWIB_DEVICE_DLTTYPE_EN10MB) */
     typedef enum {
       NETWIB_ETHERHDRTYPE_IP4 =    0x0800,
       NETWIB_ETHERHDRTYPE_ARP =    0x0806,
       NETWIB_ETHERHDRTYPE_VINES =  0x0bad,
       NETWIB_ETHERHDRTYPE_TRAIN =  0x1984,
       NETWIB_ETHERHDRTYPE_CDP =    0x2000,
       NETWIB_ETHERHDRTYPE_RARP =   0x8035,
       NETWIB_ETHERHDRTYPE_ATALK =  0x809b,
       NETWIB_ETHERHDRTYPE_AARP =   0x80f3,
       NETWIB_ETHERHDRTYPE_VLAN =   0x8100,
       NETWIB_ETHERHDRTYPE_IPX =    0x8137,
       NETWIB_ETHERHDRTYPE_IP6 =    0x86DD,
       NETWIB_ETHERHDRTYPE_PPPOED = 0x8863,
       NETWIB_ETHERHDRTYPE_PPPOES = 0x8864,
       NETWIB_ETHERHDRTYPE_LOOP =   0x9000
     } netwib_etherhdrtype;
     typedef struct {
       netwib_eth dst;
       netwib_eth src;
       netwib_etherhdrtype type;
     } netwib_etherhdr;
     typedef const netwib_etherhdr netwib_constetherhdr;
     #define NETWIB_ETHERHDR_LEN 14

     /*-------------------------------------------------------------*/
     /* NULL header (NETWIB_DEVICE_DLTTYPE_NULL) */
     typedef struct {
       netwib_etherhdrtype type;
     } netwib_nullhdr;
     typedef const netwib_nullhdr netwib_constnullhdr;
     #define NETWIB_NULLHDR_LEN 4

     /*-------------------------------------------------------------*/
     /* LOOP header (NETWIB_DEVICE_DLTTYPE_LOOP) */
     typedef struct {
       netwib_etherhdrtype type;
     } netwib_loophdr;
     typedef const netwib_loophdr netwib_constloophdr;
     #define NETWIB_LOOPHDR_LEN 4

     /*-------------------------------------------------------------*/
     /* RAW header (NETWIB_DEVICE_DLTTYPE_RAW) */
     #define NETWIB_RAWHDR_LEN 0

     /*-------------------------------------------------------------*/
     /* PPP header (NETWIB_DEVICE_DLTTYPE_PPP) */
     typedef enum {
       NETWIB_PPPHDRPROTO_IP4 =     0x0021, /* Internet Protocol */
       NETWIB_PPPHDRPROTO_AT =	    0x0029, /* AppleTalk Protocol */
       NETWIB_PPPHDRPROTO_IPX =     0x002b, /* IPX protocol */
       NETWIB_PPPHDRPROTO_VJC_COMP =   0x002d, /* VJ compressed TCP */
       NETWIB_PPPHDRPROTO_VJC_UNCOMP = 0x002f, /* VJ uncompressed TCP */
       NETWIB_PPPHDRPROTO_IP6 =     0x0057, /* Internet Protocol Version 6 */
       NETWIB_PPPHDRPROTO_COMP =    0x00fd, /* compressed packet */
       NETWIB_PPPHDRPROTO_IPCP =    0x8021, /* IP Control Protocol */
       NETWIB_PPPHDRPROTO_ATCP =    0x8029, /* AppleTalk Control Protocol */
       NETWIB_PPPHDRPROTO_IPXCP =   0x802b, /* IPX Control Protocol */
       NETWIB_PPPHDRPROTO_IP6CP =   0x8057, /* IPv6 Control Protocol */
       NETWIB_PPPHDRPROTO_CCP =     0x80fd, /* Compression Control Protocol */
       NETWIB_PPPHDRPROTO_LCP =     0xc021, /* Link Control Protocol */
       NETWIB_PPPHDRPROTO_PAP =     0xc023, /* Password Authentication Proto */
       NETWIB_PPPHDRPROTO_LQR =     0xc025, /* Link Quality Report protocol */
       NETWIB_PPPHDRPROTO_CHAP =    0xc223, /* Crypto. Handshake Auth. P. */
       NETWIB_PPPHDRPROTO_CBCP =    0xc029  /* Callback Control Protocol */
     } netwib_ppphdrproto;
     typedef struct {
       netwib_byte address;
       netwib_byte control;
       netwib_ppphdrproto protocol;
     } netwib_ppphdr;
     typedef const netwib_ppphdr netwib_constppphdr;
     #define NETWIB_PPPHDR_LEN 4

     /*-------------------------------------------------------------*/
     /* LINUX_SLL header (NETWIB_DEVICE_DLTTYPE_LINUX_SLL) */
     typedef enum {
       NETWIB_LINUXSLLHDRPKTTYPE_HOST = 0,
       NETWIB_LINUXSLLHDRPKTTYPE_BROADCAST = 1,
       NETWIB_LINUXSLLHDRPKTTYPE_MULTICAST = 2,
       NETWIB_LINUXSLLHDRPKTTYPE_OTHERHOST = 3,
       NETWIB_LINUXSLLHDRPKTTYPE_OUTGOING = 4
     } netwib_linuxsllhdrpkttype;
     typedef enum {
       NETWIB_LINUXSLLHDRHATYPE_NETROM = 0,
       NETWIB_LINUXSLLHDRHATYPE_ETHER = 1
     } netwib_linuxsllhdrhatype;
     typedef struct {
       netwib_linuxsllhdrpkttype pkttype;   /* packet type */
       netwib_linuxsllhdrhatype hatype;     /* link-layer address type */
       netwib_uint16 halen;		    /* link-layer address length */
       netwib_byte srcaddr[8];		    /* link-layer address */
       netwib_etherhdrtype protocol;	    /* protocol */
     } netwib_linuxsllhdr;
     typedef const netwib_linuxsllhdr netwib_constlinuxsllhdr;
     #define NETWIB_LINUXSLLHDR_LEN 16

     /*-------------------------------------------------------------*/
     /* Link header */
     typedef struct {
       netwib_device_dlttype type;
       union {
	 netwib_etherhdr    ether;
	 netwib_nullhdr     null;
	 netwib_loophdr     loop;
	 /* no netwib_rawhdr needed */
	 netwib_ppphdr	    ppp;
	 netwib_linuxsllhdr linuxsll;
       } hdr;
     } netwib_linkhdr;
     typedef const netwib_linkhdr netwib_constlinkhdr;
     #define NETWIB_LINKHDR_MAXLEN NETWIB_LINUXSLLHDR_LEN

     /*-------------------------------------------------------------*/
     /* Name : netwib_linkhdr_initdefault
	Description :
	  Initialize a netwib_linkhdr with default values.
	Input parameter(s) :
	  type : header type
	Input/output parameter(s) :
	Output parameter(s) :
	  *plinkhdr : netwib_linkhdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_linkhdr_initdefault(netwib_device_dlttype type,
					   netwib_linkhdr *plinkhdr);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_linkhdr
	Description :
	  Initialize physical data from a netwib_linkhdr.
	Input parameter(s) :
	  linkhdr : netwib_linkhdr
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_linkhdr(netwib_constlinkhdr *plinkhdr,
					  netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_linkhdr(netwib_constlinkhdr *plinkhdr,
					   netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_linkhdr
	Description :
	  Decode a netwib_linkhdr from data coming from wire.
	Input parameter(s) :
	  dlttype : DLT type of packet
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *plinkhdr : netwib_linkhdr to initialize
	  *pskipsize : size to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_linkhdr(netwib_device_dlttype dlttype,
					  netwib_constbuf *ppkt,
					  netwib_linkhdr *plinkhdr,
					  netwib_uint32 *pskipsize);

     /*-------------------------------------------------------------*/
     /***************************************************************
      * Link headers are horribly incompatible. The only field	    *
      * which can be considered as compatible is the type/protocol. *
      * Following functions permit to set/get it from header.	    *
      * Type netwib_linkhdrproto is the generic type.		    *
      ***************************************************************/
     typedef enum {
       NETWIB_LINKHDRPROTO_UNKNOWN = 0,
       NETWIB_LINKHDRPROTO_IP4,
       NETWIB_LINKHDRPROTO_IP6,
       NETWIB_LINKHDRPROTO_ARP,
       NETWIB_LINKHDRPROTO_RARP,
       NETWIB_LINKHDRPROTO_IPX
     } netwib_linkhdrproto;
     netwib_err netwib_linkhdr_set_proto(netwib_linkhdr *plinkhdr,
					 netwib_linkhdrproto linkhdrproto);
     netwib_err netwib_linkhdr_get_proto(netwib_constlinkhdr *plinkhdr,
					 netwib_linkhdrproto *plinkhdrproto);

MODULE IPHDR
     /*-------------------------------------------------------------*/
     /***************************************************************
      * A netwib_iphdr permits to store :			    *
      *  - an IPv4 header (rfc 791), or 			    *
      *  - an IPv6 header (rfc 2460)				    *
      ***************************************************************/
     typedef struct {
       /* common fields */
       netwib_iptype iptype;
       netwib_ip src;
       netwib_ip dst;
       netwib_uint8 ttl;
       netwib_ipproto protocol;
       /* specific fields */
       union {
	 struct {
	   netwib_uint8 ihl;
	   netwib_uint8 tos;
	   netwib_uint16 totlen;
	   netwib_uint16 id;
	   netwib_bool reserved;
	   netwib_bool dontfrag;
	   netwib_bool morefrag;
	   netwib_uint16 offsetfrag;
	   netwib_uint16 check;
	   netwib_bufext opts; /* IPv4 options as defined in ip4opts.h */
	 } ip4;
	 struct {
	   netwib_uint8 trafficclass;
	   netwib_uint32 flowlabel;
	   netwib_uint16 payloadlength;
	   netwib_bufext exts; /* IPv6 extensions as defined in ip6exts.h */
	 } ip6;
       } header;
     } netwib_iphdr;
     typedef const netwib_iphdr netwib_constiphdr;
     #define NETWIB_IPHDR_MINLEN 40

     /*-------------------------------------------------------------*/
     /* Name : netwib_iphdr_initdefault
	Description :
	  Initialize a netwib_iphdr with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *piphdr : netwib_iphdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_iphdr_initdefault(netwib_iptype iptype,
					 netwib_iphdr *piphdr);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_iphdr
	Description :
	  Initialize physical data from a netwib_iphdr.
	Input parameter(s) :
	  *piphdr : netwib_iphdr
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_iphdr(netwib_constiphdr *piphdr,
					netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_iphdr(netwib_constiphdr *piphdr,
					 netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_iphdr
	Description :
	  Decode a netwib_iphdr from physical data.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *piphdr : netwib_iphdr contained in pkt
	  *pskipsize : size to use to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
	  NETWIB_ERR_NOTCONVERTED : pkt could not be decoded
	  NETWIB_ERR_DATAMISSING : pkt was not big enough
     */
     netwib_err netwib_pkt_decode_iphdr(netwib_constbuf *ppkt,
					netwib_iphdr *piphdr,
					netwib_uint32 *pskipsize);

     /*-------------------------------------------------------------*/
     /***************************************************************
      * A netwib_iphdr contains a protocol field, it is stored :    *
      *  - IPv4 : in header.protocol				    *
      *  - IPv6 : if exts is empty : in header.protocol,	    *
      * 	  else : in last extension of header.ip6.exts	    *
      ***************************************************************/
     netwib_err netwib_iphdr_set_proto(netwib_iphdr *piphdr,
				       netwib_ipproto ipproto);
     netwib_err netwib_iphdr_get_proto(netwib_constiphdr *piphdr,
				       netwib_ipproto *pipproto);

MODULE IP4OPT
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Refer to RFC 791 to obtain more information about IPv4	    *
      * options.						    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* Comments starting with "NI" are not implemented */
     typedef enum {
       NETWIB_IP4OPTTYPE_END = 0,	 /* end of options */
       NETWIB_IP4OPTTYPE_NOOP = 1,	 /* no operation */
       NETWIB_IP4OPTTYPE_RR = 7,	 /* record route */
       NETWIB_IP4OPTTYPE_TIME = 68,	 /* timestamp */
       NETWIB_IP4OPTTYPE_SECURITY = 130, /* NI security compartmentation */
       NETWIB_IP4OPTTYPE_LSRR = 131,	 /* loose source and record route */
       NETWIB_IP4OPTTYPE_STREAM = 136,	 /* NI SATNET stream identifier */
       NETWIB_IP4OPTTYPE_SSRR = 137	 /* strict source and record route */
     } netwib_ip4opttype;

     /*-------------------------------------------------------------*/
     /* maximum length of one IP4 option */
     #define NETWIB_IP4OPT_MAXLEN 40

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 storagesize; /* 0 to 9 */
       netwib_uint32 storedvalues; /* 0 to storagesize */
     #define NETWIB_IP4OPT_RR_IP_LEN 9
       netwib_ip ip[NETWIB_IP4OPT_RR_IP_LEN];
     } netwib_ip4opt_rr;
     typedef const netwib_ip4opt_rr netwib_constip4opt_rr;

     typedef struct {
       netwib_uint32 storagesize; /* 0 to 9 */
       netwib_uint32 usedvalues; /* 0 to storagesize */
     #define NETWIB_IP4OPT_SRR_IP_LEN 9
       netwib_ip ip[NETWIB_IP4OPT_SRR_IP_LEN];
     } netwib_ip4opt_srr;
     typedef const netwib_ip4opt_srr netwib_constip4opt_srr;

     typedef enum {
       NETWIB_IP4OPT_TIMEFLAG_TS = 0,
       NETWIB_IP4OPT_TIMEFLAG_IPTS = 1,
       NETWIB_IP4OPT_TIMEFLAG_IPPTS = 3
     } netwib_ip4opt_timeflag;
     typedef struct {
       netwib_uint32 storagesize; /* 0 to 4or9 (4 for ipts/ippts; 9 for ts) */
       netwib_uint32 storedvalues; /* 0 to storeagesize */
       netwib_uint8 overflow;
       netwib_ip4opt_timeflag flag;
     #define NETWIB_IP4OPT_TIME_IP_LEN 4
       netwib_ip ip[NETWIB_IP4OPT_TIME_IP_LEN];
     #define NETWIB_IP4OPT_TIME_TIMESTAMP_LEN 9
       netwib_uint32 timestamp[NETWIB_IP4OPT_TIME_TIMESTAMP_LEN];
     } netwib_ip4opt_time;
     typedef const netwib_ip4opt_time netwib_constip4opt_time;

     typedef struct {
       netwib_ip4opttype type;
       union {
	 /* type end : no value */
	 /* type noop : no value */
	 netwib_ip4opt_rr rr;
	 netwib_ip4opt_time time;
	 /* type security : NI */
	 netwib_ip4opt_srr lsrr;
	 /* type stream : NI */
	 netwib_ip4opt_srr ssrr;
       } opt;
     } netwib_ip4opt;
     typedef const netwib_ip4opt netwib_constip4opt;

     /*-------------------------------------------------------------*/
     /* Name : netwib_ip4opt_initdefault
	Description :
	  Initialize a netwib_ip4opt with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *pip4opt : netwib_ip4opt to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_ip4opt_initdefault(netwib_ip4opttype ip4opttype,
					  netwib_ip4opt *pip4opt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_ip4opt
	Description :
	  Initialize physical data from a netwib_ip4opt.
	Input parameter(s) :
	  ip4opt : netwib_ip4opt
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_ip4opt(netwib_constip4opt *pip4opt,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_ip4opt(netwib_constip4opt *pip4opt,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_ip4opt
	Description :
	  Decode a netwib_ip4opt from data coming from wire.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *pip4opt : netwib_ip4opt to initialize
	  *pskipsize : size to skip this option
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_ip4opt(netwib_constbuf *ppkt,
					 netwib_ip4opt *pip4opt,
					 netwib_uint32 *pskipsize);

MODULE IP4OPTS
     /*-------------------------------------------------------------*/
     /***************************************************************
      * A "netwib_ip4opts" is a netwib_buf storing 0, 1 or more     *
      * netwib_ip4opt. There is no typedef for netwib_ip4opts.	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* maximum length of a buffer containing a "netwib_ip4opts" */
     #define NETWIB_IP4OPTS_MAXLEN 40

     /*-------------------------------------------------------------*/
     /***************************************************************
      * To create a "netwib_ip4opts", loop using function	    *
      * netwib_pkt_append_ip4opt.				    *
      * To decode a "netwib_ip4opts", loop using function	    *
      * netwib_pkt_decode_ip4opt.				    *
      ***************************************************************/

MODULE IP6EXT
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Following functions work on extension headers of IPv6.	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* IPv6 Hop-by-Hop Options extension header */
     typedef struct {
       netwib_bufext options;
     } netwib_ip6ext_hopopts;
     typedef const netwib_ip6ext_hopopts netwib_constip6ext_hopopts;

     /*-------------------------------------------------------------*/
     /* IPv6 Destination Options extension header */
     typedef struct {
       netwib_bufext options;
     } netwib_ip6ext_dstopts;
     typedef const netwib_ip6ext_dstopts netwib_constip6ext_dstopts;

     /*-------------------------------------------------------------*/
     /* IPv6 Routing extension header */
     typedef struct {
       netwib_uint8 routingtype;
       netwib_uint8 segmentsleft;
       netwib_bufext data;
     } netwib_ip6ext_routing;
     typedef const netwib_ip6ext_routing netwib_constip6ext_routing;

     /*-------------------------------------------------------------*/
     /* IPv6 Fragment extension header */
     typedef struct {
       netwib_uint16 fragmentoffset;
       netwib_bool reservedb1;
       netwib_bool reservedb2;
       netwib_bool morefrag;
       netwib_uint32 id;
     } netwib_ip6ext_fragment;
     typedef const netwib_ip6ext_fragment netwib_constip6ext_fragment;

     /*-------------------------------------------------------------*/
     /* IPv6 Authentication Header extension header (rfc 2402) */
     typedef struct {
       netwib_uint16 reserved;
       netwib_uint32 spi;
       netwib_uint32 seqnum;
       netwib_bufext data;
     } netwib_ip6ext_ah;
     typedef const netwib_ip6ext_ah netwib_constip6ext_ah;

     /*-------------------------------------------------------------*/
     /* Generic IPv6 extension header */
     typedef struct {
       netwib_ipproto proto;
       union {
	 netwib_ip6ext_hopopts hopopts;
	 netwib_ip6ext_dstopts dstopts;
	 netwib_ip6ext_routing routing;
	 netwib_ip6ext_fragment fragment;
	 netwib_ip6ext_ah ah;
       } ext;
       netwib_ipproto nextproto;
     } netwib_ip6ext;
     typedef const netwib_ip6ext netwib_constip6ext;

     /*-------------------------------------------------------------*/
     /* Name : netwib_ip6ext_initdefault
	Description :
	  Initialize a netwib_ip6ext with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *pip6ext : netwib_ip6ext to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_ip6ext_initdefault(netwib_ipproto proto,
					  netwib_ip6ext *pip6ext);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_ip6ext
	Description :
	  Initialize physical data from a netwib_ip6ext.
	Input parameter(s) :
	  ip6ext : netwib_ip6ext
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_ip6ext(netwib_constip6ext *pip6ext,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_ip6ext(netwib_constip6ext *pip6ext,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_ip6ext
	Description :
	  Decode a netwib_ip6ext from data coming from wire.
	Input parameter(s) :
	  pktproto : protocol of the netwib_ip6ext in ppkt
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *pip6ext : netwib_ip6ext to initialize
	  *pskipsize : size to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_ip6ext(netwib_ipproto pktproto,
					 netwib_constbuf *ppkt,
					 netwib_ip6ext *pip6ext,
					 netwib_uint32 *pskipsize);

MODULE IP6EXTS
     /*-------------------------------------------------------------*/
     /***************************************************************
      * A "netwib_ip6exts" is a netwib_buf storing 0, 1 or more     *
      * netwib_ip6ext. There is no typedef for netwib_ip6exts.	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /***************************************************************
      * To create a "netwib_ip6exts", loop using function	    *
      * netwib_pkt_append_ip6ext.				    *
      * To decode a "netwib_ip6exts", loop using function	    *
      * netwib_pkt_decode_ip6ext.				    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /***************************************************************
      * Normally, an IPv6 packet should be created and decoded	    *
      * layer by layer. So, there should be no need for an	    *
      * netwib_ip6exts, containing several layers/ip6_extensions.   *
      * However, this behavior makes harder the creation of	    *
      * functions for both IPv4 (which contains IP4 options) and    *
      * IPv6.							    *
      * So, in netwib the netwib_ip6hdr contains a buffer of	    *
      * netwib_ip6exts. 					    *
      * 							    *
      * When decoding a packet, the netwib_ip6exts buffer is set to *
      * all recognized extensions :				    *
      *   NETWIB_IPPROTO_HOPOPTS				    *
      *   NETWIB_IPPROTO_DSTOPTS				    *
      *   NETWIB_IPPROTO_ROUTING				    *
      *   NETWIB_IPPROTO_FRAGMENT				    *
      *   NETWIB_IPPROTO_AH					    *
      * Then, the packet eventually starts with unknown extensions  *
      * or real data.						    *
      * Example 1 :						    *
      *   packet is IP6+HOPOPTS+FRAGMENT+TCP			    *
      *   ip6exts in ip6hdr will contain : HOPOPTS+FRAGMENT	    *
      *   next data will be : TCP				    *
      * Example 2 :						    *
      *   packet is IP6+TCP					    *
      *   ip6exts in ip6hdr will contain : nothing		    *
      *   next data will be : TCP				    *
      * Example 3 :						    *
      *   packet is IP6+HOPOPTS+unknown+TCP			    *
      *   ip6exts in ip6hdr will contain : HOPOPTS		    *
      *   next data will be : unknown+TCP			    *
      * Example 4 :						    *
      *   packet is IP6+HOPOPTS+unknown+FRAGMENT+TCP		    *
      *   ip6exts in ip6hdr will contain : HOPOPTS		    *
      *   next data will be : unknown+FRAGMENT+TCP		    *
      * If you prefer the layer by layer behavior, just concatenate *
      * ip6exts and next_data.					    *
      * 							    *
      * When creating a packet, there are 2 ways :		    *
      *  - store extensions in ip6exts, or			    *
      *  - left empty ip6exts, and put extensions at the beginning  *
      *    of data						    *
      * The first solution is preferred, because netwib will	    *
      * magically deal with them if necessary.			    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /***************************************************************
      * RFC 2640 says "The Hop-by-Hop Options header, when present, *
      * must immediately follow the IPv6 header". This is not	    *
      * enforced in netwib.					    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_ip6exts
	Description :
	  Obtain size of all recognized extensions. Also obtain
	  the last proto and its offset (to easily overwrite it).
	  The recognized extensions are :
	     NETWIB_IPPROTO_HOPOPTS
	     NETWIB_IPPROTO_DSTOPTS
	     NETWIB_IPPROTO_ROUTING
	     NETWIB_IPPROTO_FRAGMENT
	     NETWIB_IPPROTO_AH
	Input parameter(s) :
	  pktproto : protocol of the netwib_ip6ext in ppkt
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *plastproto : last protocol
	  *plastprotooffset : offset of the byte describing the
			      last protocol. This value is unset
			      if skipsize == 0.
	  *pskipsize : size to skip this/those extensions. If 0,
		       there is no extension (in this case,
		       lastproto is set to pktproto).
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_ip6exts(netwib_ipproto pktproto,
					  netwib_constbuf *ppkt,
					  netwib_ipproto *plastproto,
					  netwib_uint32 *plastprotooffset,
					  netwib_uint32 *pskipsize);

MODULE ARPHDR
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Currently, only Ethernet-IPv4 is implemented as ARP.	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* ARP header */
     typedef enum {
       NETWIB_ARPHDROP_ARPREQ = 1,
       NETWIB_ARPHDROP_ARPREP = 2,
       NETWIB_ARPHDROP_RARPREQ = 3,
       NETWIB_ARPHDROP_RARPREP = 4
     } netwib_arphdrop;
     typedef struct
     { netwib_arphdrop op;
       netwib_eth ethsrc;
       netwib_ip ipsrc;
       netwib_eth ethdst;
       netwib_ip ipdst;
     } netwib_arphdr;
     typedef const netwib_arphdr netwib_constarphdr;
     #define NETWIB_ARPHDR_LEN 28

     /*-------------------------------------------------------------*/
     /* Name : netwib_arphdr_initdefault
	Description :
	  Initialize a netwib_arphdr with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *parphdr : netwib_arphdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_arphdr_initdefault(netwib_arphdr *parphdr);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_arphdr
	Description :
	  Initialize physical data from a netwib_arphdr.
	Input parameter(s) :
	  *parphdr : netwib_arphdr
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_arphdr(netwib_constarphdr *parphdr,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_arphdr(netwib_constarphdr *parphdr,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_arphdr
	Description :
	  Decode a netwib_arphdr from physical data.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *parphdr : netwib_arphdr contained in pkt
	  *pskipsize : size to use to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
	  NETWIB_ERR_NOTCONVERTED : pkt could not be decoded
	  NETWIB_ERR_DATAMISSING : pkt was not big enough
     */
     netwib_err netwib_pkt_decode_arphdr(netwib_constbuf *ppkt,
					 netwib_arphdr *parphdr,
					 netwib_uint32 *pskipsize);

MODULE TCPHDR
     /*-------------------------------------------------------------*/
     /* TCP header */
     typedef struct {
       netwib_port src;
       netwib_port dst;
       netwib_uint32 seqnum;
       netwib_uint32 acknum;
       netwib_uint8 doff;
       netwib_bool reserved1;
       netwib_bool reserved2;
       netwib_bool reserved3;
       netwib_bool reserved4;
       netwib_bool cwr; /* RFC 3168 */
       netwib_bool ece; /* RFC 3168 */
       netwib_bool urg;
       netwib_bool ack;
       netwib_bool psh;
       netwib_bool rst;
       netwib_bool syn;
       netwib_bool fin;
       netwib_uint16 window;
       netwib_uint16 check;
       netwib_uint16 urgptr;
       netwib_bufext opts; /* TCP options as defined in tcpopts.h */
     } netwib_tcphdr;
     typedef const netwib_tcphdr netwib_consttcphdr;
     #define NETWIB_TCPHDR_MINLEN 20
     #define NETWIB_TCPHDR_MAXLEN 64

     /*-------------------------------------------------------------*/
     /* Name : netwib_tcphdr_initdefault
	Description :
	  Initialize a netwib_tcphdr with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *ptcphdr : netwib_tcphdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_tcphdr_initdefault(netwib_tcphdr *ptcphdr);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_tcphdr
	Description :
	  Initialize physical data from a netwib_tcphdr.
	Input parameter(s) :
	  *ptcphdr : netwib_tcphdr
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
	Note : field doff is eventually recomputed.
     */
     netwib_err netwib_pkt_append_tcphdr(netwib_consttcphdr *ptcphdr,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_tcphdr(netwib_consttcphdr *ptcphdr,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_tcphdr
	Description :
	  Decode a netwib_tcphdr from physical data.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *ptcphdr : netwib_tcphdr contained in pkt
	  *pskipsize : size to use to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
	  NETWIB_ERR_NOTCONVERTED : pkt could not be decoded
	  NETWIB_ERR_DATAMISSING : pkt was not big enough
     */
     netwib_err netwib_pkt_decode_tcphdr(netwib_constbuf *ppkt,
					 netwib_tcphdr *ptcphdr,
					 netwib_uint32 *pskipsize);

MODULE UDPHDR
     /*-------------------------------------------------------------*/
     /* UDP header */
     typedef struct {
       netwib_port src;
       netwib_port dst;
       netwib_uint16 len;
       netwib_uint16 check;
     } netwib_udphdr;
     typedef const netwib_udphdr netwib_constudphdr;
     #define NETWIB_UDPHDR_LEN 8

     /*-------------------------------------------------------------*/
     /* Name : netwib_udphdr_initdefault
	Description :
	  Initialize a netwib_udphdr with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *pudphdr : netwib_udphdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_udphdr_initdefault(netwib_udphdr *pudphdr);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_udphdr
	Description :
	  Initialize physical data from a netwib_udphdr.
	Input parameter(s) :
	  *pudphdr : netwib_udphdr
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_udphdr(netwib_constudphdr *pudphdr,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_udphdr(netwib_constudphdr *pudphdr,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_udphdr
	Description :
	  Decode a netwib_udphdr from physical data.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *pudphdr : netwib_udphdr contained in pkt
	  *pskipsize : size to use to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
	  NETWIB_ERR_NOTCONVERTED : pkt could not be decoded
	  NETWIB_ERR_DATAMISSING : pkt was not big enough
     */
     netwib_err netwib_pkt_decode_udphdr(netwib_constbuf *ppkt,
					 netwib_udphdr *pudphdr,
					 netwib_uint32 *pskipsize);

MODULE TCPOPT
     /*-------------------------------------------------------------*/
     typedef enum {
       NETWIB_TCPOPTTYPE_END = 0,	   /* rfc 793 - end of options */
       NETWIB_TCPOPTTYPE_NOOP = 1,	   /* rfc 793 - no operation */
       NETWIB_TCPOPTTYPE_MSS = 2,	   /* rfc 793 - maximum segment size */
       NETWIB_TCPOPTTYPE_WINDOWSCALE = 3,  /* rfc 1323 - window scale */
       NETWIB_TCPOPTTYPE_SACKPERMITTED = 4,/* rfc 2018 - SACK permitted */
       NETWIB_TCPOPTTYPE_SACK = 5,    /* rfc 2018 - selective acknowledgment */
       NETWIB_TCPOPTTYPE_ECHOREQUEST = 6,  /* rfc 1072 - echo request */
       NETWIB_TCPOPTTYPE_ECHOREPLY = 7,    /* rfc 1072 - echo reply */
       NETWIB_TCPOPTTYPE_TIMESTAMP = 8,    /* rfc 1323 - timestamp */
       NETWIB_TCPOPTTYPE_CC = 11,	   /* rfc 1644 - connection count */
       NETWIB_TCPOPTTYPE_CCNEW = 12,	   /* rfc 1644 - connection count */
       NETWIB_TCPOPTTYPE_CCECHO = 13	   /* rfc 1644 - connection count */
     } netwib_tcpopttype;

     /*-------------------------------------------------------------*/
     /* maximum length of one TCP option */
     #define NETWIB_TCPOPT_MAXLEN 40

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint16 maxsegsize;
     } netwib_tcpopt_mss;
     typedef const netwib_tcpopt_mss netwib_consttcpopt_mss;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint8 windowscale;
     } netwib_tcpopt_windowscale;
     typedef const netwib_tcpopt_windowscale netwib_consttcpopt_windowscale;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 storedvalues; /* 0 to 4 */
       netwib_uint32 leftedge[4];
       netwib_uint32 rightedge[4];
     } netwib_tcpopt_sack;
     typedef const netwib_tcpopt_sack netwib_consttcpopt_sack;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 data;
     } netwib_tcpopt_echo;
     typedef const netwib_tcpopt_echo netwib_consttcpopt_echo;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 val;
       netwib_uint32 echoreply;
     } netwib_tcpopt_timestamp;
     typedef const netwib_tcpopt_timestamp netwib_consttcpopt_timestamp;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 connectioncount;
     } netwib_tcpopt_cc;
     typedef const netwib_tcpopt_cc netwib_consttcpopt_cc;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_tcpopttype type;
       union {
	 /* type end : no value */
	 /* type noop : no value */
	 netwib_tcpopt_mss mss;
	 netwib_tcpopt_windowscale windowscale;
	 /* type sackpermitted : no value */
	 netwib_tcpopt_sack sack;
	 netwib_tcpopt_echo echo; /* used for request and reply */
	 netwib_tcpopt_timestamp timestamp;
	 netwib_tcpopt_cc cc; /* used for cc, ccnew and ccecho */
       } opt;
     } netwib_tcpopt;
     typedef const netwib_tcpopt netwib_consttcpopt;

     /*-------------------------------------------------------------*/
     /* Name : netwib_tcpopt_initdefault
	Description :
	  Initialize a netwib_tcpopt with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *ptcpopt : netwib_tcpopt to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_tcpopt_initdefault(netwib_tcpopttype tcpopttype,
					  netwib_tcpopt *ptcpopt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_tcpopt
	Description :
	  Initialize physical data from a netwib_tcpopt.
	Input parameter(s) :
	  tcpopt : netwib_tcpopt
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_tcpopt(netwib_consttcpopt *ptcpopt,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_prepend_tcpopt(netwib_consttcpopt *ptcpopt,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_tcpopt
	Description :
	  Decode a netwib_tcpopt from data coming from wire.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *ptcpopt : netwib_tcpopt to initialize
	  *pskipsize : size to skip this option
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_tcpopt(netwib_constbuf *ppkt,
					 netwib_tcpopt *ptcpopt,
					 netwib_uint32 *pskipsize);

MODULE TCPOPTS
     /*-------------------------------------------------------------*/
     /***************************************************************
      * A "netwib_tcpopts" is a netwib_buf storing 0, 1 or more     *
      * netwib_tcpopt. There is no typedef for netwib_tcpopts.	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* maximum length of a buffer containing a "netwib_tcpopts" */
     #define NETWIB_TCPOPTS_MAXLEN 40

     /*-------------------------------------------------------------*/
     /***************************************************************
      * To create a "netwib_tcpopts", loop using function	    *
      * netwib_pkt_append_tcpopt.				    *
      * To decode a "netwib_tcpopts", loop using function	    *
      * netwib_pkt_decode_tcpopt.				    *
      ***************************************************************/

MODULE IP64BITS
     /*-------------------------------------------------------------*/
     /* Name : netwib_ip64bits_init_ippkt
	Description :
	  Initialize a buffer containing an IP header and
	  64 bits of data.
	  This kind of packets are needed for errors (cf. rfc 792).
	Input parameter(s) :
	  *piphdr : IP header
	  *pipdata : IP data
	  *phdrudp : udp header
	  *phdrtcp : tcp header
	Input/output parameter(s) :
	Output parameter(s) :
	  *pip64bits : buffer containing an IP header and
		       64 bits of data.
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_ip64bits_init_ippkt(netwib_constbuf *pippkt,
					   netwib_bufext *pip64bits);

     /*-------------------------------------------------------------*/
     /* Name : netwib_ip64bits_decode_ipxyz
	Description :
	  Try to decode ip packet contained in ip64bits.
	Input parameter(s) :
	  *pip64bits : ip header and at least 64 bits of ip data
	Input/output parameter(s) :
	Output parameter(s) :
	  *piphdr : decoded IP header
	  *pipdata : buffer containing ip data
	  *pudpsrc : udp source port
	  *pudpdst : udp destination port
	  *pudplen : udp len
	  *pudpcheck : udp checksum
	  *ptcpsrc : tcp source port
	  *ptcpdst : tcp destination port
	  *pseqnum : tcp sequence number
	Normal return values :
	  NETWIB_ERR_OK : ok
	  NETWIB_ERR_NOTCONVERTED : packet not decoded
	  NETWIB_ERR_DATAMISSING : pkt was not big enough
     */
     netwib_err netwib_ip64bits_decode_ipudp(netwib_constbuf *pip64bits,
					     netwib_iphdr *piphdr,
					     netwib_port *pudpsrc,
					     netwib_port *pudpdst);
     netwib_err netwib_ip64bits_decode_iptcp(netwib_constbuf *pip64bits,
					     netwib_iphdr *piphdr,
					     netwib_port *ptcpsrc,
					     netwib_port *ptcpdst);
     #define netwib_ip64bits_decode_ipdata(pip64bits,piphdr,pipdata) netwib_pkt_decode_ipdata(pip64bits,piphdr,pipdata)

MODULE ICMP4
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Refer to RFC 792 to obtain more information about ICMPv4.   *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* ICMP4 types. Comments starting with "NI" are not implemented */
     typedef enum {
       NETWIB_ICMP4TYPE_ECHOREP = 0,	   /* echo reply */
       NETWIB_ICMP4TYPE_DSTUNREACH = 3,    /* destination unreachable */
       NETWIB_ICMP4TYPE_SRCQUENCH = 4,	   /* source quench */
       NETWIB_ICMP4TYPE_REDIRECT = 5,	   /* redirect */
       NETWIB_ICMP4TYPE_ALTHOSTAD = 6,	   /* NI www.iana.org */
       NETWIB_ICMP4TYPE_ECHOREQ = 8,	   /* echo request */
       NETWIB_ICMP4TYPE_ROUTERADVERT = 9,  /* NI rfc 1256 */
       NETWIB_ICMP4TYPE_ROUTERSELECT = 10, /* NI rfc 1256 */
       NETWIB_ICMP4TYPE_TIMEEXCEED = 11,   /* time exceeded */
       NETWIB_ICMP4TYPE_PARAPROB = 12,	   /* parameter problem */
       NETWIB_ICMP4TYPE_TIMESTAMPREQ = 13, /* timestamp request */
       NETWIB_ICMP4TYPE_TIMESTAMPREP = 14, /* timestamp reply */
       NETWIB_ICMP4TYPE_INFOREQ = 15,	   /* information request */
       NETWIB_ICMP4TYPE_INFOREP = 16,	   /* information reply */
       NETWIB_ICMP4TYPE_ADMASKREQ = 17,    /* NI rfc 950 */
       NETWIB_ICMP4TYPE_ADMASKREP = 18,    /* NI rfc 950 */
       NETWIB_ICMP4TYPE_TRACEROUTE = 30,   /* NI rfc 1393 */
       NETWIB_ICMP4TYPE_DATACONVERR = 31,  /* NI rfc 1474 */
       NETWIB_ICMP4TYPE_MOBHOSTREDIR = 32, /* NI www.iana.org */
       NETWIB_ICMP4TYPE_IPV6WHEREYOU = 33, /* NI www.iana.org */
       NETWIB_ICMP4TYPE_IPV6IAMHERE = 34,  /* NI www.iana.org */
       NETWIB_ICMP4TYPE_MOBREGREQ = 35,    /* NI www.iana.org */
       NETWIB_ICMP4TYPE_MOBREGREP = 36,    /* NI www.iana.org */
       NETWIB_ICMP4TYPE_SKIP = 39,	   /* NI www.iana.org */
       NETWIB_ICMP4TYPE_PHOTURIS = 40	   /* NI www.iana.org */
     } netwib_icmp4type;

     /*-------------------------------------------------------------*/
     typedef enum {
       NETWIB_ICMP4CODE_ECHOREP = 0,
       NETWIB_ICMP4CODE_DSTUNREACH_NET = 0,
       NETWIB_ICMP4CODE_DSTUNREACH_HOST = 1,
       NETWIB_ICMP4CODE_DSTUNREACH_PROTO = 2,
       NETWIB_ICMP4CODE_DSTUNREACH_PORT = 3,
       NETWIB_ICMP4CODE_DSTUNREACH_FRAG = 4,
       NETWIB_ICMP4CODE_DSTUNREACH_SR = 5,
       NETWIB_ICMP4CODE_DSTUNREACH_NETUNKNOWN = 6,
       NETWIB_ICMP4CODE_DSTUNREACH_HOSTUNKNOWN = 7,
       NETWIB_ICMP4CODE_DSTUNREACH_HOSTISOL = 8,
       NETWIB_ICMP4CODE_DSTUNREACH_NETPROHI = 9,
       NETWIB_ICMP4CODE_DSTUNREACH_HOSTPROHI = 10,
       NETWIB_ICMP4CODE_DSTUNREACH_NETTOS = 11,
       NETWIB_ICMP4CODE_DSTUNREACH_HOSTTOS = 12,
       NETWIB_ICMP4CODE_DSTUNREACH_PROHI = 13,
       NETWIB_ICMP4CODE_DSTUNREACH_PRECVIOL = 14,
       NETWIB_ICMP4CODE_DSTUNREACH_PRECCUTOFF = 15,
       NETWIB_ICMP4CODE_SRCQUENCH = 0,
       NETWIB_ICMP4CODE_REDIRECT_NET = 0,
       NETWIB_ICMP4CODE_REDIRECT_HOST = 1,
       NETWIB_ICMP4CODE_REDIRECT_NETTOS = 2,
       NETWIB_ICMP4CODE_REDIRECT_HOSTTOS = 3,
       NETWIB_ICMP4CODE_ECHOREQ = 0,
       NETWIB_ICMP4CODE_TIMEEXCEED_TTL = 0,
       NETWIB_ICMP4CODE_TIMEEXCEED_FRAG = 1,
       NETWIB_ICMP4CODE_PARAPROB_POINTER = 0,
       NETWIB_ICMP4CODE_PARAPROB_MISSOPT = 1,
       NETWIB_ICMP4CODE_PARAPROB_BADLEN = 2,
       NETWIB_ICMP4CODE_TIMESTAMPREQ = 0,
       NETWIB_ICMP4CODE_TIMESTAMPREP = 0,
       NETWIB_ICMP4CODE_INFOREQ = 0,
       NETWIB_ICMP4CODE_INFOREP = 0
     } netwib_icmp4code;

     /*-------------------------------------------------------------*/
     /* Name : netwib_buf_append_icmp4type
	Description :
	  Print the text corresponding to icmp type.
	Input parameter(s) :
	  type : icmp4 type
	Input/output parameter(s) :
	  *pbuf : netwib_buf receiving data
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_buf_append_icmp4type(netwib_icmp4type type,
					    netwib_buf *pbuf);

     /*-------------------------------------------------------------*/
     /* Name : netwib_buf_append_icmp4code
	Description :
	  Print the text corresponding to icmp code.
	Input parameter(s) :
	  type : icmp4 type
	  code : icmp4 code
	Input/output parameter(s) :
	  *pbuf : netwib_buf receiving data
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_buf_append_icmp4code(netwib_icmp4type type,
					    netwib_icmp4code code,
					    netwib_buf *pbuf);

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint16 id;
       netwib_uint16 seqnum;
       netwib_bufext data;
     } netwib_icmp4_echo;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp4_dstunreach;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp4_srcquench;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_ip gw;
       netwib_bufext badippacket;
     } netwib_icmp4_redirect;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp4_timeexceed;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint8 pointer;
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp4_paraprob;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint16 id;
       netwib_uint16 seqnum;
       netwib_uint32 originatetimestamp;
       netwib_uint32 receivetimestamp;
       netwib_uint32 transmittimestamp;
     } netwib_icmp4_timestamp;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint16 id;
       netwib_uint16 seqnum;
       netwib_bufext data;
     } netwib_icmp4_info;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_icmp4type type;
       netwib_icmp4code code;
       netwib_uint16 check;
       union {
	 netwib_icmp4_echo echo; /* used for request and reply */
	 netwib_icmp4_dstunreach dstunreach;
	 netwib_icmp4_srcquench srcquench;
	 netwib_icmp4_redirect redirect;
	 netwib_icmp4_timeexceed timeexceed;
	 netwib_icmp4_paraprob paraprob;
	 netwib_icmp4_timestamp timestamp; /* used for req and rep */
	 netwib_icmp4_info info; /* used for request and reply */
       } msg;
     } netwib_icmp4;
     typedef const netwib_icmp4 netwib_consticmp4;
     #define NETWIB_ICMP4_MINLEN 4

     /*-------------------------------------------------------------*/
     /* Name : netwib_icmp4_initdefault
	Description :
	  Initialize a netwib_icmp4 with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp4hdr : netwib_icmp4hdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_icmp4_initdefault(netwib_icmp4type type,
					 netwib_icmp4 *picmp4);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_icmp4
	Description :
	  Initialize physical data from a netwib_icmp4.
	Input parameter(s) :
	  icmp4 : netwib_icmp4
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_icmp4(netwib_consticmp4 *picmp4,
					netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_icmp4
	Description :
	  Decode a netwib_icmp4 from data coming from wire.
	Input parameter(s) :
	  pktproto : protocol of the netwib_icmp4 in ppkt
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp4 : netwib_icmp4 to initialize
	  *pskipsize : size to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_icmp4(netwib_constbuf *ppkt,
					netwib_icmp4 *picmp4,
					netwib_uint32 *pskipsize);

MODULE ICMP6
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Refer to RFC 2463 to obtain more information about ICMPv6.  *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /* ICMP6 types. Comments starting with "NI" are not implemented */
     typedef enum {
       NETWIB_ICMP6TYPE_DSTUNREACH = 1,    /* destination unreachable */
       NETWIB_ICMP6TYPE_PKTTOOBIG = 2,	   /* packet too big */
       NETWIB_ICMP6TYPE_TIMEEXCEED = 3,    /* time exceeded */
       NETWIB_ICMP6TYPE_PARAPROB = 4,	   /* parameter problem */
       NETWIB_ICMP6TYPE_ECHOREQ = 128,	   /* echo request */
       NETWIB_ICMP6TYPE_ECHOREP = 129,	   /* echo reply */
       NETWIB_ICMP6TYPE_ROUTERSOLICIT = 133, /* router solicitation (rfc2461) */
       NETWIB_ICMP6TYPE_ROUTERADVERT = 134,    /* router advert. (rfc2461) */
       NETWIB_ICMP6TYPE_NEIGHBORSOLICIT = 135, /* neighbor soli. (rfc2461) */
       NETWIB_ICMP6TYPE_NEIGHBORADVERT = 136,  /* neighbor advert. (rfc2461) */
       NETWIB_ICMP6TYPE_REDIRECT = 137	       /* redirect (rfc2461) */
     } netwib_icmp6type;

     /*-------------------------------------------------------------*/
     typedef enum {
       NETWIB_ICMP6CODE_DSTUNREACH_NOROUTE = 0,
       NETWIB_ICMP6CODE_DSTUNREACH_PROHI = 1,
       NETWIB_ICMP6CODE_DSTUNREACH_HOST = 3,
       NETWIB_ICMP6CODE_DSTUNREACH_PORT = 4,
       NETWIB_ICMP6CODE_PKTTOOBIG = 0,
       NETWIB_ICMP6CODE_TIMEEXCEED_TTL = 0,
       NETWIB_ICMP6CODE_TIMEEXCEED_FRAG = 1,
       NETWIB_ICMP6CODE_PARAPROB_HDR = 0,
       NETWIB_ICMP6CODE_PARAPROB_NEXTHDR = 1,
       NETWIB_ICMP6CODE_PARAPROB_OPTION = 2,
       NETWIB_ICMP6CODE_ECHOREQ = 0,
       NETWIB_ICMP6CODE_ECHOREP = 0,
       NETWIB_ICMP6CODE_ROUTERSOLICIT = 0,
       NETWIB_ICMP6CODE_ROUTERADVERT = 0,
       NETWIB_ICMP6CODE_NEIGHBORSOLICIT = 0,
       NETWIB_ICMP6CODE_NEIGHBORADVERT = 0,
       NETWIB_ICMP6CODE_REDIRECT = 0
     } netwib_icmp6code;

     /*-------------------------------------------------------------*/
     /* Name : netwib_buf_append_icmp6type
	Description :
	  Print the text corresponding to icmp type.
	Input parameter(s) :
	  type : icmp6 type
	Input/output parameter(s) :
	  *pbuf : netwib_buf receiving data
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_buf_append_icmp6type(netwib_icmp6type type,
					    netwib_buf *pbuf);

     /*-------------------------------------------------------------*/
     /* Name : netwib_buf_append_icmp6code
	Description :
	  Print the text corresponding to icmp code.
	Input parameter(s) :
	  type : icmp6 type
	  code : icmp6 code
	Input/output parameter(s) :
	  *pbuf : netwib_buf receiving data
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_buf_append_icmp6code(netwib_icmp6type type,
					    netwib_icmp6code code,
					    netwib_buf *pbuf);

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp6_dstunreach;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 mtu;
       netwib_bufext badippacket;
     } netwib_icmp6_pkttoobig;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext badippacket;
     } netwib_icmp6_timeexceed;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 pointer;
       netwib_bufext badippacket;
     } netwib_icmp6_paraprob;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint16 id;
       netwib_uint16 seqnum;
       netwib_bufext data;
     } netwib_icmp6_echo;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_bufext options; /* buffer contains netwib_icmp6nd */
     } netwib_icmp6_routersolicit;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint8 curhoplimit;
       netwib_bool managedaddress;
       netwib_bool otherstateful;
       netwib_uint8 reserved;
       netwib_uint16 routerlifetime;
       netwib_uint32 reachabletime;
       netwib_uint32 retranstimer;
       netwib_bufext options; /* buffer contains netwib_icmp6nd */
     } netwib_icmp6_routeradvert;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_ip target;
       netwib_bufext options; /* buffer contains netwib_icmp6nd */
     } netwib_icmp6_neighborsolicit;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_bool router;
       netwib_bool solicited;
       netwib_bool override;
       netwib_uint32 reserved;
       netwib_ip target;
       netwib_bufext options; /* buffer contains netwib_icmp6nd */
     } netwib_icmp6_neighboradvert;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_uint32 reserved;
       netwib_ip target;
       netwib_ip dst;
       netwib_bufext options; /* buffer contains netwib_icmp6nd */
     } netwib_icmp6_redirect;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_icmp6type type;
       netwib_icmp6code code;
       netwib_uint16 check;
       union {
	 netwib_icmp6_dstunreach dstunreach;
	 netwib_icmp6_pkttoobig pkttoobig;
	 netwib_icmp6_timeexceed timeexceed;
	 netwib_icmp6_paraprob paraprob;
	 netwib_icmp6_echo echo; /* used for request and reply */
	 netwib_icmp6_routersolicit routersolicit;
	 netwib_icmp6_routeradvert routeradvert;
	 netwib_icmp6_neighborsolicit neighborsolicit;
	 netwib_icmp6_neighboradvert neighboradvert;
	 netwib_icmp6_redirect redirect;
       } msg;
     } netwib_icmp6;
     typedef const netwib_icmp6 netwib_consticmp6;
     #define NETWIB_ICMP6_MINLEN 4

     /*-------------------------------------------------------------*/
     /* Name : netwib_icmp6_initdefault
	Description :
	  Initialize a netwib_icmp6 with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp6hdr : netwib_icmp6hdr to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_icmp6_initdefault(netwib_icmp6type type,
					 netwib_icmp6 *picmp6);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_icmp6
	Description :
	  Initialize physical data from a netwib_icmp6.
	Input parameter(s) :
	  icmp6 : netwib_icmp6
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_icmp6(netwib_consticmp6 *picmp6,
					netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_icmp6
	Description :
	  Decode a netwib_icmp6 from data coming from wire.
	Input parameter(s) :
	  pktproto : protocol of the netwib_icmp6 in ppkt
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp6 : netwib_icmp6 to initialize
	  *pskipsize : size to skip this header
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_icmp6(netwib_constbuf *ppkt,
					netwib_icmp6 *picmp6,
					netwib_uint32 *pskipsize);

MODULE ICMP6ND
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Refer to RFC 2461 to obtain more information about ICMPv6   *
      * Neighbor Discovery options.				    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     typedef enum {
       NETWIB_ICMP6NDTYPE_SRCLINK = 1, /* src link layer address */
       NETWIB_ICMP6NDTYPE_DSTLINK = 2, /* dst link layer address */
       NETWIB_ICMP6NDTYPE_PREFIX = 3,  /* prefix information */
       NETWIB_ICMP6NDTYPE_REDIR = 4,   /* redirected */
       NETWIB_ICMP6NDTYPE_MTU = 5      /* mtu */
     } netwib_icmp6ndtype;

     /*-------------------------------------------------------------*/
     typedef struct {
       netwib_eth linkad;
     } netwib_icmp6nd_link;
     typedef const netwib_icmp6nd_link netwib_consticmp6nd_link;

     typedef struct {
       netwib_uint8 prefixlength;
       netwib_bool onlink;
       netwib_bool autonomous;
       netwib_uint8 reserved1;
       netwib_uint32 validlifetime;
       netwib_uint32 preferredlifetime;
       netwib_uint32 reserved2;
       netwib_ip prefix;
     } netwib_icmp6nd_prefix;
     typedef const netwib_icmp6nd_prefix netwib_consticmp6nd_prefix;

     typedef struct {
       netwib_uint16 reserved1;
       netwib_uint32 reserved2;
       netwib_bufext badippacket;
     } netwib_icmp6nd_redir;
     typedef const netwib_icmp6nd_redir netwib_consticmp6nd_redir;

     typedef struct {
       netwib_uint16 reserved;
       netwib_uint32 mtu;
     } netwib_icmp6nd_mtu;
     typedef const netwib_icmp6nd_mtu netwib_consticmp6nd_mtu;

     typedef struct {
       netwib_icmp6ndtype type;
       union {
	 netwib_icmp6nd_link link;
	 netwib_icmp6nd_prefix prefix;
	 netwib_icmp6nd_redir redir;
	 netwib_icmp6nd_mtu mtu;
       } opt;
     } netwib_icmp6nd;
     typedef const netwib_icmp6nd netwib_consticmp6nd;

     /*-------------------------------------------------------------*/
     /* Name : netwib_icmp6nd_initdefault
	Description :
	  Initialize a netwib_icmp6nd with default values.
	Input parameter(s) :
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp6nd : netwib_icmp6nd to initialize
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_icmp6nd_initdefault(netwib_icmp6ndtype icmp6ndtype,
					   netwib_icmp6nd *picmp6nd);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_append_icmp6nd
	Description :
	  Initialize physical data from a netwib_icmp6nd.
	Input parameter(s) :
	  icmp6nd : netwib_icmp6nd
	Input/output parameter(s) :
	  *ppht : buffer to initialize
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_append_icmp6nd(netwib_consticmp6nd *picmp6nd,
					  netwib_buf *ppkt);

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_decode_icmp6nd
	Description :
	  Decode a netwib_icmp6nd from data coming from wire.
	Input parameter(s) :
	  *ppkt : buffer containing physical data
	Input/output parameter(s) :
	Output parameter(s) :
	  *picmp6nd : netwib_icmp6nd to initialize
	  *pskipsize : size to skip this option
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_decode_icmp6nd(netwib_constbuf *ppkt,
					  netwib_icmp6nd *picmp6nd,
					  netwib_uint32 *pskipsize);

MODULE LAYER
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Following functions create/decode layers. Their names	    *
      * should be self explaining.				    *
      * Note : when decoding a layer, ppkt buffer is automatically  *
      *        shifted to point to next entry.			    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /***************************************************************
      * Some header fields are computed by functions append_layer:  *
      *  - linkhdr.ethhdr.type					    *
      *  - iphdr.protocol					    *
      *  - iphdr.header.ip4.ihl 				    *
      *  - iphdr.header.ip4.totlen				    *
      *  - iphdr.header.ip4.check				    *
      *  - iphdr.header.ip6.payloadlength			    *
      *  - udphdr.len						    *
      *  - udphdr.check 					    *
      *  - tcphdr.doff						    *
      *  - tcphdr.check 					    *
      *  - icmp4hdr.check					    *
      * To use fake values for those fields, they have to be edited *
      * after packet construction.				    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     /***************************************************************
      * Which functions to use ?				    *
      * 							    *
      * Netwib has 3 kind of functions to decode packets:	    *
      *  - netwib_pkt_decode_abc ie netwib_pkt_decode_iphdr	    *
      *  - netwib_pkt_decode_layer_abc ie netwib_pkt_decode_layer_ip*
      *  - netwib_pkt_decode_abcABC ie netwib_pkt_decode_iptcp	    *
      * Functions netwib_pkt_decode_abc and			    *
      * netwib_pkt_decode_layer_abc are almost equivalent.	    *
      * Functions netwib_pkt_decode_abcABC permits to decode only   *
      * one kind of protocol : ABC on top of abc. So, they can only *
      * be used in simple cases.				    *
      * 							    *
      * Netwib has 3 kind of functions to create packets:	    *
      *  - netwib_pkt_append_abc ie netwib_pkt_append_iphdr	    *
      *  - netwib_pkt_append_layer_abc ie netwib_pkt_append_layer_ip*
      *  - netwib_pkt_append_abcABC ie netwib_pkt_append_iptcp	    *
      * Functions netwib_pkt_append_abc use exact fields given as   *
      * parameters from users.					    *
      * Functions netwib_pkt_append_layer_abc compute fields before *
      * storing them in the packet.				    *
      * Functions netwib_pkt_append_abcABC permits to create only   *
      * one kind of protocol : ABC on top of abc. So, they can only *
      * be used in simple cases.				    *
      * 							    *
      * Summary: when possible, use netwib_pkt_append/decode_layer  *
      * 	 which are :					    *
      * 	  - easier than netwib_pkt_append/decode_abc	    *
      * 	    because they compute fields 		    *
      * 	  - faster than netwib_pkt_append/decode_abcABC     *
      * 	    if several protocols of the same layer have to  *
      * 	    be decoded (for example : iptcp and ipudp)	    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_data(netwib_constbuf *pdata,
					     netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_data(netwib_buf *ppkt,
					     netwib_bufext *pdata);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_link(netwib_constlinkhdr *plinkhdr,
					     netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_link(netwib_device_dlttype dlttype,
					     netwib_buf *ppkt,
					     netwib_linkhdr *plinkhdr);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_ip(netwib_constiphdr *piphdr,
					   netwib_uint32 datasize,
					   netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_ip(netwib_buf *ppkt,
					   netwib_iphdr *piphdr);

     /*-------------------------------------------------------------*/
     /* fields followed by "checksum" are needed only for checksum
	computation */
     netwib_err netwib_pkt_append_layer_udp(netwib_constiphdr *piphdr,/*checksum*/
					    netwib_constudphdr *pudphdr,
					    netwib_constbuf *pudpdata,/*checksum*/
					    netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_udp(netwib_buf *ppkt,
					    netwib_udphdr *pudphdr);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_tcp(netwib_constiphdr *piphdr,/*checksum*/
					    netwib_consttcphdr *ptcphdr,
					    netwib_constbuf *ptcpdata,/*checksum*/
					    netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_tcp(netwib_buf *ppkt,
					    netwib_tcphdr *ptcphdr);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_icmp4(netwib_consticmp4 *picmp4,
					      netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_icmp4(netwib_buf *ppkt,
					      netwib_icmp4 *picmp4);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_icmp6(netwib_constiphdr *piphdr,
					      netwib_consticmp6 *picmp6,
					      netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_icmp6(netwib_buf *ppkt,
					      netwib_icmp6 *picmp6);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_layer_arp(netwib_constarphdr *parphdr,
					    netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_layer_arp(netwib_buf *ppkt,
					    netwib_arphdr *parphdr);

MODULE PACKET
     /*-------------------------------------------------------------*/
     /***************************************************************
      * Following functions create/decode packets. Their names	    *
      * should be self explaining. They are specialized in decoding *
      * one kind of packet. To support several kind of packets, use *
      * netwib_pkt_decode_layer_abc instead.			    *
      ***************************************************************/

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_linkdata(netwib_constlinkhdr *plinkhdr,
					   netwib_constbuf *pdata,
					   netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkdata(netwib_device_dlttype dlttype,
					   netwib_constbuf *ppkt,
					   netwib_linkhdr *plinkhdr,
					   netwib_bufext *pdata);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_ipdata(netwib_constiphdr *piphdr,
					 netwib_constbuf *pdata,
					 netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_ipdata(netwib_constbuf *ppkt,
					 netwib_iphdr *piphdr,
					 netwib_bufext *pdata);
     netwib_err netwib_pkt_append_linkipdata(netwib_constlinkhdr *plinkhdr,
					     netwib_constiphdr *piphdr,
					     netwib_constbuf *pdata,
					     netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkipdata(netwib_device_dlttype dlttype,
					     netwib_constbuf *ppkt,
					     netwib_linkhdr *plinkhdr,
					     netwib_iphdr *piphdr,
					     netwib_bufext *pdata);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_ipudpdata(netwib_constiphdr *piphdr,
					    netwib_constudphdr *pudphdr,
					    netwib_constbuf *pdata,
					    netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_ipudpdata(netwib_constbuf *ppkt,
					    netwib_iphdr *piphdr,
					    netwib_udphdr *pudphdr,
					    netwib_bufext *pdata);
     netwib_err netwib_pkt_append_linkipudpdata(netwib_constlinkhdr *plinkhdr,
						netwib_constiphdr *piphdr,
						netwib_constudphdr *pudphdr,
						netwib_constbuf *pdata,
						netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkipudpdata(netwib_device_dlttype dlttype,
						netwib_constbuf *ppkt,
						netwib_linkhdr *plinkhdr,
						netwib_iphdr *piphdr,
						netwib_udphdr *pudphdr,
						netwib_bufext *pdata);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_iptcpdata(netwib_constiphdr *piphdr,
					    netwib_consttcphdr *ptcphdr,
					    netwib_constbuf *pdata,
					    netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_iptcpdata(netwib_constbuf *ppkt,
					    netwib_iphdr *piphdr,
					    netwib_tcphdr *ptcphdr,
					    netwib_bufext *pdata);
     netwib_err netwib_pkt_append_linkiptcpdata(netwib_constlinkhdr *plinkhdr,
						netwib_constiphdr *piphdr,
						netwib_consttcphdr *ptcphdr,
						netwib_constbuf *pdata,
						netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkiptcpdata(netwib_device_dlttype dlttype,
						netwib_constbuf *ppkt,
						netwib_linkhdr *plinkhdr,
						netwib_iphdr *piphdr,
						netwib_tcphdr *ptcphdr,
						netwib_bufext *pdata);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_ipicmp4(netwib_constiphdr *piphdr,
					  netwib_consticmp4 *picmp4,
					  netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_ipicmp4(netwib_constbuf *ppkt,
					  netwib_iphdr *piphdr,
					  netwib_icmp4 *picmp4);
     netwib_err netwib_pkt_append_linkipicmp4(netwib_constlinkhdr *plinkhdr,
					      netwib_constiphdr *piphdr,
					      netwib_consticmp4 *picmp4,
					      netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkipicmp4(netwib_device_dlttype dlttype,
					      netwib_constbuf *ppkt,
					      netwib_linkhdr *plinkhdr,
					      netwib_iphdr *piphdr,
					      netwib_icmp4 *picmp4);

     /*-------------------------------------------------------------*/
     netwib_err netwib_pkt_append_ipicmp6(netwib_constiphdr *piphdr,
					  netwib_consticmp6 *picmp6,
					  netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_ipicmp6(netwib_constbuf *ppkt,
					  netwib_iphdr *piphdr,
					  netwib_icmp6 *picmp6);
     netwib_err netwib_pkt_append_linkipicmp6(netwib_constlinkhdr *plinkhdr,
					      netwib_constiphdr *piphdr,
					      netwib_consticmp6 *picmp6,
					      netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkipicmp6(netwib_device_dlttype dlttype,
					      netwib_constbuf *ppkt,
					      netwib_linkhdr *plinkhdr,
					      netwib_iphdr *piphdr,
					      netwib_icmp6 *picmp6);

     /*-------------------------------------------------------------*/
     /* before calling this function, user has to set plinkhdr->type
	to ARP or RARP */
     netwib_err netwib_pkt_append_linkarp(netwib_constlinkhdr *plinkhdr,
					  netwib_constarphdr *parphdr,
					  netwib_buf *ppkt);
     netwib_err netwib_pkt_decode_linkarp(netwib_device_dlttype dlttype,
					  netwib_constbuf *ppkt,
					  netwib_linkhdr *plinkhdr,
					  netwib_arphdr *parphdr);

MODULE CONV
     /*-------------------------------------------------------------*/
     typedef enum {
       NETWIB_PKT_NEWFIELD_BLANK = 1, /* do not try to compute field */
       NETWIB_PKT_NEWFIELD_FILL,      /* compute field */
       NETWIB_PKT_NEWFIELD_FILLBLANK, /* if can't compute left blank */
       NETWIB_PKT_NEWFIELD_BEST = NETWIB_PKT_NEWFIELD_FILLBLANK
     } netwib_pkt_newfield;

     /*-------------------------------------------------------------*/
     /* Name : netwib_pkt_convert
	Description :
	  Convert a packet from one type to another
	Input parameter(s) :
	  dlttype : DLT type of input packet
	  *ppktin : buffer containing physical input packet
	  newfieldopt : type to use for optional fields
	  newfieldreq : type to use for mandatory fields
	  dlttypeout : wanted outtype
	Input/output parameter(s) :
	  *plinkhdrout : new link header
	  *ppktout : packet to put after the link header
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_pkt_convert(netwib_device_dlttype dlttypein,
				   netwib_constbuf *ppktin,
				   netwib_pkt_newfield newfieldopt,
				   netwib_pkt_newfield newfieldreq,
				   netwib_device_dlttype dlttypeout,
				   netwib_linkhdr *plinkhdrout,
				   netwib_bufext *ppktout);

MODULE IPFRAG
     /*-------------------------------------------------------------*/
     typedef netwib_err (*netwib_ip_frag_pf)(netwib_constbuf *pfrag,
					     netwib_ptr infos);

     /*-------------------------------------------------------------*/
     /* Name : netwib_ip_frag
	Description :
	  Fragment an IP packet
	Input parameter(s) :
	  *pippkt : IP packet (containing IP header)
	  fragdatasize : data size to send in each fragment in bytes.
			 It is rounded to 8 : 1->8bytes, 7->8bytes,
			 8->8, 9->16, etc.
			 The first fragment may be bigger than
			 the others because it contains more IPv4
			 options, or IPv6 extensions.
			 If fragdatasize == 0, this limit is not used.
	  fragtotalsize : maximum total size of the packet in bytes.
			  If fragtotalsize == 0, this limit is not used.
	  pfunc : memory address of the function which will
		  be called for each fragment
		  For each call, the first parameter ('infos')
		  will be set with the optional parameter below.
	Input/output parameter(s) :
	  infos : optional parameter (can be NULL) which will be
		  used as the first parameter for *pfunc.
		  This may be used to send information to *pfunc.
	Output parameter(s) :
	Normal return values :
	  NETWIB_ERR_OK : ok
     */
     netwib_err netwib_ip_frag(netwib_constbuf *pippkt,
			       netwib_uint32 fragdatasize,
			       netwib_uint32 fragtotalsize,
			       netwib_ip_frag_pf pfunc,
			       netwib_ptr infos);

     /*-------------------------------------------------------------*/
     #define NETWIB_MTU_MIN_IP4 576 /* rfc 791 */
     #define NETWIB_MTU_MIN_IP6 1280 /* rfc 2460 */

SEE ALSO
     netwib(3),  netwib_dat(3),  netwib_sys(3),  netwib_net(3),   netwib_pkt(3),
     netwib_shw(3), netwib_err(3)

				   14/02/2010			   NETWIB_PKT(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=netwib_pkt&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help