2 * Copyright (c) 2011, 2013, 2014 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #error "Use this header only with sparse. It is not a correct implementation."
21 #ifndef __NETINET_IN_SPARSE
22 #define __NETINET_IN_SPARSE 1
24 #include "openvswitch/types.h"
26 #include <sys/socket.h>
28 typedef ovs_be16 in_port_t;
29 typedef ovs_be32 in_addr_t;
36 sa_family_t sin_family;
38 struct in_addr sin_addr;
43 uint8_t u_s6_addr[16];
47 #define s6_addr u.u_s6_addr
49 extern const struct in6_addr in6addr_any;
51 /* Ditto, for IPv6. */
53 sa_family_t sin6_family;
54 in_port_t sin6_port; /* Transport layer port # */
55 uint32_t sin6_flowinfo; /* IPv6 flow information */
56 struct in6_addr sin6_addr; /* IPv6 address */
57 uint32_t sin6_scope_id; /* IPv6 scope-id */
61 #define IPPROTO_IPV6 41
62 #define IPPROTO_HOPOPTS 0
63 #define IPPROTO_ICMP 1
65 #define IPPROTO_UDP 17
66 #define IPPROTO_ROUTING 43
67 #define IPPROTO_FRAGMENT 44
69 #define IPPROTO_ICMPV6 58
70 #define IPPROTO_NONE 59
71 #define IPPROTO_DSTOPTS 60
72 #define IPPROTO_SCTP 132
74 /* All the IP options documented in Linux ip(7). */
75 #define IP_ADD_MEMBERSHIP 0
76 #define IP_DROP_MEMBERSHIP 1
79 #define IP_MTU_DISCOVER 4
80 #define IP_MULTICAST_IF 5
81 #define IP_MULTICAST_LOOP 6
82 #define IP_MULTICAST_TTL 7
87 #define IP_RECVOPTS 12
91 #define IP_ROUTER_ALERT 16
95 #define INADDR_ANY 0x00000000
96 #define INADDR_BROADCAST 0xffffffff
97 #define INADDR_LOOPBACK 0x7f000001
98 #define INADDR_NONE 0xffffffff
100 #define INET6_ADDRSTRLEN 46
102 #define IPV6_TCLASS 67
104 static inline ovs_be32 htonl(uint32_t x)
106 return (OVS_FORCE ovs_be32) x;
109 static inline ovs_be16 htons(uint16_t x)
111 return (OVS_FORCE ovs_be16) x;
114 static inline uint32_t ntohl(ovs_be32 x)
116 return (OVS_FORCE uint32_t) x;
119 static inline uint16_t ntohs(ovs_be16 x)
121 return (OVS_FORCE uint16_t) x;
124 in_addr_t inet_addr(const char *);
125 int inet_aton (const char *, struct in_addr *);
126 const char *inet_ntop(int, const void *, char *, socklen_t);
127 int inet_pton(int, const char *, void *);
129 #endif /* <netinet/in.h> sparse */