summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
Diffstat (limited to 'proto')
-rw-r--r--proto/bfd/bfd.c8
-rw-r--r--proto/bfd/packets.c24
-rw-r--r--proto/ospf/iface.c4
-rw-r--r--proto/radv/packets.c2
-rw-r--r--proto/rip/config.Y2
-rw-r--r--proto/rip/packets.c5
6 files changed, 12 insertions, 33 deletions
diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c
index f966161c..d33424b0 100644
--- a/proto/bfd/bfd.c
+++ b/proto/bfd/bfd.c
@@ -981,10 +981,10 @@ bfd_start(struct proto *P)
add_tail(&bfd_proto_list, &p->bfd_node);
birdloop_enter(p->loop);
- p->rx4_1 = bfd_open_rx_sk(p, 0, 4);
- p->rx4_m = bfd_open_rx_sk(p, 1, 4);
- p->rx6_1 = bfd_open_rx_sk(p, 0, 6);
- p->rx6_m = bfd_open_rx_sk(p, 1, 6);
+ p->rx4_1 = bfd_open_rx_sk(p, 0, SK_IPV4);
+ p->rx4_m = bfd_open_rx_sk(p, 1, SK_IPV4);
+ p->rx6_1 = bfd_open_rx_sk(p, 0, SK_IPV6);
+ p->rx6_m = bfd_open_rx_sk(p, 1, SK_IPV6);
birdloop_leave(p->loop);
bfd_take_requests(p);
diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c
index b7a057f1..579064c6 100644
--- a/proto/bfd/packets.c
+++ b/proto/bfd/packets.c
@@ -186,10 +186,11 @@ bfd_err_hook(sock *sk, int err)
}
sock *
-bfd_open_rx_sk(struct bfd_proto *p, int multihop, int inet_version)
+bfd_open_rx_sk(struct bfd_proto *p, int multihop, int af)
{
sock *sk = sk_new(p->tpool);
sk->type = SK_UDP;
+ sk->subtype = af;
sk->sport = !multihop ? BFD_CONTROL_PORT : BFD_MULTI_CTL_PORT;
sk->data = p;
@@ -202,19 +203,6 @@ bfd_open_rx_sk(struct bfd_proto *p, int multihop, int inet_version)
sk->priority = sk_priority_control;
sk->flags = SKF_THREAD | SKF_LADDR_RX | (!multihop ? SKF_TTL_RX : 0);
- switch (inet_version) {
- case 4:
- sk->fam = SK_FAM_IPV4;
- sk->flags |= SKF_V4ONLY;
- break;
- case 6:
- sk->fam = SK_FAM_IPV6;
- sk->flags |= SKF_V6ONLY;
- break;
- default:
- ASSERT(0);
- }
-
if (sk_open(sk) < 0)
goto err;
@@ -246,14 +234,6 @@ 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;
- if (ipa_is_ip4(local)) {
- sk->fam = SK_FAM_IPV4;
- sk->flags |= SKF_V4ONLY;
- } else {
- sk->fam = SK_FAM_IPV6;
- sk->flags |= SKF_V6ONLY;
- }
-
if (sk_open(sk) < 0)
goto err;
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 4548f6da..6ef24ffe 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -108,10 +108,10 @@ ospf_sk_open(struct ospf_iface *ifa)
sock *sk = sk_new(ifa->pool);
sk->type = SK_IP;
+ sk->subtype = ospf_is_v2(p) ? SK_IPV4 : SK_IPV6;
sk->dport = OSPF_PROTO;
sk->saddr = ifa->addr->ip;
sk->iface = ifa->iface;
- sk->fam = ospf_is_v2(p) ? SK_FAM_IPV4 : SK_FAM_IPV6;
sk->tos = ifa->cf->tx_tos;
sk->priority = ifa->cf->tx_priority;
@@ -193,8 +193,8 @@ ospf_open_vlink_sk(struct ospf_proto *p)
{
sock *sk = sk_new(p->p.pool);
sk->type = SK_IP;
+ sk->subtype = ospf_is_v2(p) ? SK_IPV4 : SK_IPV6;
sk->dport = OSPF_PROTO;
- sk->fam = ospf_is_v2(p) ? SK_FAM_IPV4 : SK_FAM_IPV6;
/* FIXME: configurable tos/priority ? */
sk->tos = IP_PREC_INTERNET_CONTROL;
diff --git a/proto/radv/packets.c b/proto/radv/packets.c
index 8f6a1913..915b412f 100644
--- a/proto/radv/packets.c
+++ b/proto/radv/packets.c
@@ -410,9 +410,9 @@ radv_sk_open(struct radv_iface *ifa)
{
sock *sk = sk_new(ifa->ra->p.pool);
sk->type = SK_IP;
+ sk->subtype = SK_IPV6;
sk->dport = ICMPV6_PROTO;
sk->saddr = ifa->addr->ip;
- sk->fam = SK_FAM_IPV6;
sk->ttl = 255; /* Mandatory for Neighbor Discovery packets */
sk->rx_hook = radv_rx_hook;
diff --git a/proto/rip/config.Y b/proto/rip/config.Y
index 3c8cd0f2..61a2a101 100644
--- a/proto/rip/config.Y
+++ b/proto/rip/config.Y
@@ -123,7 +123,7 @@ rip_iface_item:
| MODE MULTICAST { RIP_IFACE->mode = RIP_IM_MULTICAST; }
| MODE BROADCAST { RIP_IFACE->mode = RIP_IM_BROADCAST; if (rip_cfg_is_ng()) cf_error("Broadcast not supported in RIPng"); }
| PASSIVE bool { RIP_IFACE->passive = $2; }
- | ADDRESS ipa { RIP_IFACE->address = $2; }
+ | ADDRESS ipa { RIP_IFACE->address = $2; if (ipa_is_ip4($2) != rip_cfg_is_v2()) cf_error("IP address version mismatch"); }
| PORT expr { RIP_IFACE->port = $2; if (($2<1) || ($2>65535)) cf_error("Invalid port number"); }
| VERSION expr { RIP_IFACE->version = $2;
if (rip_cfg_is_ng()) cf_error("Version not supported in RIPng");
diff --git a/proto/rip/packets.c b/proto/rip/packets.c
index 488ac9df..f89bb178 100644
--- a/proto/rip/packets.c
+++ b/proto/rip/packets.c
@@ -715,7 +715,7 @@ rip_open_socket(struct rip_iface *ifa)
sock *sk = sk_new(p->p.pool);
sk->type = SK_UDP;
- sk->fam = rip_is_v2(p) ? SK_FAM_IPV4 : SK_FAM_IPV6;
+ sk->subtype = rip_is_v2(p) ? SK_IPV4 : SK_IPV6;
sk->sport = ifa->cf->port;
sk->dport = ifa->cf->port;
sk->iface = ifa->iface;
@@ -736,8 +736,7 @@ rip_open_socket(struct rip_iface *ifa)
sk->tos = ifa->cf->tx_tos;
sk->priority = ifa->cf->tx_priority;
sk->ttl = ifa->cf->ttl_security ? 255 : 1;
- sk->flags = SKF_LADDR_RX | (rip_is_ng(p) ? SKF_V6ONLY : 0) |
- ((ifa->cf->ttl_security == 1) ? SKF_TTL_RX : 0);
+ sk->flags = SKF_LADDR_RX | ((ifa->cf->ttl_security == 1) ? SKF_TTL_RX : 0);
/* sk->rbsize and sk->tbsize are handled in rip_iface_update_buffers() */