udp.h
来自「实用的程序代码」· C头文件 代码 · 共 55 行
H
55 行
/* * UDP Header File */#ifndef _UDP_H#define _UDP_H#include <net/ip.h>#define UDP_HDR_LEN 0x0008 /* 8-byte header */#define NO_UDP_CHECKSUM 0x0000 /* No udp checksum is calculated */#define IP_PROTO_UDP 17 /* protocol field in IP header */ #define UDP_STRIP_HDR 0x01 /* remove header for udp handler type */#define UDP_ADD_HDR 0x02 /* add header for udp handler type */#define UDP_PORT 69 /* tftp port no. */#define UDP_DATA 1460 /* max possible udp data for ethernet */// udp header structurestruct xilnet_udp_hdr { unsigned short src_port; unsigned short dst_port; unsigned short udp_len; unsigned short check_sum;};// udp packetstruct xilnet_udp_pkt { struct xilnet_udp_hdr udp_hdr; unsigned char data[UDP_DATA];};// udp connection management#define MAX_UDP_CONNS 5 // maximum no of open udp conns#define UDP_CONN_OPEN 0 // waiting for client connection (only src port is known)#define UDP_CONN_CLOSED 1 // connection can be used #define UDP_CONN_ESTABLISHED 2 // full conn established (both src and dst ports are known)struct xilnet_udp_conn { unsigned short src_port; unsigned short dst_port; unsigned char src_ip[IP_VERSION]; unsigned char dst_ip[IP_VERSION]; unsigned char state; int fd; // socket descriptor into xsock_sockets table} ;extern struct xilnet_udp_conn xilnet_udp_conns[MAX_UDP_CONNS];extern void xilnet_udp_init_conns();#endif /* _UDP_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?