summaryrefslogtreecommitdiff
path: root/sysdep/unix/unix.h
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2014-10-24 11:11:43 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2014-10-24 11:11:43 +0200
commit88a183c6c9a2b86b52f67e87bbc8b7edd32670c6 (patch)
treeb1348b71e69f9ed0d919a4792549026c9e31b092 /sysdep/unix/unix.h
parentf8fefde318c6248ad94e7b6d60155deed9ab8eed (diff)
Integrated IP functions.
Diffstat (limited to 'sysdep/unix/unix.h')
-rw-r--r--sysdep/unix/unix.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 518713bc..3cee96b4 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -47,19 +47,9 @@ typedef struct sockaddr_bird {
#ifdef IPV6
#define BIRD_AF AF_INET6
-#define _MI6(x1,x2,x3,x4) _MI(x1, x2, x3, x4)
-#define ipa_is_link_local(x) ipa_has_link_scope(x)
#define ipa_from_sa(x) ipa_from_sa6(x)
-#define ipa_from_u32(x) _MI6(0,0,0xffff,x)
-#define ipa_to_u32(x) _I3(x)
#else
#define BIRD_AF AF_INET
-#define _I0(X) 0
-#define _I1(X) 0
-#define _I2(X) 0
-#define _I3(X) 0
-#define _MI6(x1,x2,x3,x4) IPA_NONE
-#define ipa_is_link_local(x) 0
#define ipa_from_sa(x) ipa_from_sa4(x)
#endif
@@ -75,7 +65,7 @@ static inline ip_addr ipa_from_in4(struct in_addr a)
{ return ipa_from_u32(ntohl(a.s_addr)); }
static inline ip_addr ipa_from_in6(struct in6_addr a)
-{ return _MI6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
+{ return ipa_build6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
static inline ip_addr ipa_from_sa4(sockaddr *sa)
{ return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); }
@@ -86,8 +76,14 @@ static inline ip_addr ipa_from_sa6(sockaddr *sa)
static inline struct in_addr ipa_to_in4(ip_addr a)
{ return (struct in_addr) { htonl(ipa_to_u32(a)) }; }
+#ifdef IPV6
static inline struct in6_addr ipa_to_in6(ip_addr a)
{ return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; }
+#else
+/* Temporary dummy */
+static inline struct in6_addr ipa_to_in6(ip_addr a)
+{ return (struct in6_addr) { .s6_addr32 = { 0, 0, 0, 0 } }; }
+#endif
void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port);
int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port);