From 05476c4d04a24bdb26fa64e05ab31bc36118f34e Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 18 May 2014 11:42:26 +0200 Subject: IPv4/IPv6 integrated socket code. --- proto/ospf/iface.c | 20 +++++++++++++------- proto/ospf/packet.c | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'proto/ospf') diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index f4d9be55..50cf15e2 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -90,6 +90,8 @@ find_nbma_node_in(list *nnl, ip_addr ip) static int ospf_sk_open(struct ospf_iface *ifa) { + struct proto_ospf *po = ifa->oa->po; + sock *sk = sk_new(ifa->pool); sk->type = SK_IP; sk->dport = OSPF_PROTO; @@ -121,7 +123,7 @@ ospf_sk_open(struct ospf_iface *ifa) { ifa->all_routers = ifa->addr->brd; - if (sk_set_broadcast(sk, 1) < 0) + if (sk_setup_broadcast(sk) < 0) goto err; } else @@ -141,6 +143,7 @@ ospf_sk_open(struct ospf_iface *ifa) return 1; err: + sk_log_error(sk, po->proto.name); rfree(sk); return 0; } @@ -151,7 +154,9 @@ ospf_sk_join_dr(struct ospf_iface *ifa) if (ifa->sk_dr) return; - sk_join_group(ifa->sk, AllDRouters); + if (sk_join_group(ifa->sk, AllDRouters) < 0) + sk_log_error(ifa->sk, ifa->oa->po->proto.name); + ifa->sk_dr = 1; } @@ -161,15 +166,15 @@ ospf_sk_leave_dr(struct ospf_iface *ifa) if (!ifa->sk_dr) return; - sk_leave_group(ifa->sk, AllDRouters); + if (sk_leave_group(ifa->sk, AllDRouters) < 0) + sk_log_error(ifa->sk, ifa->oa->po->proto.name); + ifa->sk_dr = 0; } void ospf_open_vlink_sk(struct proto_ospf *po) { - struct proto *p = &po->proto; - sock *sk = sk_new(po->proto.pool); sk->type = SK_IP; sk->dport = OSPF_PROTO; @@ -197,8 +202,9 @@ ospf_open_vlink_sk(struct proto_ospf *po) return; err: + sk_log_error(sk, po->proto.name); + log(L_ERR "%s: Cannot open virtual link socket", po->proto.name); rfree(sk); - log(L_ERR "%s: Cannot open virtual link socket", p->name); } static void @@ -463,7 +469,7 @@ ospf_iface_add(struct object_lock *lock) /* Open socket if interface is not stub */ if (! ifa->stub && ! ospf_sk_open(ifa)) { - log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->ifname); + log(L_ERR "%s: Cannot open socket for %s, declaring as stub", p->name, ifa->ifname); ifa->ioprob = OSPF_I_SK; ifa->stub = 1; } diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index cd4b8a97..1240b05c 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -308,9 +308,9 @@ ospf_rx_hook(sock *sk, int size) return 1; } - if (ifa->check_ttl && (sk->ttl < 255)) + if (ifa->check_ttl && (sk->rcv_ttl < 255)) { - log(L_ERR "%s%I - TTL %d (< 255)", mesg, sk->faddr, sk->ttl); + log(L_ERR "%s%I - TTL %d (< 255)", mesg, sk->faddr, sk->rcv_ttl); return 1; } -- cgit v1.2.3