structproto{void(*fproc)(char*,ssize_t,structtimeval*);void(*fsend)(void);structsockaddr*sasend;/* sockaddr{} for send, from getaddrinfo */structsockaddr*sarecv;/* sockaddr{} for receiving */socklen_t salen;/* length of sockaddr{}s */int icmpproto;/* IPPROTO_xxx value for ICMP */}*pr;
2.1.2 struct addrinfo
structaddrinfo{int ai_flags;/* Input flags. */int ai_family;/* Protocol family for socket. */int ai_socktype;/* Socket type. */int ai_protocol;/* Protocol for socket. */socklen_t ai_addrlen;/* Length of socket address. */structsockaddr*ai_addr;/* Socket address for socket. */char*ai_canonname;/* Canonical name for service location. */structaddrinfo*ai_next;/* Pointer to next in list. */};
2.1.3 struct ip
structip{#if__BYTE_ORDER == __LITTLE_ENDIANunsignedint ip_hl:4;/* header length */unsignedint ip_v:4;/* version */#endif#if__BYTE_ORDER == __BIG_ENDIANunsignedint ip_v:4;/* version */unsignedint ip_hl:4;/* header length */#endifuint8_t ip_tos;/* type of service */unsignedshort ip_len;/* total length */unsignedshort ip_id;/* identification */unsignedshort ip_off;/* fragment offset field */#defineIP_RF0x8000/* reserved fragment flag */#defineIP_DF0x4000/* dont fragment flag */#defineIP_MF0x2000/* more fragments flag */#defineIP_OFFMASK0x1fff/* mask for fragmenting bits */uint8_t ip_ttl;/* time to live */uint8_t ip_p;/* protocol */unsignedshort ip_sum;/* checksum */structin_addr ip_src, ip_dst;/* source and dest address */};
2.1.4 struct icmp
structicmp{uint8_t icmp_type;/* type of message, see below */uint8_t icmp_code;/* type sub code */uint16_t icmp_cksum;/* ones complement checksum of struct */union{unsignedchar ih_pptr;/* ICMP_PARAMPROB */structin_addr ih_gwaddr;/* gateway address */structih_idseq/* echo datagram */{uint16_t icd_id;uint16_t icd_seq;} ih_idseq;uint32_t ih_void;/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */structih_pmtu{uint16_t ipm_void;uint16_t ipm_nextmtu;} ih_pmtu;structih_rtradv{uint8_t irt_num_addrs;uint8_t irt_wpa;uint16_t irt_lifetime;} ih_rtradv;} icmp_hun;#defineicmp_pptricmp_hun.ih_pptr#defineicmp_gwaddricmp_hun.ih_gwaddr#defineicmp_idicmp_hun.ih_idseq.icd_id#defineicmp_seqicmp_hun.ih_idseq.icd_seq#defineicmp_voidicmp_hun.ih_void#defineicmp_pmvoidicmp_hun.ih_pmtu.ipm_void#defineicmp_nextmtuicmp_hun.ih_pmtu.ipm_nextmtu#defineicmp_num_addrsicmp_hun.ih_rtradv.irt_num_addrs#defineicmp_wpaicmp_hun.ih_rtradv.irt_wpa#defineicmp_lifetimeicmp_hun.ih_rtradv.irt_lifetimeunion{struct{uint32_t its_otime;uint32_t its_rtime;uint32_t its_ttime;} id_ts;struct{structip idi_ip;/* options and then 64 bits of data */} id_ip;structicmp_ra_addr id_radv;uint32_t id_mask;uint8_t id_data[1];} icmp_dun;#defineicmp_otimeicmp_dun.id_ts.its_otime#defineicmp_rtimeicmp_dun.id_ts.its_rtime#defineicmp_ttimeicmp_dun.id_ts.its_ttime#defineicmp_ipicmp_dun.id_ip.idi_ip#defineicmp_radvicmp_dun.id_radv#defineicmp_maskicmp_dun.id_mask#defineicmp_dataicmp_dun.id_data};
structaddrinfo{int ai_flags;/* Input flags. */int ai_family;/* Protocol family for socket. */int ai_socktype;/* Socket type. */int ai_protocol;/* Protocol for socket. */
socklen_t ai_addrlen;/* Length of socket address. */structsockaddr*ai_addr;/* Socket address for socket. */char*ai_canonname;/* Canonical name for service location. */structaddrinfo*ai_next;/* Pointer to next in list. */};
2.1.7 struct sockaddr
structsockaddr{unsignedshortint sa_family;/* Common data: address family and length. */char sa_data[14];/* Address data. */};