/* 
 * FILENAME: stkdata.h
 *
 * Copyright 2011 By InterNiche Technologies Inc. All rights reserved.
 *
 * Header file for InterNiche TCP/IP stack's configuration parameters 
 * and statistics
 *
 * Module: TCP/IP stack
 *
 * ROUTINES:
 *
 * PORTABLE: yes
 */

/* module identifiers */
#define ARP_MODULE         0  /* ARP */
#define DHCPC_MODULE       1  /* DHCP client */
#define DNSC_MODULE        2  /* DNS client */
#define ICMP_MODULE        3  /* ICMP */
#define IF_MODULE          4  /* Interface */
#define IPV4_MODULE        5  /* IPv4 */
#define TCP_MODULE         6  /* TCP */
#define UDP_MODULE         7  /* UDP */
#define QUEUES_MODULE      8  /* system queues */
#define SOCKETS_MODULE     9  /* TCP/UDP sockets */
#define EMAC_MODULE       10  /* Ethernet device driver */

/* parameter identifiers (see below for a description of these parameters) */
/* DHCP client */
#define IN_DHCPC_MAX_TRIES 0

/* DNS client */
#define IN_DNSC_MAX_TX   0
#define IN_DNSC_RETX_INT 1
#define IN_DNSC_SRV_ADDR 2

/* ICMP */
#define IN_ICMP_PING_RESP     0
#define IN_ICMP_PING_RESP_TMO 1

/* IPv4 */
#define IN_IPV4_REASM_TMO 0 
#define IN_IPV4_TOS       1
#define IN_IPV4_TTL       2

/* TCP */
#define IN_TCP_MSL                0
#define IN_TCP_TXBUF_HIWAT        1
#define IN_TCP_RXBUF_HIWAT        2
#define IN_TCP_CONN_ESTAB_TMO     3
#define IN_TCP_KAL_IDLE_TMO       4
#define IN_TCP_KAL_NUM_PROBES     5
#define IN_TCP_KAL_PROBE_INTERVAL 6
#define IN_TCP_NOPORT_RST         7

/* UDP */
#define IN_UDP_NOPORT_ICMPDU 0
#define IN_UDP_RXBUF_HIWAT   1

/* Interface */
#define IN_IF_ADDR4        0
#define IN_IF_MASK4        1
#define IN_IF_GW4          2
#define IN_IF_MTU          3
#define IN_IF_ADMIN_STATUS 4
#define IN_IF_OPER_STATUS  5
#define IN_IF_AGM          6 /* address, subnet mask, and gateway */
#define IN_IF_ALL          7 /* all interface parameters */

/* table identifiers */
/* ARP cache */
#define ARP_CACHE_TBL  0

/* DNS client cache */
#define DNSC_CACHE_TBL 0

/* module-specific table clearing functions */
extern int arp_clrtab(int id);
extern int dnc_clrtab(int id);

/* user-configurable parameters */
/* DHCP client */
extern uint8_t dhcpc_max_tries;
extern uint8_t dhcp_vendclass[DHCP_VENDCLASS_MAXLEN];
extern uint8_t dhcp_vendclass_len;

/* DNS client */
extern struct dnc_cfg dnccfg;

/* IPv4 */
extern uint16_t ipv4_reasm_tmo;
extern uint8_t ipv4_tos;
extern uint8_t ipv4_ttl;

/* ICMP */
extern bool_t icmp_ping_resp;
extern struct ping_cfg pingcfg;

/* UDP */
extern bool_t udp_noport_icmpdu;
extern uint32_t udp_rxbuf_hiwat;

/* TCP */
extern uint16_t tcp_conn_estab_tmo;
extern uint8_t tcp_kal_num_probes;
extern int tcp_keepidle;
extern int tcp_keepintvl;
extern int TCPTV_MSL;
extern uint32_t tcp_sendspace;
extern uint32_t tcp_recvspace;
extern bool_t tcp_noport_rst;

