From 52a43ae3b76f86b697537bc3ad8afdb3b421cf2c Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 28 Mar 2011 22:46:18 +0200 Subject: Minor changes in addresses. Mainly changes IA_UNNUMBERED to IA_PEER and adds IA_HOST. Also do not show broadcast addr in show interfaces. Nobody cares for that. --- proto/ospf/iface.c | 14 +++++++------- proto/ospf/packet.c | 2 +- proto/ospf/topology.c | 22 +++++++++++++--------- proto/rip/rip.c | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) (limited to 'proto') diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index faee634..7889944 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -443,6 +443,10 @@ ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr) if (! addr) return 0; + /* a host/loopback address */ + if (addr->flags & IA_HOST) + return 1; + /* * We cannot properly support multiple OSPF ifaces on real iface * with multiple prefixes, therefore we force OSPF ifaces with @@ -453,10 +457,6 @@ ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr) return 1; #endif - /* a loopback/dummy address */ - if ((addr->pxlen == MAX_PREFIX_LENGTH) && ipa_zero(addr->opposite)) - return 1; - return ip->stub; } @@ -522,10 +522,10 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i int old_type = ifa->type; #ifdef OSPFv2 - if ((ifa->type == OSPF_IT_BCAST) && (addr->flags & IA_UNNUMBERED)) + if ((ifa->type == OSPF_IT_BCAST) && (addr->flags & IA_PEER)) ifa->type = OSPF_IT_PTP; - if ((ifa->type == OSPF_IT_NBMA) && (addr->flags & IA_UNNUMBERED)) + if ((ifa->type == OSPF_IT_NBMA) && (addr->flags & IA_PEER)) ifa->type = OSPF_IT_PTMP; #endif @@ -1115,7 +1115,7 @@ ospf_iface_info(struct ospf_iface *ifa) else { #ifdef OSPFv2 - if (ifa->addr->flags & IA_UNNUMBERED) + if (ifa->addr->flags & IA_PEER) cli_msg(-1015, "Interface %s (peer %I)", ifa->iface->name, ifa->addr->opposite); else cli_msg(-1015, "Interface %s (%I/%d)", ifa->iface->name, ifa->addr->prefix, ifa->addr->pxlen); diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index e8ebafd..ae9f862 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -269,7 +269,7 @@ ospf_rx_hook(sock *sk, int size) struct proto_ospf *po = ifa->oa->po; // struct proto *p = &po->proto; - int src_local = ifa_match_addr(ifa->addr, sk->faddr); + int src_local = ipa_in_net(sk->faddr, ifa->addr->prefix, ifa->addr->pxlen); int dst_local = ipa_equal(sk->laddr, ifa->addr->ip); int dst_mcast = ipa_equal(sk->laddr, AllSPFRouters) || ipa_equal(sk->laddr, AllDRouters); diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 1403e72..78d8859 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -160,6 +160,7 @@ configured_stubnet(struct ospf_area *oa, struct ifa *a) if (!oa->ac) return 0; + /* Does not work for IA_PEER addresses, but it is not called on these */ struct ospf_stubnet_config *sn; WALK_LIST(sn, oa->ac->stubnet_list) { @@ -254,7 +255,7 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length) ln = lsab_alloc(po, sizeof(struct ospf_lsa_rt_link)); ln->type = LSART_PTP; ln->id = neigh->rid; - ln->data = (ifa->addr->flags & IA_UNNUMBERED) ? + ln->data = (ifa->addr->flags & IA_PEER) ? ifa->iface->index : ipa_to_u32(ifa->addr->ip); ln->metric = ifa->cost; ln->padding = 0; @@ -301,12 +302,14 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length) /* Now we will originate stub area if there is no primary */ if (net_lsa || (ifa->type == OSPF_IT_VLINK) || - (ifa->addr->flags & IA_UNNUMBERED) || + (ifa->addr->flags & IA_PEER) || configured_stubnet(oa, ifa->addr)) continue; ln = lsab_alloc(po, sizeof(struct ospf_lsa_rt_link)); - if ((ifa->state == OSPF_IS_LOOP) || (ifa->type == OSPF_IT_PTMP)) + if ((ifa->addr->flags & IA_HOST) || + (ifa->state == OSPF_IS_LOOP) || + (ifa->type == OSPF_IT_PTMP)) { /* Host stub entry */ ln->type = LSART_STUB; @@ -1208,7 +1211,7 @@ originate_prefix_rt_lsa_body(struct ospf_area *oa, u16 *length) WALK_LIST(a, ifa->iface->addrs) { if ((a->flags & IA_SECONDARY) || - (a->flags & IA_UNNUMBERED) || + (a->flags & IA_PEER) || (a->scope <= SCOPE_LINK)) continue; @@ -1219,15 +1222,16 @@ originate_prefix_rt_lsa_body(struct ospf_area *oa, u16 *length) configured_stubnet(oa, a)) continue; - if ((ifa->state == OSPF_IS_LOOP) || (ifa->type == OSPF_IT_PTMP)) + if ((a->flags & IA_HOST) || + (ifa->state == OSPF_IS_LOOP) || + (ifa->type == OSPF_IT_PTMP)) + { lsa_put_prefix(po, a->ip, MAX_PREFIX_LENGTH, 0); + host_addr = 1; + } else lsa_put_prefix(po, a->prefix, a->pxlen, ifa->cost); i++; - - if ((ifa->state == OSPF_IS_LOOP) || - (a->pxlen == MAX_PREFIX_LENGTH)) - host_addr = 1; } ifa->px_pos_end = i; diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 4b3de2e..0259cfb 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -704,7 +704,7 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_ } if (new) { - if (new->addr->flags & IA_UNNUMBERED) + if (new->addr->flags & IA_PEER) log( L_WARN "%s: rip is not defined over unnumbered links", p->name ); if (rif->multicast) { #ifndef IPV6 -- cgit v1.2.3