/* The following set of includes and definitions were intended to
   provide the default length (bytes) of the user portion of a
   UDP datagram.  Here's the computation ...

     Ethernet Max Transmission Unit (ETHERMTU)           1500 bytes
   - size of an Internet header                          - 20
   - size of a UDP header                                -  8
   ----------------------------------------------------------
     Max UDP data size                                   1472
*/

#ifdef BSD
#include <sys/sockio.h>        /* ... for in_addr structure */
#include <net/if.h>            /* ... for ifnet structure */
#include <netinet/in.h>        /* ... for in_addr structure */
#include <netinet/if_ether.h>  /* ... for ETHERMTU definition & ether_header structure */
#include <netinet/in_systm.h>  /* ... for n_long typedef */
#include <netinet/ip.h>        /* ... for ip structure */
#include <netinet/udp.h>       /* ... for udphdr structure */
#define DEF_FRAGMENTATION_BYTES (ETHERMTU - sizeof(struct ip) - sizeof(struct udphdr))
#else
#define DEF_FRAGMENTATION_BYTES (1472)
#endif

#define MAX_FRAGMENTS           ((1<<16)-1)
#define MAX_FRAG_BYTES          ((1<<16)-1)
#define MAX_MSG_BYTES           ((1<<16)-1)

#define NULL_OPTION             0x0000  /* disables all options bits */

struct frag_hdr 
{
  unsigned long  frag_seqn   ; /* incremental fragment sequence number       */
  unsigned short msg_bytes   ; /* total message length (bytes), w/o hdr      */
  unsigned short frag_count  ; /* total number of fragments in message       */
  unsigned short frag_nmbr   ; /* current fragment index (1,2,..,frag_count) */
  unsigned short frag_offset ; /* offset from message start (bytes)          */
  unsigned short data_bytes  ; /* length of packet minus this header         */
  unsigned short options     ; /* optional flag bits                         */
};

typedef struct frag_hdr FRAG_HDR;

#define SIZEOF_FRAG_HDR (sizeof(FRAG_HDR)) /* defined here for run-time speed */

