[9] | 1 | /*
|
---|
| 2 | netinet/in.h
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifndef _NETINET__IN_H
|
---|
| 6 | #define _NETINET__IN_H
|
---|
| 7 |
|
---|
| 8 | /* Can we include <stdint.h> here or do we need an additional header that is
|
---|
| 9 | * safe to include?
|
---|
| 10 | */
|
---|
| 11 | #include <stdint.h>
|
---|
| 12 |
|
---|
| 13 | /* Open Group Base Specifications Issue 6 (not complete) */
|
---|
| 14 | #define INADDR_ANY (uint32_t)0x00000000
|
---|
| 15 | #define INADDR_BROADCAST (uint32_t)0xFFFFFFFF
|
---|
| 16 |
|
---|
| 17 | #define IN_LOOPBACKNET 127
|
---|
| 18 |
|
---|
| 19 | #define IPPORT_RESERVED 1024
|
---|
| 20 |
|
---|
| 21 | typedef uint16_t in_port_t;
|
---|
| 22 |
|
---|
| 23 | #ifndef _IN_ADDR_T
|
---|
| 24 | #define _IN_ADDR_T
|
---|
| 25 | typedef uint32_t in_addr_t;
|
---|
| 26 | #endif /* _IN_ADDR_T */
|
---|
| 27 |
|
---|
| 28 | #ifndef _SA_FAMILY_T
|
---|
| 29 | #define _SA_FAMILY_T
|
---|
| 30 | /* Should match corresponding typedef in <sys/socket.h> */
|
---|
| 31 | typedef uint8_t sa_family_t;
|
---|
| 32 | #endif /* _SA_FAMILY_T */
|
---|
| 33 |
|
---|
| 34 | /* Protocols */
|
---|
| 35 | #define IPPROTO_IP 0 /* Dummy protocol */
|
---|
| 36 | #define IPPROTO_ICMP 1 /* ICMP */
|
---|
| 37 | #define IPPROTO_TCP 6 /* TCP */
|
---|
| 38 | #define IPPROTO_EGP 8 /* exterior gateway protocol */
|
---|
| 39 | #define IPPROTO_UDP 17 /* UDP */
|
---|
| 40 |
|
---|
| 41 | /* setsockopt options at IP level */
|
---|
| 42 | #define IP_ADD_MEMBERSHIP 12
|
---|
| 43 | #define IP_DROP_MEMBERSHIP 13
|
---|
| 44 |
|
---|
| 45 | #ifndef _STRUCT_IN_ADDR
|
---|
| 46 | #define _STRUCT_IN_ADDR
|
---|
| 47 | struct in_addr
|
---|
| 48 | {
|
---|
| 49 | in_addr_t s_addr;
|
---|
| 50 | };
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | struct sockaddr_in
|
---|
| 54 | {
|
---|
| 55 | sa_family_t sin_family;
|
---|
| 56 | in_port_t sin_port;
|
---|
| 57 | struct in_addr sin_addr;
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | struct ip_mreq
|
---|
| 61 | {
|
---|
| 62 | struct in_addr imr_multiaddr;
|
---|
| 63 | struct in_addr imr_interface;
|
---|
| 64 | };
|
---|
| 65 |
|
---|
| 66 | /* Definitions that are not part of the Open Group Base Specifications */
|
---|
| 67 | #define IN_CLASSA(i) (((uint32_t)(i) & 0x80000000) == 0)
|
---|
| 68 | #define IN_CLASSA_NET 0xff000000
|
---|
| 69 | #define IN_CLASSA_NSHIFT 24
|
---|
| 70 |
|
---|
| 71 | #define IN_CLASSB(i) (((uint32_t)(i) & 0xc0000000) == 0x80000000)
|
---|
| 72 | #define IN_CLASSB_NET 0xffff0000
|
---|
| 73 | #define IN_CLASSB_NSHIFT 16
|
---|
| 74 |
|
---|
| 75 | #define IN_CLASSC(i) (((uint32_t)(i) & 0xe0000000) == 0xc0000000)
|
---|
| 76 | #define IN_CLASSC_NET 0xffffff00
|
---|
| 77 | #define IN_CLASSC_NSHIFT 8
|
---|
| 78 |
|
---|
| 79 | #define IN_CLASSD(i) (((uint32_t)(i) & 0xf0000000) == 0xe0000000)
|
---|
| 80 | #define IN_CLASSD_NET 0xf0000000
|
---|
| 81 | #define IN_CLASSD_NSHIFT 28
|
---|
| 82 |
|
---|
| 83 | #endif /* _NETINET__IN_H */
|
---|