summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_interface.c')
-rw-r--r--ospfd/ospf_interface.c126
1 files changed, 64 insertions, 62 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index dc0787d5..09f30a44 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -3,7 +3,7 @@
* Copyright (C) 1999, 2000 Toshiaki Takada
*
* This file is part of GNU Zebra.
- *
+ *
* GNU Zebra is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or (at your
@@ -49,7 +49,7 @@
#include "ospfd/ospf_snmp.h"
#endif /* HAVE_SNMP */
-
+
int
ospf_if_get_output_cost (struct ospf_interface *oi)
{
@@ -83,11 +83,11 @@ ospf_if_recalculate_output_cost (struct interface *ifp)
{
u_int32_t newcost;
struct route_node *rn;
-
+
for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
{
struct ospf_interface *oi;
-
+
if ( (oi = rn->info) == NULL)
continue;
@@ -102,17 +102,17 @@ ospf_if_recalculate_output_cost (struct interface *ifp)
}
}
-/* Simulate down/up on the interface. This is needed, for example, when
+/* Simulate down/up on the interface. This is needed, for example, when
the MTU changes. */
void
ospf_if_reset(struct interface *ifp)
{
struct route_node *rn;
-
+
for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
{
struct ospf_interface *oi;
-
+
if ( (oi = rn->info) == NULL)
continue;
@@ -129,7 +129,7 @@ ospf_if_reset_variables (struct ospf_interface *oi)
if (oi->vl_data)
oi->type = OSPF_IFTYPE_VIRTUALLINK;
- else
+ else
/* preserve network-type */
if (oi->type != OSPF_IFTYPE_NBMA)
oi->type = OSPF_IFTYPE_BROADCAST;
@@ -138,10 +138,10 @@ ospf_if_reset_variables (struct ospf_interface *oi)
oi->crypt_seqnum = 0;
- /* This must be short, (less than RxmtInterval)
+ /* This must be short, (less than RxmtInterval)
- RFC 2328 Section 13.5 para 3. Set to 1 second to avoid Acks being
held back for too long - MAG */
- oi->v_ls_ack = 1;
+ oi->v_ls_ack = 1;
}
/* lookup oi for specified prefix/ifp */
@@ -151,17 +151,17 @@ ospf_if_table_lookup (struct interface *ifp, struct prefix *prefix)
struct prefix p;
struct route_node *rn;
struct ospf_interface *rninfo = NULL;
-
+
p = *prefix;
p.prefixlen = IPV4_MAX_PREFIXLEN;
-
+
/* route_node_get implicitely locks */
if ((rn = route_node_lookup (IF_OIFS (ifp), &p)))
{
rninfo = (struct ospf_interface *) rn->info;
route_unlock_node (rn);
}
-
+
return rninfo;
}
@@ -211,14 +211,14 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
}
else
return oi;
-
+
/* Set zebra interface pointer. */
oi->ifp = ifp;
oi->address = p;
-
+
ospf_add_to_if (ifp, oi);
listnode_add (ospf->oiflist, oi);
-
+
/* Initialize neighbor list. */
oi->nbrs = route_table_init ();
@@ -246,7 +246,7 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
#endif /* HAVE_OPAQUE_LSA */
oi->ospf = ospf;
-
+
return oi;
}
@@ -274,7 +274,7 @@ ospf_if_cleanup (struct ospf_interface *oi)
}
nbr_nbma->oi = NULL;
-
+
listnode_delete (oi->nbr_nbma, nbr_nbma);
}
@@ -290,10 +290,10 @@ ospf_if_cleanup (struct ospf_interface *oi)
list_delete_all_node (oi->ls_ack);
oi->crypt_seqnum = 0;
-
+
/* Empty link state update queue */
ospf_ls_upd_queue_empty (oi);
-
+
/* Reset pseudo neighbor. */
ospf_nbr_delete (oi->nbr_self);
oi->nbr_self = ospf_nbr_new (oi);
@@ -313,16 +313,16 @@ ospf_if_free (struct ospf_interface *oi)
/* Free Pseudo Neighbour */
ospf_nbr_delete (oi->nbr_self);
-
+
route_table_finish (oi->nbrs);
route_table_finish (oi->ls_upd_queue);
-
+
/* Free any lists that should be freed */
list_free (oi->nbr_nbma);
-
+
list_free (oi->ls_ack);
list_free (oi->ls_ack_direct.ls_ack);
-
+
ospf_delete_from_if (oi->ifp, oi);
listnode_delete (oi->ospf->oiflist, oi);
@@ -334,7 +334,7 @@ ospf_if_free (struct ospf_interface *oi)
XFREE (MTYPE_OSPF_IF, oi);
}
-
+
/*
* check if interface with given address is configured and
* return it if yes. special treatment for PtP networks.
@@ -377,7 +377,7 @@ ospf_if_is_up (struct ospf_interface *oi)
struct ospf_interface *
ospf_if_exists (struct ospf_interface *oic)
-{
+{
struct listnode *node;
struct ospf *ospf;
struct ospf_interface *oi;
@@ -398,13 +398,13 @@ ospf_if_lookup_by_local_addr (struct ospf *ospf,
{
struct listnode *node;
struct ospf_interface *oi;
-
+
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (ifp && oi->ifp != ifp)
continue;
-
+
if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
return oi;
}
@@ -417,7 +417,7 @@ ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p)
{
struct listnode *node;
struct ospf_interface *oi;
-
+
/* Check each Interface. */
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
@@ -465,7 +465,7 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src,
if (prefix_match (CONNECTED_PREFIX(oi->connected),
(struct prefix *) &addr))
{
- if ( (match == NULL) ||
+ if ( (match == NULL) ||
(match->address->prefixlen < oi->address->prefixlen)
)
match = oi;
@@ -474,12 +474,12 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src,
return match;
}
-
+
void
ospf_if_stream_set (struct ospf_interface *oi)
{
/* set output fifo queue. */
- if (oi->obuf == NULL)
+ if (oi->obuf == NULL)
oi->obuf = ospf_fifo_new ();
}
@@ -503,7 +503,7 @@ ospf_if_stream_unset (struct ospf_interface *oi)
}
}
-
+
static struct ospf_if_params *
ospf_new_if_params (void)
{
@@ -528,7 +528,7 @@ ospf_new_if_params (void)
UNSET_IF_PARAM (oip, auth_type);
oip->auth_crypt = list_new ();
-
+
oip->network_lsa_seqnum = htonl(OSPF_INITIAL_SEQUENCE_NUMBER);
return oip;
@@ -557,7 +557,7 @@ ospf_free_if_params (struct interface *ifp, struct in_addr addr)
oip = rn->info;
route_unlock_node (rn);
-
+
if (!OSPF_IF_PARAM_CONFIGURED (oip, output_cost_cmd) &&
!OSPF_IF_PARAM_CONFIGURED (oip, transmit_delay) &&
!OSPF_IF_PARAM_CONFIGURED (oip, retransmit_interval) &&
@@ -589,7 +589,7 @@ ospf_lookup_if_params (struct interface *ifp, struct in_addr addr)
p.prefix = addr;
rn = route_node_lookup (IF_OIFS_PARAMS (ifp), (struct prefix*)&p);
-
+
if (rn)
{
route_unlock_node (rn);
@@ -610,12 +610,12 @@ ospf_get_if_params (struct interface *ifp, struct in_addr addr)
p.prefix = addr;
rn = route_node_get (IF_OIFS_PARAMS (ifp), (struct prefix*)&p);
-
+
if (rn->info == NULL)
rn->info = ospf_new_if_params ();
else
route_unlock_node (rn);
-
+
return rn->info;
}
@@ -624,7 +624,7 @@ ospf_if_update_params (struct interface *ifp, struct in_addr addr)
{
struct route_node *rn;
struct ospf_interface *oi;
-
+
for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
{
if ((oi = rn->info) == NULL)
@@ -641,15 +641,15 @@ ospf_if_new_hook (struct interface *ifp)
int rc = 0;
ifp->info = XCALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info));
-
+
IF_OIFS (ifp) = route_table_init ();
IF_OIFS_PARAMS (ifp) = route_table_init ();
-
+
IF_DEF_PARAMS (ifp) = ospf_new_if_params ();
-
+
SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
IF_DEF_PARAMS (ifp)->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
-
+
SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
IF_DEF_PARAMS (ifp)->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
@@ -669,10 +669,10 @@ ospf_if_new_hook (struct interface *ifp)
SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_simple);
memset (IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
-
+
SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
IF_DEF_PARAMS (ifp)->auth_type = OSPF_AUTH_NOTSET;
-
+
#ifdef HAVE_OPAQUE_LSA
rc = ospf_opaque_new_if (ifp);
#endif /* HAVE_OPAQUE_LSA */
@@ -763,7 +763,7 @@ ospf_if_set_multicast(struct ospf_interface *oi)
/* drop only if last reference */
if (OI_MEMBER_COUNT(oi, MEMBER_DROUTERS) == 1)
ospf_if_drop_alldrouters(oi->ospf, oi->address, oi->ifp->ifindex);
-
+
/* Unset the flag regardless of whether the system call to leave
the group succeeded, since it's much safer to assume that
we are not a member. */
@@ -807,7 +807,7 @@ ospf_if_down (struct ospf_interface *oi)
return 1;
}
-
+
/* Virtual Link related functions. */
struct ospf_vl_data *
@@ -832,7 +832,7 @@ ospf_vl_data_free (struct ospf_vl_data *vl_data)
u_int vlink_count = 0;
-struct ospf_interface *
+struct ospf_interface *
ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
{
struct ospf_interface * voi;
@@ -842,7 +842,7 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
struct in_addr area_id;
struct connected *co;
struct prefix_ipv4 *p;
-
+
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_vl_new(): Start");
if (vlink_count == OSPF_VL_MAX_COUNT)
@@ -866,9 +866,9 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
p->family = AF_INET;
p->prefix.s_addr = 0;
p->prefixlen = 0;
-
+
co->address = (struct prefix *)p;
-
+
voi = ospf_if_new (ospf, vi, co->address);
if (voi == NULL)
{
@@ -924,24 +924,24 @@ ospf_vl_lookup (struct ospf *ospf, struct ospf_area *area,
{
struct ospf_vl_data *vl_data;
struct listnode *node;
-
+
if (IS_DEBUG_OSPF_EVENT)
{
zlog_debug ("%s: Looking for %s", __func__, inet_ntoa (vl_peer));
if (area)
zlog_debug ("%s: in area %s", __func__, inet_ntoa (area->area_id));
}
-
+
for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("%s: VL %s, peer %s", __func__,
vl_data->vl_oi->ifp->name,
inet_ntoa (vl_data->vl_peer));
-
+
if (area && !IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
continue;
-
+
if (IPV4_ADDR_SAME (&vl_data->vl_peer, &vl_peer))
return vl_data;
}
@@ -949,7 +949,7 @@ ospf_vl_lookup (struct ospf *ospf, struct ospf_area *area,
return NULL;
}
-static void
+static void
ospf_vl_shutdown (struct ospf_vl_data *vl_data)
{
struct ospf_interface *oi;
@@ -1002,7 +1002,7 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
if (voi->output_cost != v->distance)
{
-
+
voi->output_cost = v->distance;
changed = 1;
}
@@ -1011,11 +1011,11 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
{
vl_data->nexthop.oi = vp->nexthop->oi;
vl_data->nexthop.router = vp->nexthop->router;
-
+
if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
&vl_data->nexthop.oi->address->u.prefix4))
changed = 1;
-
+
voi->address->u.prefix4 = vl_data->nexthop.oi->address->u.prefix4;
voi->address->prefixlen = vl_data->nexthop.oi->address->prefixlen;
@@ -1055,17 +1055,19 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
&rl->link[i].link_data))
changed = 1;
vl_data->peer_addr = rl->link[i].link_data;
+ default:
+ break ;
}
}
}
-
+
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("%s: %s peer address: %s, cost: %d,%schanged", __func__,
vl_data->vl_oi->ifp->name,
inet_ntoa(vl_data->peer_addr),
voi->output_cost,
(changed ? " " : " un"));
-
+
return changed;
}
@@ -1176,7 +1178,7 @@ ospf_vls_in_area (struct ospf_area *area)
return c;
}
-
+
struct crypt_key *
ospf_crypt_key_new ()
{