/* generic TCP/IP stack parameter get/set API
 *
 * This provides a simple mechanism to get or set scalar variables (e.g,
 * IPv4 reassembly timeout, TCP MSL, etc).  For scalar variables, the 
 * user can pass in a pointer to a variable that contains the desired 
 * value.  It can be used to set non-scalars by having 'valp' point to a 
 * structure that contains all of the information required to set the 
 * variable (e.g., interface identifier and MTU when setting the MTU).
 */

extern int in_getparm(int modid, int parmid, void *valp);
extern int in_setparm(int modid, int parmid, void *valp);

/* module-specific get and set parameter functions */
extern int dhcpc_getparm(int parmid, void *valp);
extern int dnc_getparm(int parmid, void *valp);
extern int icmp_getparm(int parmid, void *valp);
extern int if_getparm(int parmid, void *valp);
extern int ipv4_getparm(int parmid, void *valp);
extern int tcp_getparm(int parmid, void *valp);
extern int udp_getparm(int parmid, void *valp);

extern int dhcpc_setparm(int parmid, void *valp);
extern int dnc_setparm(int parmid, void *valp);
extern int icmp_setparm(int parmid, void *valp);
extern int if_setparm(int parmid, void *valp);
extern int ipv4_setparm(int parmid, void *valp);
extern int tcp_setparm(int parmid, void *valp);
extern int udp_setparm(int parmid, void *valp);

struct ipv4_parms
{
   uint16_t reasm_tmo; /* IPv4 reassembly timeout (seconds) */
   uint8_t tos;        /* default value of TOS in outgoing IPv4 header */
   uint8_t ttl;        /* default value of TTL in outgoing IPv4 header */
};

struct icmp_parms
{
   bool_t enable_resp;    /* enable or disable responses to ICMP Echo (ping) */
   uint16_t max_sessions; /* maximum number of active ping sessions */
   uint8_t timeout;       /* timeout for ICMP Echo (ping) response (seconds) */
};

struct tcp_kal_parms
{
   uint16_t idle_time;     /* idle time (before probing starts) (seconds) */
   uint8_t num_probes;     /* number of probes sent */
   uint8_t probe_interval; /* interval between successive probes (seconds) */
};

struct tcp_parms
{
   uint8_t conn_estab_tmo;   /* timeout for connection establishment (seconds) */
   struct tcp_kal_parms kal; /* keepalive algorithm parameters */
   uint8_t msl;              /* Maximum Segment Lifetime (MSL) (seconds) */
   bool_t enable_noport_rst; /* enable or disable sending RST upon receipt */
                             /* of a SYN to a non-existent TCP port */
   uint32_t recv_space;      /* Length of receive buffer (bytes) - maximum */
                             /* amount of incoming data that can be queued */
                             /* on the connection */
   uint32_t send_space;      /* Length of send buffer (bytes) - maximum */
                             /* amount of outgoing data that can be queued */
                             /* on the connection */
};

struct udp_parms
{
   bool_t enable_dest_unreach; /* transmit ICMP Destination Unreachable  */
                         /* (Port Unreachable) msg when a packet is received */
                         /* for a non-existent UDP port */
   uint32_t rcvbuf_size; /* Length of receive buffer (bytes) - maximum */
                         /* amount of incoming data that can be queued */
                         /* on the connection */
};

struct dhcpc_parms
{
   uint8_t max_tries;   /* number of transmissions of DHCP packet during */
                        /* address acquisition */
   uint8_t vendclass[DHCP_VENDCLASS_MAXLEN]; /* vendor class identifier */
   uint8_t vendclass_len; /* length of vendor class identifier (bytes) */
};

struct dnsc_parms
{
   uint8_t max_tries;     /* total number of transmissions of a */
                          /* DNS request, including the first one */
   uint8_t retx_interval; /* retransmission interval (seconds) */
   uint8_t max_entries;   /* number of entries in the DNS client table */
   char *dns_servers[MAXDNSSERVERS]; /* IPv4 address of DNS servers */
};

