]>
Commit | Line | Data |
---|---|---|
6506f45c | 1 | /* |
d8e0edec | 2 | * Copyright (c) 2011, 2013 Nicira, Inc. |
6506f45c BP |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef __CHECKER__ | |
18 | #error "Use this header only with sparse. It is not a correct implementation." | |
19 | #endif | |
20 | ||
21 | #ifndef __NETINET_IN_SPARSE | |
22 | #define __NETINET_IN_SPARSE 1 | |
23 | ||
24 | #include "openvswitch/types.h" | |
25 | #include <inttypes.h> | |
26 | #include <sys/socket.h> | |
27 | ||
28 | typedef ovs_be16 in_port_t; | |
29 | typedef ovs_be32 in_addr_t; | |
30 | ||
31 | struct in_addr { | |
32 | in_addr_t s_addr; | |
33 | }; | |
34 | ||
35 | struct sockaddr_in { | |
36 | sa_family_t sin_family; | |
37 | in_port_t sin_port; | |
38 | struct in_addr sin_addr; | |
39 | }; | |
40 | ||
41 | struct in6_addr { | |
42 | union { | |
43 | uint8_t u_s6_addr[16]; | |
44 | } u; | |
45 | }; | |
46 | ||
47 | #define s6_addr u.u_s6_addr | |
48 | ||
49 | extern const struct in6_addr in6addr_any; | |
50 | ||
51 | #define IPPROTO_IP 0 | |
52 | #define IPPROTO_HOPOPTS 0 | |
53 | #define IPPROTO_ICMP 1 | |
54 | #define IPPROTO_TCP 6 | |
55 | #define IPPROTO_UDP 17 | |
56 | #define IPPROTO_ROUTING 43 | |
57 | #define IPPROTO_FRAGMENT 44 | |
58 | #define IPPROTO_AH 51 | |
59 | #define IPPROTO_ICMPV6 58 | |
60 | #define IPPROTO_NONE 59 | |
61 | #define IPPROTO_DSTOPTS 60 | |
c6bcb685 | 62 | #define IPPROTO_SCTP 132 |
6506f45c | 63 | |
f125905c MM |
64 | /* All the IP options documented in Linux ip(7). */ |
65 | #define IP_ADD_MEMBERSHIP 0 | |
66 | #define IP_DROP_MEMBERSHIP 1 | |
67 | #define IP_HDRINCL 2 | |
68 | #define IP_MTU 3 | |
69 | #define IP_MTU_DISCOVER 4 | |
70 | #define IP_MULTICAST_IF 5 | |
71 | #define IP_MULTICAST_LOOP 6 | |
72 | #define IP_MULTICAST_TTL 7 | |
73 | #define IP_NODEFRAG 8 | |
74 | #define IP_OPTIONS 9 | |
75 | #define IP_PKTINFO 10 | |
76 | #define IP_RECVERR 11 | |
77 | #define IP_RECVOPTS 12 | |
78 | #define IP_RECVTOS 13 | |
79 | #define IP_RECVTTL 14 | |
80 | #define IP_RETOPTS 15 | |
81 | #define IP_ROUTER_ALERT 16 | |
82 | #define IP_TOS 17 | |
83 | #define IP_TTL 18 | |
84 | ||
6506f45c BP |
85 | #define INADDR_ANY 0x00000000 |
86 | #define INADDR_BROADCAST 0xffffffff | |
87 | #define INADDR_NONE 0xffffffff | |
88 | ||
89 | #define INET6_ADDRSTRLEN 46 | |
90 | ||
91 | static inline ovs_be32 htonl(uint32_t x) | |
92 | { | |
93 | return (OVS_FORCE ovs_be32) x; | |
94 | } | |
95 | ||
96 | static inline ovs_be16 htons(uint16_t x) | |
97 | { | |
98 | return (OVS_FORCE ovs_be16) x; | |
99 | } | |
100 | ||
101 | static inline uint32_t ntohl(ovs_be32 x) | |
102 | { | |
103 | return (OVS_FORCE uint32_t) x; | |
104 | } | |
105 | ||
106 | static inline uint16_t ntohs(ovs_be16 x) | |
107 | { | |
108 | return (OVS_FORCE uint16_t) x; | |
109 | } | |
110 | ||
111 | in_addr_t inet_addr(const char *); | |
112 | int inet_aton (const char *, struct in_addr *); | |
6506f45c BP |
113 | const char *inet_ntop(int, const void *, char *, socklen_t); |
114 | int inet_pton(int, const char *, void *); | |
115 | ||
116 | #endif /* <netinet/in.h> sparse */ |