diff options
Diffstat (limited to 'proto/bfd/packets.c')
-rw-r--r-- | proto/bfd/packets.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c index 2200acfa..a28e4c50 100644 --- a/proto/bfd/packets.c +++ b/proto/bfd/packets.c @@ -186,7 +186,7 @@ bfd_err_hook(sock *sk, int err) } sock * -bfd_open_rx_sk(struct bfd_proto *p, int multihop) +bfd_open_rx_sk(struct bfd_proto *p, int multihop, int inet_version) { sock *sk = sk_new(p->tpool); sk->type = SK_UDP; @@ -202,7 +202,18 @@ bfd_open_rx_sk(struct bfd_proto *p, int multihop) sk->priority = sk_priority_control; sk->flags = SKF_THREAD | SKF_LADDR_RX | (!multihop ? SKF_TTL_RX : 0); - sk->af = AF_INET6; + switch (inet_version) { + case 4: + sk->af = AF_INET; + sk->flags |= SKF_V4ONLY; + break; + case 6: + sk->af = AF_INET6; + sk->flags |= SKF_V6ONLY; + break; + default: + ASSERT(0); + } if (sk_open(sk) < 0) goto err; @@ -235,7 +246,13 @@ bfd_open_tx_sk(struct bfd_proto *p, ip_addr local, struct iface *ifa) sk->ttl = ifa ? 255 : -1; sk->flags = SKF_THREAD | SKF_BIND | SKF_HIGH_PORT; - sk->af = AF_INET6; + if (ipa_is_ip4(local)) { + sk->af = AF_INET; + sk->flags |= SKF_V4ONLY; + } else { + sk->af = AF_INET6; + sk->flags |= SKF_V6ONLY; + } if (sk_open(sk) < 0) goto err; |