struct dnsc_srvcfg
{
   int index;             /* DNS server table slot identifier */
   ip_addr addr;          /* DNS server address */
};

struct if_mtucfg
{
   char *name;            /* name of interface */
   int mtu;               /* MTU */
};

struct if_addrcfg
{
   char *name;            /* name of interface */
   ip_addr addr4;         /* IPv4 address (interface address, subnet mask, */
                          /* or gateway address */
};

struct if_agmcfg
{
   char *name;            /* name of interface */
   ip_addr addr4;         /* IPv4 address of interface */
   ip_addr gw4;           /* gateway */
   ip_addr mask4;         /* mask */
};

struct if_stscfg
{
   char *name;            /* name of interface */
   int32_t status;        /* administrative or operational status of interface */
};

struct if_cfg
{
   char *name;            /* name of interface */
   ip_addr addr4;         /* IPv4 address of interface */
   ip_addr gw4;           /* gateway */
   ip_addr mask4;         /* mask */
   int mtu;               /* MTU */
   int32_t status_adm;    /* administrative status of interface */
   int32_t status_oper;   /* operational status of interface */
};

/* user-level configuration data structures for various protocols */
extern struct dhcpc_parms dhcp;
extern struct dnsc_parms dns;
extern struct icmp_parms ping;
extern struct ipv4_parms ipv4;
extern struct tcp_parms tcp;
extern struct udp_parms udp;

/* statistics APIs
 *
 * in_getstats(): dump statistics for specified module
 * in_clrstats(): clear statistics for specified module
 */
extern int in_getstats(int module_id, void *statp);
extern int in_clrstats(int module_id, void *parm);

/* module-specific clear and retrieve statistics functions */
extern void arp_clrstats(void *parm);
extern void dhcpc_clrstats(void *parm);
extern void dnc_clrstats(void *parm);
extern void icmp_clrstats(void *parm);
extern void if_clrstats(void *parm);
extern void ipv4_clrstats(void *parm);
extern void tcp_clrstats(void *parm);
extern void udp_clrstats(void *parm);

extern void arp_getstats(void *statp);
extern void dhcpc_getstats(void *statp);
extern void dnc_getstats(void *statp);
extern void icmp_getstats(void *statp);
extern void if_getstats(void *statp);
extern void ipv4_getstats(void *statp);
extern void queue_getstats(void *statp);
extern void tcp_getstats(void *statp);
extern void tcpsock_getstats(void *statp);
extern void udp_getstats(void *statp);
extern void udpsock_getstats(void *statp);


/* cleanup API
 *
 * clear contents of ARP cache or DNS client cache
 */
int in_clrtab(int module_id, int table_id);

/* statistics data structures */

/* ARP statistics */
struct arp_stats
{
   uint32_t arpReqsIn;           /* requests received */
   uint32_t arpReqsOut;          /* requests sent */
   uint32_t arpRepsIn;           /* replies received */
   uint32_t arpRepsOut;          /* replies sent */
   uint32_t arpGratReqsConflict; /* # of address conflicts detected upon */
                                 /* receipt of a gratuitous ARP request */
   uint32_t arpGratRepsConflict; /* # of address conflicts detected upon */
                                 /* receipt of a gratuitous ARP reply */
};

/* (implementation-specific) DHCP statistics */
struct dhcpc_stats
{
   uint32_t dsc_errors;    /* protocol/implementation runtime errors */
   uint32_t dsc_discovers; /* discovers sent */
   uint32_t dsc_offers;    /* offers recieved */
   uint32_t dsc_requests;  /* requests sent */
   uint32_t dsc_acks;      /* acks received */
   uint32_t dsc_bpreplys;  /* plain bootp replys received */
   uint32_t dsc_declines;  /* declines sent */
   uint32_t dsc_releases;  /* releases sent */
   uint32_t dsc_naks;      /* naks received */
   uint32_t dsc_renew;     /* unicast requests sent to renew lease */
   uint32_t dsc_rebind;    /* broadcast requests sent to renew lease */
   uint32_t dsc_rlyerrs;   /* runtime errors due to DHCP Relay agents */
};

