summaryrefslogtreecommitdiff
path: root/lib/socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/socket.h')
-rw-r--r--lib/socket.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/socket.h b/lib/socket.h
index 6babfa7b..d12ea3c5 100644
--- a/lib/socket.h
+++ b/lib/socket.h
@@ -10,7 +10,6 @@
#define _BIRD_SOCKET_H_
#include <errno.h>
-// #include <sys/socket.h>
#include "lib/resource.h"
@@ -45,7 +44,7 @@ typedef struct birdsock {
uint lifindex; /* local interface that received the datagram */
/* laddr and lifindex are valid only if SKF_LADDR_RX flag is set to request it */
- int af; /* Address family (AF_INET, AF_INET6 or 0 for non-IP) of fd */
+ int fam; /* Address family (SK_FAM_* or 0 for non-IP) of fd */
int fd; /* System-dependent data */
int index; /* Index in poll buffer */
int rcv_ttl; /* TTL of last received datagram */
@@ -68,19 +67,12 @@ void sk_set_tbsize(sock *s, uint val); /* Resize TX buffer, keeping content */
void sk_set_tbuf(sock *s, void *tbuf); /* Switch TX buffer, NULL-> return to internal */
void sk_dump_all(void);
+int sk_is_ipv4(sock *s); /* True if socket is IPv4 */
+int sk_is_ipv6(sock *s); /* True if socket is IPv6 */
+
static inline int sk_send_buffer_empty(sock *sk)
{ return sk->tbuf == sk->tpos; }
-
-#ifdef IPV6
-#define sk_is_ipv4(X) 0
-#define sk_is_ipv6(X) 1
-#else
-#define sk_is_ipv4(X) 1
-#define sk_is_ipv6(X) 0
-#endif
-
-
int sk_setup_multicast(sock *s); /* Prepare UDP or IP socket for multicasting */
int sk_join_group(sock *s, ip_addr maddr); /* Join multicast group on sk iface */
int sk_leave_group(sock *s, ip_addr maddr); /* Leave multicast group on sk iface */
@@ -124,6 +116,12 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shou
#define SK_UNIX_PASSIVE 8
#define SK_UNIX 9
+/* Socket families */
+
+#define SK_FAM_NONE 0
+#define SK_FAM_IPV4 4
+#define SK_FAM_IPV6 6
+
/*
* For SK_UDP or SK_IP sockets setting DA/DP allows to use sk_send(),
* otherwise sk_send_to() must be used.