diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ipv4.h | 6 | ||||
-rw-r--r-- | lib/ipv6.h | 10 | ||||
-rw-r--r-- | lib/socket.h | 11 |
3 files changed, 24 insertions, 3 deletions
@@ -54,6 +54,7 @@ typedef u32 ip_addr; #define ipa_hton(x) x = _MI(htonl(_I(x))) #define ipa_ntoh(x) x = _MI(ntohl(_I(x))) #define ipa_classify(x) ipv4_classify(_I(x)) +#define ipa_has_link_scope(x) ipv4_has_link_scope(_I(x)) #define ipa_opposite(x,len) _MI(_I(x) ^ (len == 30 ? 3 : 1)) #define ipa_class_mask(x) _MI(ipv4_class_mask(_I(x))) #define ipa_from_u32(x) _MI(x) @@ -69,6 +70,11 @@ int ipv4_classify(u32); u32 ipv4_class_mask(u32); byte *ipv4_skip_header(byte *, int *); +static inline int ipv4_has_link_scope(u32 a) +{ + return 0; +} + static inline unsigned ipv4_hash(u32 a) { /* Returns a 16-bit value */ @@ -1,3 +1,4 @@ + /* * BIRD -- IP Addresses et Cetera for IPv6 * @@ -59,6 +60,7 @@ typedef struct ipv6_addr { #define ipa_hton(x) ipv6_hton(&(x)) #define ipa_ntoh(x) ipv6_ntoh(&(x)) #define ipa_classify(x) ipv6_classify(&(x)) +#define ipa_has_link_scope(x) ipv6_has_link_scope(&(x)) /* ipa_opposite and ipa_class_mask don't make sense with IPv6 */ /* ipa_from_u32 and ipa_to_u32 replaced by ipa_build */ #define ipa_build(a,b,c,d) _MI(a,b,c,d) @@ -68,6 +70,9 @@ typedef struct ipv6_addr { #define ipa_getbit(x, y) ipv6_getbit(x, y) #define ipa_absolutize(x,y) ipv6_absolutize(x,y) +/* In IPv6, SOCK_RAW does not return packet header */ +#define ip_skip_header(x, y) x + ip_addr ipv6_mkmask(unsigned); unsigned ipv6_mklen(ip_addr *); int ipv6_classify(ip_addr *); @@ -77,6 +82,11 @@ int ipv6_compare(ip_addr, ip_addr); int ipv4_pton_u32(char *, u32 *); void ipv6_absolutize(ip_addr *, ip_addr *); +static inline int ipv6_has_link_scope(ip_addr *a) +{ + return ((a->addr[0] & 0xffc00000) == 0xfe800000); +} + /* * This hash function looks well, but once IPv6 enters * mainstream use, we need to check that it has good diff --git a/lib/socket.h b/lib/socket.h index 53e89ed..f44e8e8 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -50,9 +50,16 @@ int sk_send_to(sock *, unsigned len, ip_addr to, unsigned port); /* sk_send to g void sk_reallocate(sock *); /* Free and allocate tbuf & rbuf */ void sk_dump_all(void); int sk_set_ttl(sock *s, int ttl); /* Set TTL for given socket */ -int sk_set_md5_auth(sock *s, ip_addr a, char *passwd); /* Add or remove security associations for given passive socket */ + +/* Add or remove security associations for given passive socket */ +int sk_set_md5_auth(sock *s, ip_addr a, char *passwd); int sk_rx_ready(sock *s); +/* Prepare UDP or IP socket to multicasting. s->iface and s->ttl must be set */ +int sk_setup_multicast(sock *s); +int sk_join_group(sock *s, ip_addr maddr); +int sk_leave_group(sock *s, ip_addr maddr); + static inline int sk_send_buffer_empty(sock *sk) { @@ -73,9 +80,7 @@ sk_send_buffer_empty(sock *sk) #define SK_TCP_ACTIVE 1 /* ? ? * * - ? - */ #define SK_TCP 2 #define SK_UDP 3 /* ? ? - - - ? ? */ -#define SK_UDP_MC 4 /* ? ? * * * * - */ #define SK_IP 5 /* ? - - * - ? ? */ -#define SK_IP_MC 6 /* ? - * * * * - */ #define SK_MAGIC 7 /* Internal use by sysdep code */ #define SK_UNIX_PASSIVE 8 #define SK_UNIX 9 |