udpipgen.h

来自「程序实现了Linux下dhcp客户端以及autoip客户端的功能」· C头文件 代码 · 共 53 行

H
53
字号
#ifndef UDPIPGEN_H#define UDPIPGEN_H#include <netinet/ip.h>#ifndef IPDEFTTL#define IPDEFTTL 64#endifstruct ipovly{  int ih_next,ih_prev;  u_char ih_x1;  u_char ih_pr;  u_short ih_len;  struct in_addr ih_src;  struct in_addr ih_dst;} __attribute__((packed));struct udphdr{  u_int16_t uh_sport;  u_int16_t uh_dport;  u_int16_t uh_ulen;  u_int16_t uh_sum;} __attribute__((packed));typedef struct udpiphdr{  char ip[sizeof(struct ip)];  char udp[sizeof(struct udphdr)];} __attribute__((packed)) udpiphdr;/** *Description: this functions generates the IP header of an UDP datagram *@param udpip: the header to be built *@param saddr: source ip addr *@param daddr: destination ip addr *@param sport: source port *@param dport: destination port *@param msglen: the length of the message */void udpipgen(udpiphdr *udpip,unsigned int saddr,unsigned int daddr,unsigned short sport,unsigned short dport,unsigned short msglen);/** *Description: check the ip header of an UDP datagram *return 0 if no error occurs */int udpipchk(udpiphdr *udpip);#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?