/* DNS client statistics */
struct dnc_stats
{
   uint32_t alloc_fail;  /* number of instances when a memory allocation */
                         /* request failed */
   uint32_t badrxlen;    /* number of instances when t_recvfrom() returned */
                         /* zero */
   uint32_t badresp;     /* number of times server sent bad response (e.g., */
                         /* no A records) */
   uint32_t expired;     /* number of entries containing a (good or bad) */
                         /* response from the server that timed out */
   uint32_t idmatch;     /* number of instances when id in reply matched */
                         /* that of the last request transmitted */
   uint32_t lost_entry;  /* number of times task woke up, and couldn't */
                         /* locate its DNS client table entry (the entry */
                         /* was timed out by the timer task (because it was */
                         /* never resolved), or because it was resolved and */
                         /* was reused for another request */
   uint32_t lostaddrs;   /* number of instances an IPv4 address (from an A */
                         /* record) could not be copied into the DNS client */
                         /* table entry due to lack of space */
   uint32_t lostaliases; /* number of instances an alias (from an CNAME */
                         /* record) could not be copied into the DNS client */
                         /* table entry due to lack of space */
   uint32_t no_srv;      /* number of instances when a DNS request could */
                         /* not be sent out because no server was configured */
   uint32_t no_slot;     /* number of instances when a request for */
                         /* resolution couldn't be met because the DNS */
                         /* client table was full (with pending requests) */
   uint32_t nomatch;     /* number of instances when a rcvd pkt didn't have */
                         /* a matching entry in DNS client table */
   uint32_t res_succ;    /* number of client requests that were successfully */
                         /* resolved */
   uint32_t res_err;     /* number of client requests that were responded */
                         /* to with an error (from the server) */
   uint32_t timedout;    /* number of entries that timed out before being */
                         /* resolved */
};

/* ICMP statistics (from ICMP group in RFC 1213) */
struct icmp_stats
{
   uint32_t icmpInMsgs;
   uint32_t icmpInErrors;
   uint32_t icmpInDestUnreachs;
   uint32_t icmpInTimeExcds;
   uint32_t icmpInParmProbs;
   uint32_t icmpInSrcQuenchs;
   uint32_t icmpInRedirects;
   uint32_t icmpInEchos;
   uint32_t icmpInEchoReps;
   uint32_t icmpInTimestamps;
   uint32_t icmpInTimestampReps;
   uint32_t icmpInAddrMasks;
   uint32_t icmpInAddrMaskReps;
   uint32_t icmpOutMsgs;
   uint32_t icmpOutErrors;
   uint32_t icmpOutDestUnreachs;
   uint32_t icmpOutTimeExcds;
   uint32_t icmpOutParmProbs;
   uint32_t icmpOutSrcQuenchs;
   uint32_t icmpOutRedirects;
   uint32_t icmpOutEchos;
   uint32_t icmpOutEchoReps;
   uint32_t icmpOutTimestamps;
   uint32_t icmpOutTimestampReps;
   uint32_t icmpOutAddrMasks;
   uint32_t icmpOutAddrMaskReps;
};

/* interface statistics from Interfaces group (RFC 1213) */
struct if_stats
{
   char *name;             /* name of interface (e.g., "nd0") */
   uint32_t ifInOctets;
   uint32_t ifInUcastPkts;
   uint32_t ifInNUcastPkts;
   uint32_t ifInDiscards;
   uint32_t ifInErrors;
   uint32_t ifInUnknownProtos;
   uint32_t ifOutOctets;
   uint32_t ifOutUcastPkts;
   uint32_t ifOutNUcastPkts;
   uint32_t ifOutDiscards;
   uint32_t ifOutErrors;
   uint32_t ifOutQLen;
};

/* number of variables in a part of the Interfaces group (RFC 1213) */
#define IF_GRP_VARSET_LEN 12 /* ifInOctets, ..., ifOutQLen */

/* IP statistics (from IP group in RFC 1213) */
struct ip_stats
{
   uint32_t ipForwarding;
   uint32_t ipDefaultTTL;
   uint32_t ipInReceives;
   uint32_t ipInHdrErrors;
   uint32_t ipInAddrErrors;
   uint32_t ipForwDatagrams;
   uint32_t ipUnknownProtos;
   uint32_t ipInDiscards;
   uint32_t ipInDelivers;
   uint32_t ipOutRequests;
   uint32_t ipOutDiscards;
   uint32_t ipOutNoRoutes;
   uint32_t ipReasmTimeout;
   uint32_t ipReasmReqds;
   uint32_t ipReasmOKs;
   uint32_t ipReasmFails;
   uint32_t ipFragOKs;
   uint32_t ipFragFails;
   uint32_t ipFragCreates;
   uint32_t ipRoutingDiscards;
};

/* number of variables in two parts of the IPv4 group (RFC 1213) */
#define IP_GRP_VARSET1_LEN 10 /* ipInReceives, ..., ipOutNoRoutes */
#define IP_GRP_VARSET2_LEN 7  /* ipReasmReqds, ..., ipRoutingDiscards */

/* queue name can be up to 7 characters long */
#define MAX_QNAME_LEN 8
/* mbufq, mfreeq, and rcvdq */
#define NUM_NONPKT_QUEUES 3

/* queue statistics data structure */
struct qstats
{
   char name[MAX_QNAME_LEN]; /* name of queue */
   uint32_t size;            /* size of buffers in queue (non-zero only */
                             /* for packet buffer queues; 0 for mbufq, */
                             /* mfreeq, and rcvdq) */   
   uint32_t len;             /* current length of queue */
   uint32_t max;             /* maximum length (high water mark) of queue */
   uint32_t min;             /* minimum length (low water mark) of queue */
};

/* queue statistics table data structure */
struct qstats_tbl
{
   int num;             /* number of queue statistics data structures for */
                        /* which storage has been allocated */
   struct qstats qs[1];
};

/* TCP statistics (from TCP group in RFC 1213) and implementation-specific 
 * TCP statistics 
 */
struct tcp_stats
{
   uint32_t tcps_connattempt;    /* connections initiated */
   uint32_t tcps_accepts;        /* connections accepted */
   uint32_t tcps_connects;       /* connections established */
   uint32_t tcps_drops;          /* connections dropped */
   uint32_t tcps_conndrops;      /* embryonic connections dropped */
   uint32_t tcps_closed;         /* conn. closed (includes drops) */
   uint32_t tcps_segstimed;      /* segs where we tried to get rtt */
   uint32_t tcps_rttupdated;     /* times we succeeded */
   uint32_t tcps_delack;         /* delayed acks sent */
   uint32_t tcps_timeoutdrop;    /* conn. dropped in rxmt timeout */
   uint32_t tcps_rexmttimeo;     /* retransmit timeouts */
   uint32_t tcps_persisttimeo;   /* persist timeouts */
   uint32_t tcps_keeptimeo;      /* keepalive timeouts */
   uint32_t tcps_keepprobe;      /* keepalive probes sent */
   uint32_t tcps_keepdrops;      /* connections dropped in keepalive */
   uint32_t tcps_persistdrops;   /* connections dropped in persist */
   uint32_t tcps_lingerdrops;    /* connections dropped in linger time */

   uint32_t tcps_sndtotal;       /* total packets sent */
   uint32_t tcps_sndpack;        /* data packets sent */
   uint32_t tcps_sndbyte;        /* data bytes sent */
   uint32_t tcps_sndrexmitpack;  /* data packets retransmitted */
   uint32_t tcps_sndrexmitbyte;  /* data bytes retransmitted */
   uint32_t tcps_sndacks;        /* ack-only packets sent */
   uint32_t tcps_sndprobe;       /* window probes sent */
   uint32_t tcps_sndurg;         /* packets sent with URG only */
   uint32_t tcps_sndwinup;       /* window update-only packets sent */
   uint32_t tcps_sndctrl;        /* control (SYN|FIN|RST) packets sent */

   uint32_t tcps_rcvtotal;       /* total packets received */
   uint32_t tcps_rcvpack;        /* packets received in sequence */
   uint32_t tcps_rcvbyte;        /* bytes received in sequence */
   uint32_t tcps_rcvbadsum;      /* packets received with ccksum errs */
   uint32_t tcps_rcvbadoff;      /* packets received with bad offset */
   uint32_t tcps_rcvshort;       /* packets received too short */
   uint32_t tcps_rcvduppack;     /* duplicate-only packets received */
   uint32_t tcps_rcvdupbyte;     /* duplicate-only bytes received */
   uint32_t tcps_rcvpartduppack; /* packets with some duplicate data */
   uint32_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
   uint32_t tcps_rcvoopack;      /* out-of-order packets received */
   uint32_t tcps_rcvoobyte;      /* out-of-order bytes received */
   uint32_t tcps_rcvpackafterwin;   /* packets with data after window */
   uint32_t tcps_rcvbyteafterwin;   /* bytes rcvd after window */
   uint32_t tcps_rcvafterclose;  /* packets rcvd after "close" */
   uint32_t tcps_rcvwinprobe;    /* rcvd window probe packets */
   uint32_t tcps_rcvdupack;      /* rcvd duplicate acks */
   uint32_t tcps_rcvacktoomuch;  /* rcvd acks for unsent data */
   uint32_t tcps_rcvackpack;     /* rcvd ack packets */
   uint32_t tcps_rcvackbyte;     /* bytes acked by rcvd acks */
   uint32_t tcps_rcvwinupd;      /* rcvd window update packets */
   uint32_t tcps_pullups;        /* # of successful TCP/IPv4 header pullups */
   uint32_t tcps_pullupfail;     /* # of failed TCP/IPv4 header pullups */
   uint32_t tcps_pullup_newbuf;  /* # of successful pullups that required */
                                 /* allocation of a new buffer */
   uint32_t tcps_pullup_curbuf;  /* # of successful pullups that didn't */
                                 /* require allocation of a new buffer */

   uint32_t tcps_mcopies;        /* m_copy() actual copies */
   uint32_t tcps_mclones;        /* m_copy() clones */
   uint32_t tcps_mcopiedbytes;   /* m_copy() # bytes copied */
   uint32_t tcps_mclonedbytes;   /* m_copy() # bytes cloned */

   uint32_t tcps_oprepends;      /* ip_output() prepends of header to data */
   uint32_t tcps_oappends;       /* ip_output() appends of data to header */
   uint32_t tcps_ocopies;        /* ip_output() copies */
   uint32_t tcps_predack;        /* VJ predicted-header acks */
   uint32_t tcps_preddat;        /* VJ predicted-header data packets */
   uint32_t tcps_zioacks;        /* acks recvd during zio sends */

   uint32_t tcpActiveOpens;      /* RFC 1213 */
   uint32_t tcpPassiveOpens;
   uint32_t tcpAttemptFails;
   uint32_t tcpEstabResets;
   uint32_t tcpCurrEstab;
   uint32_t tcpInSegs;
   uint32_t tcpOutSegs;
   uint32_t tcpRetransSegs;
   uint32_t tcpInErrs;
   uint32_t tcpOutRsts;
};

/* number of variables in two parts of the TCP group (RFC 1213) */
#define TCP_GRP_VARSET1_LEN 8 /* tcpActiveOpens, ..., tcpRetransSegs */
#define TCP_GRP_VARSET2_LEN 2 /* tcpInErrs and tcpOutRsts */

/* common portion of TCP and UDP socket table data structures */
struct sock_tbl_cmn
{
   uint32_t num;   /* number of TCP or UDP socket data structures for */
                   /* which storage has been allocated */
   uint8_t domain; /* address family (AF_INET) */
   uint8_t type;   /* type of socket (SOCK_DGRAM or SOCK_STREAM) */
};

/* TCP socket data structure */
struct tcpsock
{
   SOCKTYPE socket;   /* socket identifier */
   int error;         /* socket error */
   uint32_t options;  /* configured socket options (bitmask) */
   uint32_t rxqueued; /* # of bytes queued in receive buffer */
   uint32_t txqueued; /* # of bytes queued in trasnmit buffer */
   ip_addr faddr;     /* remote IPv4 address */
   ip_addr laddr;     /* local IPv4 address */
   uint16_t fport;    /* remote port */
   uint16_t lport;    /* local port */
   uint8_t state;     /* TCP state of this connection (e.g., ESTABLISHED) */ 
   uint32_t snd_una;  /* send unacknowledged (sequence number) */
   uint32_t snd_nxt;  /* send next (sequence number) */
};

/* TCP socket table data structure */
struct tcpsock_tbl
{
   struct sock_tbl_cmn cmn;
   struct tcpsock ts[1];
};

/* UDP statistics (from UDP group in RFC 1213) */
struct udp_stats
{
   uint32_t udpInDatagrams;
   uint32_t udpNoPorts;
   uint32_t udpInErrors;
   uint32_t udpOutDatagrams;
};

/* UDP socket data structure */
struct udpsock
{
   SOCKTYPE socket;   /* socket identifier */
   int error;         /* socket error */
   uint32_t options;  /* configured socket options (bitmask) */
   uint32_t rxqueued; /* # of bytes queued in receive buffer */
   uint32_t txqueued; /* # of bytes queued in trasnmit buffer */
   ip_addr faddr;     /* remote IPv4 address */
   ip_addr laddr;     /* local IPv4 address */
   uint16_t fport;    /* remote port */
   uint16_t lport;    /* local port */
};

/* UDP socket table data structure */
struct udpsock_tbl
{
   struct sock_tbl_cmn cmn;
   struct udpsock us[1];
};

/*************************************************************************/
/*   Device driver statistics data structure                             */
/*************************************************************************/

/* Ethernet driver statistics data structure */
struct enet_stats {
   int      unit;             /* ethernet device number */
   uint32_t rx_ints;          /* RX interrupts */
   uint32_t tx_ints;          /* TX interrupts */
   uint32_t total_ints;       /* total number of interrupts */
   uint32_t refills;          /* local pool refill count */
   uint32_t empty;            /* local pool empty count */
   uint32_t rx_packets;       /* number of good packets received */
   uint32_t rx_errors;        /* number of bad packets received */
   uint32_t rx_overrun;       /* fatal RX overruns */
   uint32_t tx_packets;       /* number of packets sent */
   uint32_t tx_errors;        /* all TX errors */
   uint32_t tx_coll1;         /* packet collision count */
   uint32_t tx_collx;         /* excessive packet collision count */
   uint32_t tx_deff1;         /* deferred packet count */
   uint32_t tx_deffx;         /* excessive deferred packet count */
   uint32_t tx_underrun;      /* TX FIFO underrun on transmit */
   uint16_t rx_segsize;       /* RX segment size */
   uint16_t rx_thresh;        /* target amount of RX space (bytes) */
   uint16_t rx_space;         /* current amount of RX space (bytes) */
};

/* copy user-specified configuration parameters to TCP/IP stack */
extern void in_cfgstack(void);

/* interface uses DHCP Client to obtain IP address */
#define  NETF_DHCPC  0x0100
/* interface uses auto-configuration to obtain IP address in the 169.254/16 range */
#define  NETF_AUTOIP 0x0200

/* 
 * configure IPv4 address, subnet mask, gateway address, and interface flags
 * for specified interface.
 */
extern int in_v4addrcfg(char *name, char *ip_str, char *subnet_str, 
                        char *gateway_str, uint32_t flags);

