diff options
-rw-r--r-- | bgpd/bgp_aspath.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_clist.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_debug.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_msg_read.c | 1 | ||||
-rw-r--r-- | bgpd/bgp_open.c | 15 | ||||
-rw-r--r-- | bgpd/bgp_peer.c | 1 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 36 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 81 | ||||
-rwxr-xr-x | configure.ac | 13 | ||||
-rw-r--r-- | isisd/isis_csm.c | 26 | ||||
-rw-r--r-- | isisd/isis_pdu.c | 66 | ||||
-rw-r--r-- | isisd/isis_spf.c | 2 | ||||
-rw-r--r-- | lib/command_parse.h | 8 | ||||
-rw-r--r-- | lib/errno_names.c | 2 | ||||
-rw-r--r-- | lib/log.c | 16 | ||||
-rw-r--r-- | lib/log_local.h | 2 | ||||
-rw-r--r-- | lib/qpath.c | 4 | ||||
-rw-r--r-- | lib/qpath.h | 4 | ||||
-rw-r--r-- | lib/vty_local.h | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_message.c | 16 | ||||
-rw-r--r-- | ospfd/ospf_abr.c | 134 | ||||
-rw-r--r-- | ospfd/ospf_apiserver.c | 8 | ||||
-rw-r--r-- | ospfd/ospf_interface.c | 126 | ||||
-rw-r--r-- | ospfd/ospf_ism.c | 18 | ||||
-rw-r--r-- | ospfd/ospf_lsa.c | 346 | ||||
-rw-r--r-- | ospfd/ospf_neighbor.c | 34 | ||||
-rw-r--r-- | tests/bgp_capability_test.c | 2 | ||||
-rw-r--r-- | watchquagga/watchquagga.c | 6 |
30 files changed, 562 insertions, 429 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index dc6ed166..6fdd53c0 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -1508,6 +1508,10 @@ aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path) case AS_SEQUENCE: cpasns = MIN(seg->length, hops); hops -= seg->length; + break ; + + default: + break ; } assert (cpasns <= seg->length); @@ -1726,6 +1730,8 @@ aspath_gettoken (const char *buf, enum as_token *token, u_long *asno) *token = as_token_confed_set_end; p++; return p; + default: + break ; } /* Check actual AS value. */ diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index ecf1a526..b7d21e81 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -60,6 +60,8 @@ community_list_master_lookup (struct community_list_handler *ch, int master) return &ch->community_list; case EXTCOMMUNITY_LIST_MASTER: return &ch->extcommunity_list; + default: + break ; } return NULL; } diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 83e6400a..e7afe874 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -307,6 +307,8 @@ bgp_notify_print(struct peer *peer, bgp_notify notification) if (subcode != 0) subcode_str = LOOKUP (bgp_notify_capability_msg, subcode); break; + default: + break ; } /* Construct hex_form of data, if required. */ diff --git a/bgpd/bgp_msg_read.c b/bgpd/bgp_msg_read.c index ed49f535..a7f8ad26 100644 --- a/bgpd/bgp_msg_read.c +++ b/bgpd/bgp_msg_read.c @@ -114,7 +114,6 @@ static const bgp_size_t bgp_type_min_size[] = [qBGP_MT_unknown] = BGP_MSG_MAX_L + 1, /* invalid ! */ [qBGP_MT_OPEN] = BGP_OPM_MIN_L, - [qBGP_MT_OPEN] = BGP_OPM_MIN_L, [qBGP_MT_UPDATE] = BGP_UPM_MIN_L, [qBGP_MT_NOTIFICATION] = BGP_NOM_MIN_L, [qBGP_MT_KEEPALIVE] = BGP_KAM_L, diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 80b90683..4c4f9ff2 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -158,10 +158,17 @@ bgp_afi_safi_valid_indices (afi_t afi, safi_t *safi) case SAFI_MULTICAST: case SAFI_MPLS_VPN: return 1; - } - } - zlog_debug ("unknown afi/safi (%u/%u)", afi, *safi); + default: + break ; + } ; + break ; + + default: + break ; + } ; + + zlog_debug ("unknown afi/safi (%u/%u)", afi, *safi); return 0; } @@ -350,6 +357,8 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) case ORF_MODE_RECEIVE: SET_FLAG (peer->af_cap[afi][safi], rm_cap); break; + default: + break ; } } return 0; diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index f07a30f5..91753594 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -1485,6 +1485,7 @@ bgp_peer_map_peer_down(peer_down_t why_down) /* To keep the compiler happy. */ case PEER_DOWN_count: + default: break ; /* should have asserted already */ } ; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 34d580b8..e1f3748e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1732,6 +1732,7 @@ bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, else bgp_adj_out_unset (rn, peer, p, afi, safi); break; + case BGP_TABLE_RSCLIENT: /* Announcement to peer->conf. If the route is filtered, withdraw it. */ @@ -1741,6 +1742,9 @@ bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, else bgp_adj_out_unset (rn, peer, p, afi, safi); break; + + default: + break ; } bgp_attr_extra_free (&attr); @@ -9971,9 +9975,13 @@ bgp_table_stats_walker (struct thread *t) case AF_INET: space = IPV4_MAX_BITLEN; break; + case AF_INET6: space = IPV6_MAX_BITLEN; break; + + default: + return 0 ; } ts->counts[BGP_STATS_MAXBITLEN] = space; diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index f9bf2844..56455a0b 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2205,12 +2205,18 @@ bgp_route_match_add (struct vty *vty, struct route_map_index *index, { switch (ret) { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + + default: + vty_out (vty, "%% Route map *internal* error %d.%s", ret, + VTY_NEWLINE); + return CMD_WARNING; } } return CMD_SUCCESS; @@ -2231,9 +2237,15 @@ bgp_route_match_delete (struct vty *vty, struct route_map_index *index, case RMAP_RULE_MISSING: vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); return CMD_WARNING; + case RMAP_COMPILE_ERROR: vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); return CMD_WARNING; + + default: + vty_out (vty, "%% Route map *internal* error %d.%s", ret, + VTY_NEWLINE); + return CMD_WARNING; } } return CMD_SUCCESS; @@ -2254,9 +2266,15 @@ bgp_route_set_add (struct vty *vty, struct route_map_index *index, case RMAP_RULE_MISSING: vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); return CMD_WARNING; + case RMAP_COMPILE_ERROR: vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); return CMD_WARNING; + + default: + vty_out (vty, "%% Route map *internal* error %d.%s", ret, + VTY_NEWLINE); + return CMD_WARNING; } } return CMD_SUCCESS; @@ -2277,9 +2295,15 @@ bgp_route_set_delete (struct vty *vty, struct route_map_index *index, case RMAP_RULE_MISSING: vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); return CMD_WARNING; + case RMAP_COMPILE_ERROR: vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); return CMD_WARNING; + + default: + vty_out (vty, "%% Route map *internal* error %d.%s", ret, + VTY_NEWLINE); + return CMD_WARNING; } } return CMD_SUCCESS; diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index 3f56fb25..6244695a 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -451,6 +451,8 @@ write_bgpPeerTable (int action, u_char *var_val, case BGPPEERMINROUTEADVERTISEMENTINTERVAL: peer->v_routeadv = intval; break; + default: + break ; } return SNMP_ERR_NOERROR; } @@ -840,6 +842,8 @@ bgp4PathAttrTable (struct variable *v, oid name[], size_t *length, *var_len = 0; return NULL; break; + default: + break ; } return NULL; } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 40efd6b8..bafe7eb3 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -223,13 +223,17 @@ bgp_vty_return (struct vty *vty, int ret) case BGP_ERR_NO_IBGP_WITH_TTLHACK: str = "ttl-security only allowed for EBGP peers"; break; - } - if (str) - { - vty_out (vty, "%% %s%s", str, VTY_NEWLINE); + default: + if (ret >= 0) + return CMD_SUCCESS ; + + vty_out (vty, "%% unknown error %d%s", ret, VTY_NEWLINE); return CMD_WARNING; - } - return CMD_SUCCESS; + } ; + + vty_out (vty, "%% %s%s", str, VTY_NEWLINE); + + return CMD_WARNING ; } /* BGP global configuration. */ @@ -340,20 +344,27 @@ DEFUN_ATTR (router_bgp, ret = bgp_get (&bgp, &as, name); switch (ret) { - case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: - vty_out (vty, "Please specify 'bgp multiple-instance' first%s", - VTY_NEWLINE); - return CMD_WARNING; - - case BGP_ERR_AS_MISMATCH: - vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); - return CMD_WARNING; - - case BGP_ERR_INSTANCE_MISMATCH: - vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE); - vty_out (vty, "BGP instance is already running; AS is %u%s", - as, VTY_NEWLINE); - return CMD_WARNING; + case 0: + break ; + + case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: + vty_out (vty, "Please specify 'bgp multiple-instance' first%s", + VTY_NEWLINE); + return CMD_WARNING; + + case BGP_ERR_AS_MISMATCH: + vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); + return CMD_WARNING; + + case BGP_ERR_INSTANCE_MISMATCH: + vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE); + vty_out (vty, "BGP instance is already running; AS is %u%s", + as, VTY_NEWLINE); + return CMD_WARNING; + + default: + vty_out (vty, "%% unknown error %d%s", ret, VTY_NEWLINE); + return CMD_WARNING ; } vty->node = BGP_NODE ; @@ -1299,6 +1310,8 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE); return CMD_WARNING; + default: + break ; } return bgp_vty_return (vty, ret); } @@ -7836,16 +7849,20 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp, { switch (type) { - case show_all: - bgp_show_peer (vty, peer); - break; - case show_peer: - if (sockunion_same (&peer->su, su)) - { - find = 1; - bgp_show_peer (vty, peer); - } - break; + case show_all: + bgp_show_peer (vty, peer); + break; + + case show_peer: + if (sockunion_same (&peer->su, su)) + { + find = 1; + bgp_show_peer (vty, peer); + } + break; + + default: + break ; } } @@ -10287,6 +10304,8 @@ community_list_perror (struct vty *vty, int ret) case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); break; + default: + break ; } } @@ -11079,6 +11098,8 @@ community_list_config_write_list(struct vty* vty, int what) list_type = "extcommunity-list" ; list_style = "expanded " ; break ; + default: + break ; } ; if (all_digit(list_name)) list_style = "" ; /* squash style for all digit names */ diff --git a/configure.ac b/configure.ac index 01dc36bb..1151cd95 100755 --- a/configure.ac +++ b/configure.ac @@ -134,11 +134,14 @@ if test "x${cflags_specified}" = "x" ; then AC_MSG_RESULT([Intel default]) ;; "GCC") - CFLAGS="-Os -fno-omit-frame-pointer -g -std=gnu99 -Wall" - CFLAGS="${CFLAGS} -Wsign-compare -Wpointer-arith" - CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings" - CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations" - CFLAGS="${CFLAGS} -Wchar-subscripts -Wcast-qual" + CFLAGS="-O2 -fno-omit-frame-pointer -g -std=c99 -Wall -Wextra" + CFLAGS="${CFLAGS} -Wno-missing-field-initializers -Wno-type-limits" + CFLAGS="${CFLAGS} -Wno-unused-parameter" + CFLAGS="${CFLAGS} -Wbad-function-cast -Wcast-qual -Wchar-subscripts" + CFLAGS="${CFLAGS} -Wmissing-declarations -Wmissing-prototypes" + CFLAGS="${CFLAGS} -Wpointer-arith -Wwrite-strings" + # CFLAGS="${CFLAGS} -Wswitch-default" -- interesting, but tedious + # CFLAGS="${CFLAGS} -Wtype-limits" -- interesting, but tedious CFLAGS="${CFLAGS} -pthread" # TODO: conditionally addd -Wpacked if handled AC_MSG_RESULT([gcc default]) diff --git a/isisd/isis_csm.c b/isisd/isis_csm.c index 80d0c906..e4f8f133 100644 --- a/isisd/isis_csm.c +++ b/isisd/isis_csm.c @@ -2,21 +2,21 @@ * IS-IS Rout(e)ing protocol - isis_csm.c * IS-IS circuit state machine * Copyright (C) 2001,2002 Sampo Saaristo - * Tampere University of Technology + * Tampere University of Technology * Institute of Communications Engineering * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public Licenseas published by the Free - * Software Foundation; either version 2 of the License, or (at your option) + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public Licenseas published by the Free + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * - * This program is distributed in the hope that it will be useful,but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * This program is distributed in the hope that it will be useful,but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -103,6 +103,8 @@ isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg) case IF_DOWN_FROM_Z: zlog_warn ("circuit already disconnected"); break; + default: + break ; } break; case C_STATE_INIT: @@ -127,6 +129,8 @@ isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg) isis_circuit_del (circuit); circuit = NULL; break; + default: + break ; } break; case C_STATE_CONF: @@ -149,6 +153,8 @@ isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg) case IF_DOWN_FROM_Z: zlog_warn ("circuit already disconnected"); break; + default: + break ; } break; case C_STATE_UP: @@ -171,6 +177,8 @@ isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg) circuit->state = C_STATE_CONF; isis_event_circuit_state_change (circuit, 0); break; + default: + break ; } break; diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index a2ab0649..0a69dcb6 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1,23 +1,23 @@ /* - * IS-IS Rout(e)ing protocol - isis_pdu.c + * IS-IS Rout(e)ing protocol - isis_pdu.c * PDU processing * * Copyright (C) 2001,2002 Sampo Saaristo - * Tampere University of Technology + * Tampere University of Technology * Institute of Communications Engineering * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public Licenseas published by the Free - * Software Foundation; either version 2 of the License, or (at your option) + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public Licenseas published by the Free + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * - * This program is distributed in the hope that it will be useful,but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * This program is distributed in the hope that it will be useful,but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -142,7 +142,7 @@ ip_match (struct list *left, struct list *right) if ((left == NULL) || (right == NULL)) return 0; - + for (ALL_LIST_ELEMENTS_RO (left, node1, ip1)) { for (ALL_LIST_ELEMENTS_RO (right, node2, ip2)) @@ -158,7 +158,7 @@ ip_match (struct list *left, struct list *right) } /* - * Checks whether we should accept a PDU of given level + * Checks whether we should accept a PDU of given level */ static int accept_level (int level, int circuit_t) @@ -269,7 +269,7 @@ tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj) #endif /* HAVE_IPV6 */ /* - * RECEIVE SIDE + * RECEIVE SIDE */ /* @@ -320,7 +320,7 @@ process_p2p_hello (struct isis_circuit *circuit) hdr.local_id = stream_getc (stream); */ /* - * My interpertation of the ISO, if no adj exists we will create one for + * My interpertation of the ISO, if no adj exists we will create one for * the circuit */ @@ -430,6 +430,8 @@ process_p2p_hello (struct isis_circuit *circuit) isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System"); } break; + default: + break ; } } @@ -495,6 +497,8 @@ process_p2p_hello (struct isis_circuit *circuit) ; /* Accept */ } break; + default: + break ; } } @@ -536,6 +540,8 @@ process_p2p_hello (struct isis_circuit *circuit) ; /* Accept */ } break; + default: + break ; } } } @@ -615,6 +621,8 @@ process_p2p_hello (struct isis_circuit *circuit) ; /* Accept */ } break; + default: + break ; } } } @@ -638,6 +646,8 @@ process_p2p_hello (struct isis_circuit *circuit) case ISIS_ADJ_NONE: adj->sys_type = ISIS_SYSTYPE_UNKNOWN; break; + default: + break ; } adj->circuit_t = hdr->circuit_t; @@ -773,8 +783,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char * ssnpa) goto out; } - /* - * it's own IIH PDU - discard silently + /* + * it's own IIH PDU - discard silently */ if (!memcmp (circuit->u.bc.snpa, ssnpa, ETH_ALEN)) { @@ -846,6 +856,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char * ssnpa) ISIS_SYS_ID_LEN + 1); } break; + default: + break ; } adj->hold_time = hdr.hold_time; @@ -949,7 +961,7 @@ process_lsp (int level, struct isis_circuit *circuit, u_char * ssnpa) ntohs (hdr->checksum), ntohs (hdr->rem_lifetime), /* FIXME: use %z when we stop supporting old compilers. */ - (unsigned long) stream_get_endp (circuit->rcv_stream), + (unsigned long) stream_get_endp (circuit->rcv_stream), circuit->interface->name); } @@ -1144,7 +1156,7 @@ dontcheckadj: } return retval; } - /* 7.3.15.1 c) - If this is our own lsp and we don't have it initiate a + /* 7.3.15.1 c) - If this is our own lsp and we don't have it initiate a * purge */ if (memcmp (hdr->lsp_id, isis->sysid, ISIS_SYS_ID_LEN) == 0) { @@ -1489,7 +1501,7 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit, } else { - /* 7.3.15.2 b) 5) if it was not found, and all of those are not 0, + /* 7.3.15.2 b) 5) if it was not found, and all of those are not 0, * insert it and set SSN on it */ if (entry->rem_lifetime && entry->checksum && entry->seq_num && memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN)) @@ -1776,7 +1788,7 @@ isis_receive (struct thread *thread) int retval; /* - * Get the circuit + * Get the circuit */ circuit = THREAD_ARG (thread); assert (circuit); @@ -1792,8 +1804,8 @@ isis_receive (struct thread *thread) if (retval == ISIS_OK) retval = isis_handle_pdu (circuit, ssnpa); - /* - * prepare for next packet. + /* + * prepare for next packet. */ THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit, circuit->fd); @@ -1810,7 +1822,7 @@ isis_receive (struct thread *thread) int retval; /* - * Get the circuit + * Get the circuit */ circuit = THREAD_ARG (thread); assert (circuit); @@ -1827,8 +1839,8 @@ isis_receive (struct thread *thread) if (retval == ISIS_OK) retval = isis_handle_pdu (circuit, ssnpa); - /* - * prepare for next packet. + /* + * prepare for next packet. */ circuit->t_read = thread_add_timer_msec (master, isis_receive, circuit, listcount @@ -1882,7 +1894,7 @@ fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type) } /* - * SEND SIDE + * SEND SIDE */ static void fill_fixed_hdr_andstream (struct isis_fixed_hdr *hdr, u_char pdu_type, @@ -1974,7 +1986,7 @@ send_hello (struct isis_circuit *circuit, int level) } /* - * Then the variable length part + * Then the variable length part */ /* add circuit password */ if (circuit->passwd.type) diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index c4433e49..633f0ad1 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -379,6 +379,8 @@ isis_find_vertex (struct list *list, void *id, enum vertextype vtype) PSIZE (p1->prefixlen)) == 0) return vertex; break; + default: + break ; } } diff --git a/lib/command_parse.h b/lib/command_parse.h index ee219f84..ab93f061 100644 --- a/lib/command_parse.h +++ b/lib/command_parse.h @@ -142,7 +142,7 @@ typedef enum cmd_item_type_bit cmd_item_type_bit_t ; Inline bool cmd_item_is_option(cmd_item_type_t itt) { - const static bool is_option[item_type_count] = + static const bool is_option[item_type_count] = { [item_null] = false, @@ -176,7 +176,7 @@ cmd_item_is_option(cmd_item_type_t itt) Inline bool cmd_item_is_vararg(cmd_item_type_t itt) { - const static bool is_vararg[item_type_count] = + static const bool is_vararg[item_type_count] = { [item_null] = false, @@ -391,7 +391,7 @@ match_item_type(match_type_t mt) Inline match_strength_t match_match_strength(match_type_t mt) { - const static match_strength_t match_match_strength[match_type_count] = + static const match_strength_t match_match_strength[match_type_count] = { [mt_no_match] = ms_no_match, @@ -439,7 +439,7 @@ match_match_strength(match_type_t mt) Inline match_type_t item_best_match(cmd_item_type_t it) { - const static match_type_t item_best_match[item_type_count] = + static const match_type_t item_best_match[item_type_count] = { [item_null] = mt_no_match, diff --git a/lib/errno_names.c b/lib/errno_names.c index 3c1ff23c..be3fda51 100644 --- a/lib/errno_names.c +++ b/lib/errno_names.c @@ -178,7 +178,9 @@ static const char* errno_name_table[] = ERRNO(ECOMM), /* Communication error on send */ #endif #ifdef EDEADLOCK +# ifndef EDEADLK ERRNO(EDEADLOCK), /* same as EDEADLK */ +# endif #endif #ifdef EDOTDOT ERRNO(EDOTDOT), /* RFS specific error */ @@ -530,9 +530,8 @@ void _zlog_assert_failed (const char *assertion, const char *file, unsigned int line, const char *function) { - const static size_t buff_size = 1024; - char buff[buff_size]; - snprintf(buff, buff_size, + char buff[1024]; + snprintf(buff, sizeof(buff), "Assertion `%s' failed in file %s, line %u, function %s", assertion, file, line, (function ? function : "?")); zlog_abort(buff); @@ -543,9 +542,9 @@ void _zlog_abort_mess (const char *mess, const char *file, unsigned int line, const char *function) { - const static size_t buff_size = 1024; - char buff[buff_size]; - snprintf(buff, buff_size, "%s, in file %s, line %u, function %s", + char buff[1024]; + snprintf(buff, sizeof(buff), + "%s, in file %s, line %u, function %s", mess, file, line, (function ? function : "?")); zlog_abort(buff); } @@ -563,9 +562,8 @@ void _zlog_abort_err (const char *mess, int err, const char *file, unsigned int line, const char *function) { - const static size_t buff_size = 1024; - char buff[buff_size]; - snprintf(buff, buff_size, + char buff[1024]; + snprintf(buff, sizeof(buff), "%s, in file %s, line %u, function %s, %s", mess, file, line, (function ? function : "?"), errtoa(err, 0).str); diff --git a/lib/log_local.h b/lib/log_local.h index d96f9f8b..b5e712d0 100644 --- a/lib/log_local.h +++ b/lib/log_local.h @@ -119,7 +119,7 @@ extern int log_assert_fail ; Inline void LOG_ASSERT_FAILED(void) { - if (log_assert_fail == 0) ; + if (log_assert_fail == 0) { log_assert_fail = 1 ; assert(0) ; diff --git a/lib/qpath.c b/lib/qpath.c index 955f307f..1a05e507 100644 --- a/lib/qpath.c +++ b/lib/qpath.c @@ -98,9 +98,9 @@ qpath_reset(qpath qp, free_keep_b free_structure) qs_reset(qp->path, keep_it) ; if (free_structure) - XFREE(MTYPE_QPATH, qp) ; /* sets qp = NULL */ + XFREE(MTYPE_QPATH, qp) ; /* sets qp = NULL */ else - ; + {;}; /* currently nothing else to do */ return qp ; } ; diff --git a/lib/qpath.h b/lib/qpath.h index 9b0509d7..dbd6da3a 100644 --- a/lib/qpath.h +++ b/lib/qpath.h @@ -75,7 +75,7 @@ Inline qpath qpath_free(qpath qp) ; Inline const char* qpath_string(qpath qp) ; Inline char* qpath_char_string(qpath qp) ; Inline ulen qpath_len(qpath qp) ; -Inline const qstring qpath_qs(qpath qp) ; +Inline qstring qpath_qs(qpath qp) ; extern qpath qpath_set(qpath dst, const char* src) ; extern qpath qpath_set_n(qpath dst, const char* src, ulen n) ; @@ -208,7 +208,7 @@ qpath_len(qpath qp) * * For a NULL qpath returns NULL qstring. */ -Inline const qstring +Inline qstring qpath_qs(qpath qp) { return (qp != NULL) ? qp->path : NULL ; diff --git a/lib/vty_local.h b/lib/vty_local.h index ed2c5ce4..212ab053 100644 --- a/lib/vty_local.h +++ b/lib/vty_local.h @@ -177,7 +177,7 @@ extern int vty_assert_fail ; Inline void VTY_ASSERT_FAILED(void) { - if (vty_assert_fail == 0) ; + if (vty_assert_fail == 0) { vty_assert_fail = 1 ; assert(0) ; diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 51933b76..9a8345df 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -14,9 +14,9 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #include <zebra.h> @@ -542,6 +542,8 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh, ospf6_lsa_delete (his); continue; break; + default: + break ; } if (ntohs (his->header->type) == OSPF6_LSTYPE_AS_EXTERNAL && @@ -764,6 +766,8 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh, ospf6_lsa_delete (his); continue; break; + default: + break ; } if (OSPF6_LSA_SCOPE (his->header->type) == OSPF6_SCOPE_AS && @@ -1078,6 +1082,8 @@ ospf6_lsack_recv (struct in6_addr *src, struct in6_addr *dst, ospf6_lsa_delete (his); continue; break; + default: + break ; } if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) @@ -1925,7 +1931,7 @@ ospf6_lsack_send_interface (struct thread *thread) return 0; } - + /* Commands */ DEFUN (debug_ospf6_message, debug_ospf6_message_cmd, @@ -1999,7 +2005,7 @@ ALIAS (debug_ospf6_message, "Debug only receiving message\n" ) - + DEFUN (no_debug_ospf6_message, no_debug_ospf6_message_cmd, "no debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)", diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 01da8808..410d59ac 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -8,12 +8,12 @@ * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. - * + * * GNU Zebra is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING. If not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -50,7 +50,7 @@ #include "ospfd/ospf_ase.h" #include "ospfd/ospf_zebra.h" #include "ospfd/ospf_dump.h" - + static struct ospf_area_range * ospf_area_range_new (struct prefix_ipv4 *p) { @@ -122,7 +122,7 @@ ospf_area_range_lookup (struct ospf_area *area, struct prefix_ipv4 *p) } struct ospf_area_range * -ospf_area_range_lookup_next (struct ospf_area *area, +ospf_area_range_lookup_next (struct ospf_area *area, struct in_addr *range_net, int first) { @@ -356,21 +356,21 @@ ospf_abr_nssa_am_elected (struct ospf_area *area) struct ospf_lsa *lsa; struct router_lsa *rlsa; struct in_addr *best = NULL; - + LSDB_LOOP ( ROUTER_LSDB (area), rn, lsa) { /* sanity checks */ - if (!lsa - || (lsa->data->type != OSPF_ROUTER_LSA) + if (!lsa + || (lsa->data->type != OSPF_ROUTER_LSA) || IS_LSA_SELF (lsa)) continue; - + rlsa = (struct router_lsa *) lsa->data; - + /* ignore non-ABR routers */ if (!IS_ROUTER_LSA_BORDER (rlsa)) continue; - + /* Router has Nt flag - always translate */ if (IS_ROUTER_LSA_NT (rlsa)) { @@ -380,21 +380,21 @@ ospf_abr_nssa_am_elected (struct ospf_area *area) inet_ntoa (lsa->data->id) ); return 0; } - + if (best == NULL) best = &lsa->data->id; else if ( IPV4_ADDR_CMP (&best, &lsa->data->id) < 0) best = &lsa->data->id; } - + if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_nssa_am_elected: best electable ABR is: %s", (best) ? inet_ntoa (*best) : "<none>" ); - + if (best == NULL) return 1; - + if ( IPV4_ADDR_CMP (&best, &area->ospf->router_id) < 0) return 1; else @@ -404,12 +404,12 @@ ospf_abr_nssa_am_elected (struct ospf_area *area) /* Check NSSA ABR status * assumes there are nssa areas */ -static void +static void ospf_abr_nssa_check_status (struct ospf *ospf) { struct ospf_area *area; struct listnode *lnode, *nnode; - + for (ALL_LIST_ELEMENTS (ospf->areas, lnode, nnode, area)) { u_char old_state = area->NSSATranslatorState; @@ -425,7 +425,7 @@ ospf_abr_nssa_check_status (struct ospf *ospf) if (!IS_OSPF_ABR (area->ospf)) { if (IS_DEBUG_OSPF (nssa, NSSA)) - zlog_debug ("ospf_abr_nssa_check_status: " + zlog_debug ("ospf_abr_nssa_check_status: " "not ABR"); area->NSSATranslatorState = OSPF_NSSA_TRANSLATE_DISABLED; } @@ -469,6 +469,8 @@ ospf_abr_nssa_check_status (struct ospf *ospf) zlog_debug ("ospf_abr_nssa_check_status: " "not elected"); } break; + default: + break ; } } /* RFC3101, 3.1: @@ -503,10 +505,10 @@ ospf_check_abr_status (struct ospf *ospf) for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) { - if (listcount (area->oiflist)) + if (listcount (area->oiflist)) { areas_configured++; - + if (OSPF_IS_AREA_BACKBONE (area)) bb_configured = 1; } @@ -514,7 +516,7 @@ ospf_check_abr_status (struct ospf *ospf) if (ospf_area_actively_attached (area)) { areas_act_attached++; - + if (OSPF_IS_AREA_BACKBONE (area)) bb_act_attached = 1; } @@ -630,7 +632,7 @@ ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost, static int ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) { - /* Incoming Type-7 or later aggregated Type-7 + /* Incoming Type-7 or later aggregated Type-7 * * LSA is skipped if P-bit is off. * LSA is aggregated if within range. @@ -638,7 +640,7 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) * The Type-7 is translated, Installed/Approved as a Type-5 into * global LSDB, then Flooded through AS * - * Later, any Unapproved Translated Type-5's are flushed/discarded + * Later, any Unapproved Translated Type-5's are flushed/discarded */ struct ospf_lsa *old = NULL, @@ -651,9 +653,9 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_translate_nssa(): LSA Id %s, P-bit off, NO Translation", inet_ntoa (lsa->data->id)); - return 1; + return 1; } - + if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_translate_nssa(): LSA Id %s, TRANSLATING 7 to 5", inet_ntoa (lsa->data->id)); @@ -661,7 +663,7 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) ext7 = (struct as_external_lsa *)(lsa->data); p.prefix = lsa->data->id; p.prefixlen = ip_masklen (ext7->mask); - + if (ext7->e[0].fwd_addr.s_addr == OSPF_DEFAULT_DESTINATION) { if (IS_DEBUG_OSPF_NSSA) @@ -670,7 +672,7 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) inet_ntoa (lsa->data->id)); return 1; } - + /* try find existing AS-External LSA for this prefix */ old = ospf_external_info_find_lsa (area->ospf, &p); @@ -678,10 +680,10 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) if (old) { if (IS_DEBUG_OSPF_NSSA) - zlog_debug ("ospf_abr_translate_nssa(): " + zlog_debug ("ospf_abr_translate_nssa(): " "found old translated LSA Id %s, refreshing", inet_ntoa (old->data->id)); - + /* refresh */ new = ospf_translated_nssa_refresh (area->ospf, lsa, old); if (!new) @@ -695,15 +697,15 @@ ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) else { /* no existing external route for this LSA Id - * originate translated LSA + * originate translated LSA */ - - if ((new = ospf_translated_nssa_originate (area->ospf, lsa)) + + if ((new = ospf_translated_nssa_originate (area->ospf, lsa)) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_translate_nssa(): Could not translate " - "Type-7 for %s to Type-5", + "Type-7 for %s to Type-5", inet_ntoa (lsa->data->id)); return 1; } @@ -733,7 +735,7 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_network_to_area(): Start"); - old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, + old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, (struct prefix_ipv4 *) p, area->ospf->router_id); if (old) @@ -747,13 +749,13 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, zlog_debug ("ospf_abr_announce_network_to_area(): " "old metric: %d, new metric: %d", GET_METRIC (sl->metric), cost); - + if (GET_METRIC (sl->metric) == cost) { /* unchanged. simply reapprove it */ if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_network_to_area(): " - "old summary approved"); + "old summary approved"); SET_FLAG (old->flags, OSPF_LSA_APPROVED); } else @@ -764,11 +766,11 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, "refreshing summary"); set_metric (old, cost); lsa = ospf_lsa_refresh (area->ospf, old); - + if (!lsa) { char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */ - + prefix2str ((struct prefix *) p, buf, sizeof(buf)); zlog_warn ("%s: Could not refresh %s to %s", __func__, @@ -776,7 +778,7 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, inet_ntoa (area->area_id)); return; } - + SET_FLAG (lsa->flags, OSPF_LSA_APPROVED); /* This will flood through area. */ } @@ -788,11 +790,11 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, "creating new summary"); lsa = ospf_summary_lsa_originate ( (struct prefix_ipv4 *)p, cost, area); /* This will flood through area. */ - + if (!lsa) { char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */ - + prefix2str ((struct prefix *)p, buf, sizeof(buf)); zlog_warn ("%s: Could not originate %s to %s", __func__, @@ -800,7 +802,7 @@ ospf_abr_announce_network_to_area (struct prefix_ipv4 *p, u_int32_t cost, inet_ntoa (area->area_id)); return; } - + SET_FLAG (lsa->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_network_to_area(): " @@ -886,7 +888,7 @@ ospf_abr_announce_network (struct ospf *ospf, if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_network(): Start"); - or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id); + or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id); assert (or_area); for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) @@ -907,7 +909,7 @@ ospf_abr_announce_network (struct ospf *ospf, zlog_debug ("ospf_abr_announce_network(): " "prefix %s/%d was denied by import-list", inet_ntoa (p->prefix), p->prefixlen); - continue; + continue; } if (!ospf_abr_plist_in_check (area, or, p)) @@ -916,7 +918,7 @@ ospf_abr_announce_network (struct ospf *ospf, zlog_debug ("ospf_abr_announce_network(): " "prefix %s/%d was denied by prefix-list", inet_ntoa (p->prefix), p->prefixlen); - continue; + continue; } if (area->external_routing != OSPF_AREA_DEFAULT && area->no_summary) @@ -945,7 +947,7 @@ ospf_abr_announce_network (struct ospf *ospf, zlog_debug ("ospf_abr_announce_network(): " "this is intra-area route to %s/%d", inet_ntoa (p->prefix), p->prefixlen); - if ((range = ospf_area_range_match (or_area, p)) + if ((range = ospf_area_range_match (or_area, p)) && !ospf_area_is_transit (area)) ospf_abr_update_aggregate (range, or); else @@ -963,7 +965,7 @@ ospf_abr_should_announce (struct ospf *ospf, area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id); assert (area); - + if (EXPORT_NAME (area)) { if (EXPORT_LIST (area) == NULL) @@ -998,18 +1000,18 @@ ospf_abr_process_nssa_translates (struct ospf *ospf) { if (! area->NSSATranslatorState) continue; /* skip if not translator */ - + if (area->external_routing != OSPF_AREA_NSSA) continue; /* skip if not Nssa Area */ if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_process_nssa_translates(): " "looking at area %s", inet_ntoa (area->area_id)); - + LSDB_LOOP (NSSA_LSDB (area), rn, lsa) ospf_abr_translate_nssa (area, lsa); } - + if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_process_nssa_translates(): Stop"); @@ -1147,9 +1149,9 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost, { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_rtr_to_area(): 2.2"); - - if (old) - { + + if (old) + { set_metric (old, cost); lsa = ospf_lsa_refresh (area->ospf, old); } @@ -1158,7 +1160,7 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost, if (!lsa) { char buf[INET_ADDRSTRLEN + 3]; /* ipv4 and /XX */ - + prefix2str ((struct prefix *)p, buf, sizeof(buf)); zlog_warn ("%s: Could not refresh/originate %s to %s", __func__, @@ -1166,7 +1168,7 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost, inet_ntoa (area->area_id)); return; } - + if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_announce_rtr_to_area(): " "flooding new version of summary"); @@ -1287,10 +1289,10 @@ ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt) (struct prefix_ipv4 *) &rn->p); flag = 1; } - + if (best == NULL) continue; - + if (or != best) { if (IS_DEBUG_OSPF_EVENT) @@ -1298,7 +1300,7 @@ ospf_abr_process_router_rt (struct ospf *ospf, struct route_table *rt) "This route is not the best among possible, skipping"); continue; } - + if (or->path_type == OSPF_PATH_INTER_AREA && !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) { @@ -1379,14 +1381,14 @@ ospf_abr_unapprove_summaries (struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_unapprove_summaries(): " "considering area %s", - inet_ntoa (area->area_id)); + inet_ntoa (area->area_id)); LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa) if (ospf_lsa_is_self_originated (ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_unapprove_summaries(): " "approved unset on summary link id %s", - inet_ntoa (lsa->data->id)); + inet_ntoa (lsa->data->id)); UNSET_FLAG (lsa->flags, OSPF_LSA_APPROVED); } @@ -1499,7 +1501,7 @@ ospf_abr_announce_aggregates (struct ospf *ospf) zlog_debug ("ospf_abr_announce_aggregates(): Skipping " "announcement of BB aggregate into" " a transit area"); - continue; + continue; } ospf_abr_announce_network_to_area ((struct prefix_ipv4 *)&p, range->cost, ar); } @@ -1693,7 +1695,7 @@ ospf_abr_remove_unapproved_translates (struct ospf *ospf) LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa) ospf_abr_remove_unapproved_translates_apply (ospf, lsa); - + if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_remove_unapproved_translates(): Stop"); } @@ -1725,7 +1727,7 @@ ospf_abr_remove_unapproved_summaries (struct ospf *ospf) if (!CHECK_FLAG (lsa->flags, OSPF_LSA_APPROVED)) ospf_lsa_flush_area (lsa, area); } - + if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_abr_remove_unapproved_summaries(): Stop"); } @@ -1805,7 +1807,7 @@ ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */ /* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or * Aggregate as Type-7 - * Install or Approve in Type-5 Global LSDB + * Install or Approve in Type-5 Global LSDB */ if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_nssa_task(): process translates"); @@ -1814,19 +1816,19 @@ ospf_abr_nssa_task (struct ospf *ospf) /* called only if any_nssa */ /* Translate/Send any "ranged" aggregates, and also 5-Install and * Approve * Scan Type-7's for aggregates, translate to Type-5's, - * Install/Flood/Approve + * Install/Flood/Approve */ if (IS_DEBUG_OSPF_NSSA) zlog_debug("ospf_abr_nssa_task(): send NSSA aggregates"); ospf_abr_send_nssa_aggregates (ospf); /*TURNED OFF FOR NOW */ - /* Send any NSSA defaults as Type-5 + /* Send any NSSA defaults as Type-5 *if (IS_DEBUG_OSPF_NSSA) * zlog_debug ("ospf_abr_nssa_task(): announce nssa defaults"); *ospf_abr_announce_nssa_defaults (ospf); * havnt a clue what above is supposed to do. */ - + /* Flush any unapproved previous translates from Global Data Base */ if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_abr_nssa_task(): remove unapproved translates"); diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index a964e690..73ac7d98 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -106,7 +106,7 @@ ospf_apiserver_if_lookup_by_ifp (struct interface *ifp) struct ospf_interface *oi; struct ospf *ospf; - if (!(ospf = ospf_lookup ())); + if ((ospf = ospf_lookup ()) == NULL) return NULL; for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi)) @@ -332,6 +332,8 @@ ospf_apiserver_event (enum event event, int fd, thread_add_write (master, ospf_apiserver_async_write, apiserv, fd); } break; + default: + break ; } } @@ -1049,6 +1051,8 @@ ospf_apiserver_handle_register_opaque_type (struct ospf_apiserver *apiserv, case OSPF_OPAQUE_AS_LSA: ospf_apiserver_notify_ready_type11 (apiserv); break; + default: + break ; } out: return rc; @@ -1754,6 +1758,8 @@ ospf_apiserver_flood_opaque_lsa (struct ospf_lsa *lsa) /* Flood LSA through AS. */ ospf_flood_through_as (ospf, NULL /*nbr */ , lsa); break; + default: + break ; } } } 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 () { diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index db53882d..558c7586 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -1,6 +1,6 @@ /* * OSPF version 2 Interface State Machine - * From RFC2328 [OSPF Version 2] + * From RFC2328 [OSPF Version 2] * Copyright (C) 1999, 2000 Toshiaki Takada * * This file is part of GNU Zebra. @@ -44,7 +44,7 @@ #include "ospfd/ospf_flood.h" #include "ospfd/ospf_abr.h" #include "ospfd/ospf_snmp.h" - + /* elect DR and BDR. Refer to RFC2319 section 9.4 */ static struct ospf_neighbor * ospf_dr_election_sub (struct list *routers) @@ -228,7 +228,7 @@ ospf_dr_election (struct ospf_interface *oi) !(new_state == ISM_DROther && old_state < ISM_DROther)) { ospf_elect_bdr (oi, el_list); - ospf_elect_dr (oi, el_list); + ospf_elect_dr (oi, el_list); new_state = ospf_ism_state (oi); @@ -246,7 +246,7 @@ ospf_dr_election (struct ospf_interface *oi) return new_state; } - + int ospf_hello_timer (struct thread *thread) { @@ -264,7 +264,7 @@ ospf_hello_timer (struct thread *thread) /* Hello timer set. */ OSPF_HELLO_TIMER_ON (oi); - + return 0; } @@ -322,7 +322,7 @@ ism_timer_set (struct ospf_interface *oi) virtual link. The router attempts to form an adjacency with neighboring router. Hello packets are also sent. */ /* send first hello immediately */ - OSPF_ISM_TIMER_MSEC_ON (oi->t_hello, ospf_hello_timer, 1); + OSPF_ISM_TIMER_MSEC_ON (oi->t_hello, ospf_hello_timer, 1); OSPF_ISM_TIMER_OFF (oi->t_wait); OSPF_ISM_TIMER_ON (oi->t_ls_ack, ospf_ls_ack_timer, oi->v_ls_ack); break; @@ -348,6 +348,8 @@ ism_timer_set (struct ospf_interface *oi) OSPF_ISM_TIMER_OFF (oi->t_wait); OSPF_ISM_TIMER_ON (oi->t_ls_ack, ospf_ls_ack_timer, oi->v_ls_ack); break; + default: + break ; } } @@ -518,7 +520,7 @@ struct { { ism_ignore, ISM_DR }, /* UnloopInd */ { ism_interface_down, ISM_Down }, /* InterfaceDown */ }, -}; +}; static const char *ospf_ism_event_str[] = { @@ -549,7 +551,7 @@ ism_change_state (struct ospf_interface *oi, int state) oi->state_change++; #ifdef HAVE_SNMP - /* Terminal state or regression */ + /* Terminal state or regression */ if ((state == ISM_DR) || (state == ISM_Backup) || (state == ISM_DROther) || (state == ISM_PointToPoint) || (state < old_state)) { diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 842df49c..45087de9 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -50,7 +50,7 @@ #include "ospfd/ospf_ase.h" #include "ospfd/ospf_zebra.h" - + u_int32_t get_metric (u_char *metric) { @@ -61,7 +61,7 @@ get_metric (u_char *metric) return m; } - + struct timeval tv_adjust (struct timeval a) { @@ -159,22 +159,22 @@ ospf_lsa_refresh_delay (struct ospf_lsa *lsa) return delay; } - + int get_age (struct ospf_lsa *lsa) { int age; - age = ntohs (lsa->data->ls_age) + age = ntohs (lsa->data->ls_age) + tv_floor (tv_sub (recent_relative_time (), lsa->tv_recv)); return age; } - + /* Fletcher Checksum -- Refer to RFC1008. */ -/* All the offsets are zero-based. The offsets in the RFC1008 are +/* All the offsets are zero-based. The offsets in the RFC1008 are one-based. */ u_int16_t ospf_lsa_checksum (struct lsa_header *lsa) @@ -183,7 +183,7 @@ ospf_lsa_checksum (struct lsa_header *lsa) int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */ /* Skip the AGE field */ - u_int16_t len = ntohs(lsa->length) - options_offset; + u_int16_t len = ntohs(lsa->length) - options_offset; /* Checksum offset starts from "options" field, not the beginning of the lsa_header struct. The offset is 14, rather than 16. */ @@ -193,7 +193,7 @@ ospf_lsa_checksum (struct lsa_header *lsa) } - + /* Create OSPF LSA. */ struct ospf_lsa * ospf_lsa_new () @@ -208,7 +208,7 @@ ospf_lsa_new () new->tv_recv = recent_relative_time (); new->tv_orig = new->tv_recv; new->refresh_list = -1; - + return new; } @@ -246,7 +246,7 @@ void ospf_lsa_free (struct ospf_lsa *lsa) { assert (lsa->lock == 0); - + if (IS_DEBUG_OSPF (lsa, LSA)) zlog_debug ("LSA: freed %p", lsa); @@ -256,7 +256,7 @@ ospf_lsa_free (struct ospf_lsa *lsa) assert (lsa->refresh_list < 0); - memset (lsa, 0, sizeof (struct ospf_lsa)); + memset (lsa, 0, sizeof (struct ospf_lsa)); XFREE (MTYPE_OSPF_LSA, lsa); } @@ -275,7 +275,7 @@ ospf_lsa_unlock (struct ospf_lsa **lsa) /* This is sanity check. */ if (!lsa || !*lsa) return; - + (*lsa)->lock--; assert ((*lsa)->lock >= 0); @@ -329,7 +329,7 @@ ospf_lsa_data_free (struct lsa_header *lsah) XFREE (MTYPE_OSPF_LSA_DATA, lsah); } - + /* LSA general functions. */ const char * @@ -381,7 +381,7 @@ lsa_header_set (struct stream *s, u_char options, stream_forward_endp (s, OSPF_LSA_HEADER_SIZE); } - + /* router-LSA related functions. */ /* Get router-LSA flags. */ @@ -419,7 +419,7 @@ router_lsa_flags (struct ospf_area *area) if (IS_OSPF_ABR (area->ospf)) { SET_FLAG (flags, ROUTER_LSA_BORDER); - /* If Area is NSSA and we are both ABR and unconditional translator, + /* If Area is NSSA and we are both ABR and unconditional translator, * set Nt bit to inform other routers. */ if ( (area->external_routing == OSPF_AREA_NSSA) @@ -480,7 +480,7 @@ link_info_set (struct stream *s, struct in_addr id, if (STREAM_WRITEABLE(s) < OSPF_ROUTER_LSA_LINK_SIZE) { size_t ret = OSPF_MAX_LSA_SIZE; - + /* Can we enlarge the stream still? */ if (STREAM_SIZE(s) == OSPF_MAX_LSA_SIZE) { @@ -495,7 +495,7 @@ link_info_set (struct stream *s, struct in_addr id, */ ret = stream_resize (s, OSPF_MAX_PACKET_SIZE - OSPF_MAX_LSA_SIZE); } - + if (ret == OSPF_MAX_LSA_SIZE) { zlog_warn ("%s: Out of space in LSA stream, left %zd, size %zd", @@ -503,14 +503,14 @@ link_info_set (struct stream *s, struct in_addr id, return 0; } } - + /* TOS based routing is not supported. */ stream_put_ipv4 (s, id.s_addr); /* Link ID. */ stream_put_ipv4 (s, data.s_addr); /* Link Data. */ stream_putc (s, type); /* Link Type. */ stream_putc (s, tos); /* TOS = 0. */ stream_putw (s, cost); /* Link Cost. */ - + return 1; } @@ -552,7 +552,7 @@ lsa_link_broadcast_set (struct stream *s, struct ospf_interface *oi) struct ospf_neighbor *dr; struct in_addr id, mask; u_int16_t cost = ospf_link_cost (oi); - + /* Describe Type 3 Link. */ if (oi->state == ISM_Waiting) { @@ -585,7 +585,7 @@ static int lsa_link_loopback_set (struct stream *s, struct ospf_interface *oi) { struct in_addr id, mask; - + /* Describe Type 3 Link. */ if (oi->state != ISM_Loopback) return 0; @@ -615,7 +615,7 @@ lsa_link_virtuallink_set (struct stream *s, struct ospf_interface *oi) #define lsa_link_nbma_set(S,O) lsa_link_broadcast_set (S, O) -/* this function add for support point-to-multipoint ,see rfc2328 +/* this function add for support point-to-multipoint ,see rfc2328 12.4.1.4.*/ /* from "edward rrr" <edward_rrr@hotmail.com> http://marc.theaimsgroup.com/?l=zebra&m=100739222210507&w=2 */ @@ -649,7 +649,7 @@ lsa_link_ptomp_set (struct stream *s, struct ospf_interface *oi) zlog_debug ("PointToMultipoint: set link to %s", inet_ntoa(oi->address->u.prefix4)); } - + return links; } @@ -689,7 +689,9 @@ router_lsa_link_set (struct stream *s, struct ospf_area *area) links += lsa_link_virtuallink_set (s, oi); break; case OSPF_IFTYPE_LOOPBACK: - links += lsa_link_loopback_set (s, oi); + links += lsa_link_loopback_set (s, oi); + default: + break ; } } } @@ -723,26 +725,26 @@ ospf_router_lsa_body_set (struct stream *s, struct ospf_area *area) /* Set # of links here. */ stream_putw_at (s, putp, cnt); } - + static int ospf_stub_router_timer (struct thread *t) { struct ospf_area *area = THREAD_ARG (t); - + area->t_stub_router = NULL; - + SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); - + /* clear stub route state and generate router-lsa refresh, don't * clobber an administratively set stub-router state though. */ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) return 0; - + UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); - + ospf_router_lsa_update_area (area); - + return 0; } @@ -758,13 +760,13 @@ ospf_stub_router_check (struct ospf_area *area) SET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); return; } - + /* not admin-stubbed, check whether startup stubbing is configured and * whether it's not been done yet */ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED)) return; - + if (area->ospf->stub_router_startup_time == OSPF_STUB_ROUTER_UNCONFIGURED) { /* stub-router is hence done forever for this area, even if someone @@ -773,14 +775,14 @@ ospf_stub_router_check (struct ospf_area *area) SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); return; } - + /* startup stub-router configured and not yet done */ SET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); - + OSPF_AREA_TIMER_ON (area->t_stub_router, ospf_stub_router_timer, area->ospf->stub_router_startup_time); } - + /* Create new router-LSA. */ static struct ospf_lsa * ospf_router_lsa_new (struct ospf_area *area) @@ -794,11 +796,11 @@ ospf_router_lsa_new (struct ospf_area *area) if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) zlog_debug ("LSA[Type1]: Create router-LSA instance"); - /* check whether stub-router is desired, and if this is the first + /* check whether stub-router is desired, and if this is the first * router LSA. */ ospf_stub_router_check (area); - + /* Create a stream for LSA. */ s = stream_new (OSPF_MAX_LSA_SIZE); /* Set LSA common header fields. */ @@ -819,7 +821,7 @@ ospf_router_lsa_new (struct ospf_area *area) zlog_err ("%s: Unable to create new lsa", __func__); return NULL; } - + new->area = area; SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED); @@ -836,7 +838,7 @@ static struct ospf_lsa * ospf_router_lsa_originate (struct ospf_area *area) { struct ospf_lsa *new; - + /* Create new router-LSA instance. */ if ( (new = ospf_router_lsa_new (area)) == NULL) { @@ -887,14 +889,14 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa) /* Unregister LSA from refresh-list */ ospf_refresher_unregister_lsa (area->ospf, lsa); - + /* Create new router-LSA instance. */ if ( (new = ospf_router_lsa_new (area)) == NULL) { zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__); return NULL; } - + new->data->ls_seqnum = lsa_seqnum_increment (lsa); ospf_lsa_install (area->ospf, NULL, new); @@ -982,7 +984,7 @@ ospf_router_lsa_update (struct ospf *ospf) return 0; } - + /* network-LSA related functions. */ /* Originate Network-LSA. */ static void @@ -1019,7 +1021,7 @@ ospf_network_lsa_new (struct ospf_interface *oi) the router does not originate network-LSA (see RFC 12.4.2) */ if (oi->full_nbrs == 0) return NULL; - + if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) zlog_debug ("LSA[Type2]: Create network-LSA instance"); @@ -1043,7 +1045,7 @@ ospf_network_lsa_new (struct ospf_interface *oi) zlog_err ("%s: ospf_lsa_new returned NULL", __func__); return NULL; } - + new->area = oi->area; SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED); @@ -1051,7 +1053,7 @@ ospf_network_lsa_new (struct ospf_interface *oi) new->data = ospf_lsa_data_new (length); memcpy (new->data, lsah, length); stream_free (s); - + /* Remember prior network LSA sequence numbers, even if we stop * originating one for this oi, to try avoid re-originating LSAs with a * prior sequence number, and thus speed up adjency forming & convergence. @@ -1067,7 +1069,7 @@ ospf_network_lsa_new (struct ospf_interface *oi) ospf_if_update_params (oi->ifp, oi->address->u.prefix4); } oip->network_lsa_seqnum = new->data->ls_seqnum; - + return new; } @@ -1076,13 +1078,13 @@ void ospf_network_lsa_update (struct ospf_interface *oi) { struct ospf_lsa *new; - + if (oi->network_lsa_self != NULL) { ospf_lsa_refresh (oi->ospf, oi->network_lsa_self); return; } - + /* Create new network-LSA instance. */ new = ospf_network_lsa_new (oi); if (new == NULL) @@ -1114,9 +1116,9 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa) struct ospf_lsa *new, *new2; struct ospf_if_params *oip; struct ospf_interface *oi; - + assert (lsa->data); - + /* Retrieve the oi for the network LSA */ oi = ospf_if_lookup_by_local_addr (area->ospf, NULL, lsa->data->id); if (oi == NULL) @@ -1135,20 +1137,20 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa) /* Unregister LSA from refresh-list */ ospf_refresher_unregister_lsa (area->ospf, lsa); - + /* Create new network-LSA instance. */ new = ospf_network_lsa_new (oi); if (new == NULL) return NULL; - + oip = ospf_lookup_if_params (oi->ifp, oi->address->u.prefix4); assert (oip != NULL); oip->network_lsa_seqnum = new->data->ls_seqnum = lsa_seqnum_increment (lsa); new2 = ospf_lsa_install (area->ospf, oi, new); - + assert (new2 == new); - + /* Flood LSA through aera. */ ospf_flood_through_area (area, NULL, new); @@ -1161,7 +1163,7 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa) return new; } - + static void stream_put_ospf_metric (struct stream *s, u_int32_t metric_value) { @@ -1244,12 +1246,12 @@ ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p, /* Originate Summary-LSA. */ struct ospf_lsa * -ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, +ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, struct ospf_area *area) { struct ospf_lsa *new; struct in_addr id; - + id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_SUMMARY_LSA, p); if (id.s_addr == 0xffffffff) @@ -1260,7 +1262,7 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, OSPF_SUMMARY_LSA); return NULL; } - + /* Create new summary-LSA instance. */ if ( !(new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id))) return NULL; @@ -1290,7 +1292,7 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) struct ospf_lsa *new; struct summary_lsa *sl; struct prefix p; - + /* Sanity check. */ assert (lsa->data); @@ -1298,14 +1300,14 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) p.prefixlen = ip_masklen (sl->mask); new = ospf_summary_lsa_new (lsa->area, &p, GET_METRIC (sl->metric), sl->header.id); - + if (!new) return NULL; - + new->data->ls_seqnum = lsa_seqnum_increment (lsa); ospf_lsa_install (ospf, NULL, new); - + /* Flood LSA through AS. */ ospf_flood_through_area (new->area, NULL, new); @@ -1316,11 +1318,11 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) new->data->type, inet_ntoa (new->data->id)); ospf_lsa_header_dump (new->data); } - + return new; } - + /* summary-ASBR-LSA related functions. */ static void ospf_summary_asbr_lsa_body_set (struct stream *s, struct prefix *p, @@ -1390,12 +1392,12 @@ ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p, /* Originate summary-ASBR-LSA. */ struct ospf_lsa * -ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, +ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, struct ospf_area *area) { struct ospf_lsa *new; struct in_addr id; - + id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_ASBR_SUMMARY_LSA, p); if (id.s_addr == 0xffffffff) @@ -1406,7 +1408,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, OSPF_ASBR_SUMMARY_LSA); return NULL; } - + /* Create new summary-LSA instance. */ new = ospf_summary_asbr_lsa_new (area, (struct prefix *) p, metric, id); if (!new) @@ -1414,7 +1416,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric, /* Install LSA to LSDB. */ new = ospf_lsa_install (area->ospf, NULL, new); - + /* Update LSA origination count. */ area->ospf->lsa_originate_count++; @@ -1447,11 +1449,11 @@ ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) sl->header.id); if (!new) return NULL; - + new->data->ls_seqnum = lsa_seqnum_increment (lsa); ospf_lsa_install (ospf, NULL, new); - + /* Flood LSA through area. */ ospf_flood_through_area (new->area, NULL, new); @@ -1486,7 +1488,7 @@ ospf_external_lsa_nexthop_get (struct ospf *ospf, struct in_addr nexthop) nh.family = AF_INET; nh.u.prefix4 = nexthop; nh.prefixlen = IPV4_MAX_BITLEN; - + /* XXX/SCALE: If there were a lot of oi's on an ifp, then it'd be * better to make use of the per-ifp table of ois. */ @@ -1512,7 +1514,7 @@ ospf_get_ip_from_ifp (struct ospf_interface *oi) if (if_is_operative (oi->ifp)) return oi->address->u.prefix4; - + return fwd; } @@ -1600,7 +1602,7 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei, /* If prefix is default, specify DEFAULT_ROUTE. */ type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type; - + mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ? ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type); @@ -1612,13 +1614,13 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei, /* Put 0 metric. TOS metric is not supported. */ stream_put_ospf_metric (s, mvalue); - + /* Get forwarding address to nexthop if on the Connection List, else 0. */ fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop); /* Put forwarding address. */ stream_put_ipv4 (s, fwd_addr.s_addr); - + /* Put route tag -- This value should be introduced from configuration. */ stream_putl (s, 0); } @@ -1690,7 +1692,7 @@ ospf_external_lsa_new (struct ospf *ospf, /* As Type-7 */ static void -ospf_install_flood_nssa (struct ospf *ospf, +ospf_install_flood_nssa (struct ospf *ospf, struct ospf_lsa *lsa, struct external_info *ei) { struct ospf_lsa *new; @@ -1699,12 +1701,12 @@ ospf_install_flood_nssa (struct ospf *ospf, struct listnode *node, *nnode; /* LSA may be a Type-5 originated via translation of a Type-7 LSA - * which originated from an NSSA area. In which case it should not be + * which originated from an NSSA area. In which case it should not be * flooded back to NSSA areas. */ if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) return; - + /* NSSA Originate or Refresh (If anyNSSA) LSA is self-originated. And just installed as Type-5. @@ -1735,11 +1737,11 @@ ospf_install_flood_nssa (struct ospf *ospf, if (! IS_OSPF_ABR (ospf)) { SET_FLAG(new->data->options, OSPF_OPTION_NP); - + /* set non-zero FWD ADDR - + draft-ietf-ospf-nssa-update-09.txt - + if the network between the NSSA AS boundary router and the adjacent AS is advertised into OSPF as an internal OSPF route, the forwarding address should be the next op address as is cu @@ -1750,14 +1752,14 @@ ospf_install_flood_nssa (struct ospf *ospf, which belong to the NSSA. If no such addresses exist, then no type-7 LSA's with the P-bit set should originate from this router. */ - + /* kevinm: not updating lsa anymore, just new */ extlsa = (struct as_external_lsa *)(new->data); - + if (extlsa->e[0].fwd_addr.s_addr == 0) extlsa->e[0].fwd_addr = ospf_get_nssa_ip(area); /* this NSSA area in ifp */ - if (extlsa->e[0].fwd_addr.s_addr == 0) + if (extlsa->e[0].fwd_addr.s_addr == 0) { if (IS_DEBUG_OSPF_NSSA) zlog_debug ("LSA[Type-7]: Could not build FWD-ADDR"); @@ -1775,17 +1777,17 @@ ospf_install_flood_nssa (struct ospf *ospf, } static struct ospf_lsa * -ospf_lsa_translated_nssa_new (struct ospf *ospf, +ospf_lsa_translated_nssa_new (struct ospf *ospf, struct ospf_lsa *type7) { struct ospf_lsa *new; struct as_external_lsa *ext, *extnew; struct external_info ei; - + ext = (struct as_external_lsa *)(type7->data); - /* need external_info struct, fill in bare minimum */ + /* need external_info struct, fill in bare minimum */ ei.p.family = AF_INET; ei.p.prefix = type7->data->id; ei.p.prefixlen = ip_masklen (ext->mask); @@ -1794,18 +1796,18 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf, ei.route_map_set.metric = -1; ei.route_map_set.metric_type = -1; ei.tag = 0; - + if ( (new = ospf_external_lsa_new (ospf, &ei, &type7->data->id)) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_nssa_translate_originate(): Could not originate " - "Translated Type-5 for %s", + "Translated Type-5 for %s", inet_ntoa (ei.p.prefix)); return NULL; } extnew = (struct as_external_lsa *)(new->data); - + /* copy over Type-7 data to new */ extnew->e[0].tos = ext->e[0].tos; extnew->e[0].route_tag = ext->e[0].route_tag; @@ -1813,10 +1815,10 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf, new->data->ls_seqnum = type7->data->ls_seqnum; /* add translated flag, checksum and lock new lsa */ - SET_FLAG (new->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */ + SET_FLAG (new->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */ new = ospf_lsa_lock (new); - - return new; + + return new; } /* Originate Translated Type-5 for supplied Type-7 NSSA LSA */ @@ -1825,11 +1827,11 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7) { struct ospf_lsa *new; struct as_external_lsa *extnew; - + /* we cant use ospf_external_lsa_originate() as we need to set * the OSPF_LSA_LOCAL_XLT flag, must originate by hand */ - + if ( (new = ospf_lsa_translated_nssa_new (ospf, type7)) == NULL) { if (IS_DEBUG_OSPF_NSSA) @@ -1838,9 +1840,9 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7) inet_ntoa (type7->data->id)); return NULL; } - + extnew = (struct as_external_lsa *)new; - + if (IS_DEBUG_OSPF_NSSA) { zlog_debug ("ospf_translated_nssa_originate(): " @@ -1849,16 +1851,16 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7) zlog_debug (" Network mask: %d",ip_masklen (extnew->mask)); zlog_debug (" Forward addr: %s", inet_ntoa (extnew->e[0].fwd_addr)); } - + if ( (new = ospf_lsa_install (ospf, NULL, new)) == NULL) { - if (IS_DEBUG_OSPF_NSSA); + if (IS_DEBUG_OSPF_NSSA) zlog_debug ("ospf_lsa_translated_nssa_originate(): " "Could not install LSA " "id %s", inet_ntoa (type7->data->id)); return NULL; } - + ospf->lsa_originate_count++; ospf_flood_through_as (ospf, NULL, new); @@ -1867,11 +1869,11 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7) /* Refresh Translated from NSSA AS-external-LSA. */ struct ospf_lsa * -ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, +ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, struct ospf_lsa *type5) { struct ospf_lsa *new = NULL; - + /* Sanity checks. */ assert (type7 || type5); if (!(type7 || type5)) @@ -1887,8 +1889,8 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, { /* find the translated Type-5 for this Type-7 */ struct as_external_lsa *ext = (struct as_external_lsa *)(type7->data); - struct prefix_ipv4 p = - { + struct prefix_ipv4 p = + { .prefix = type7->data->id, .prefixlen = ip_masklen (ext->mask), .family = AF_INET, @@ -1905,13 +1907,13 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, struct route_node *rn; struct ospf_lsa *lsa; struct ospf_area *area; - + for (ALL_LIST_ELEMENTS (ospf->areas, ln, lnn, area)) { - if (area->external_routing != OSPF_AREA_NSSA + if (area->external_routing != OSPF_AREA_NSSA && !type7) continue; - + LSDB_LOOP (NSSA_LSDB(area), rn, lsa) { if (lsa->data->id.s_addr == type5->data->id.s_addr) @@ -1945,7 +1947,7 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, /* Delete LSA from neighbor retransmit-list. */ ospf_ls_retransmit_delete_nbr_as (ospf, type5); - + /* create new translated LSA */ if ( (new = ospf_lsa_translated_nssa_new (ospf, type7)) == NULL) { @@ -1964,7 +1966,7 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7, inet_ntoa (type7->data->id)); return NULL; } - + /* Flood LSA through area. */ ospf_flood_through_as (ospf, NULL, new); @@ -2023,11 +2025,11 @@ ospf_external_lsa_originate (struct ospf *ospf, struct external_info *ei) flushed from the AS. */ - + /* Check the AS-external-LSA should be originated. */ if (!ospf_redistribute_check (ospf, ei, NULL)) return NULL; - + /* Create new AS-external-LSA instance. */ if ((new = ospf_external_lsa_new (ospf, ei, NULL)) == NULL) { @@ -2082,7 +2084,7 @@ ospf_external_lsa_originate_timer (struct thread *thread) if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p)) if (!ospf_external_lsa_originate (ospf, ei)) zlog_warn ("LSA: AS-external-LSA was not originated."); - + return 0; } @@ -2092,7 +2094,7 @@ ospf_default_external_info (struct ospf *ospf) int type; struct route_node *rn; struct prefix_ipv4 p; - + p.family = AF_INET; p.prefix.s_addr = 0; p.prefixlen = 0; @@ -2121,7 +2123,7 @@ ospf_default_originate_timer (struct thread *thread) struct in_addr nexthop; struct external_info *ei; struct ospf *ospf; - + ospf = THREAD_ARG (thread); p.family = AF_INET; @@ -2138,7 +2140,7 @@ ospf_default_originate_timer (struct thread *thread) if ((ei = ospf_default_external_info (ospf))) ospf_external_lsa_originate (ospf, ei); - + return 0; } @@ -2155,15 +2157,15 @@ ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p) if (area->external_routing == OSPF_AREA_NSSA) { if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix, - ospf->router_id))) + ospf->router_id))) { - if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) + if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) zlog_debug ("LSA: There is no such AS-NSSA-LSA %s/%d in LSDB", inet_ntoa (p->prefix), p->prefixlen); continue; } ospf_ls_retransmit_delete_nbr_area (area, lsa); - if (!IS_LSA_MAXAGE (lsa)) + if (!IS_LSA_MAXAGE (lsa)) { ospf_refresher_unregister_lsa (ospf, lsa); ospf_lsa_flush_area (lsa, area); @@ -2193,8 +2195,8 @@ ospf_external_lsa_flush (struct ospf *ospf, return; } - /* If LSA is selforiginated, not a translated LSA, and there is - * NSSA area, flush Type-7 LSA's at first. + /* If LSA is selforiginated, not a translated LSA, and there is + * NSSA area, flush Type-7 LSA's at first. */ if (IS_LSA_SELF(lsa) && (ospf->anyNSSA) && !(CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))) @@ -2292,13 +2294,13 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, { struct ospf_lsa *new; int changed; - + /* Check the AS-external-LSA should be originated. */ if (!ospf_redistribute_check (ospf, ei, &changed)) { if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) zlog_debug ("LSA[Type%d:%s]: Could not be refreshed, " - "redist check fail", + "redist check fail", lsa->data->type, inet_ntoa (lsa->data->id)); ospf_external_lsa_flush (ospf, ei->type, &ei->p, ei->ifindex /*, ei->nexthop */); @@ -2320,7 +2322,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, ospf_refresher_unregister_lsa (ospf, lsa); new = ospf_external_lsa_new (ospf, ei, &lsa->data->id); - + if (new == NULL) { if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) @@ -2328,7 +2330,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, inet_ntoa (lsa->data->id)); return NULL; } - + new->data->ls_seqnum = lsa_seqnum_increment (lsa); ospf_lsa_install (ospf, NULL, new); /* As type-5. */ @@ -2340,8 +2342,8 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, if (ospf->anyNSSA && !(CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT))) ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood per new rules */ - /* Register self-originated LSA to refresh queue. - * Translated LSAs should not be registered, but refreshed upon + /* Register self-originated LSA to refresh queue. + * Translated LSAs should not be registered, but refreshed upon * refresh of the Type-7 */ if ( !CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT) ) @@ -2358,7 +2360,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa, return new; } - + /* LSA installation functions. */ /* Install router-LSA to an area. */ @@ -2371,7 +2373,7 @@ ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new, /* RFC 2328 Section 13.2 Router-LSAs and network-LSAs The entire routing table must be recalculated, starting with the shortest path calculations for each area (not just the - area whose link-state database has changed). + area whose link-state database has changed). */ if (IS_LSA_SELF (new)) @@ -2402,7 +2404,7 @@ ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new, /* Install network-LSA to an area. */ static struct ospf_lsa * ospf_network_lsa_install (struct ospf *ospf, - struct ospf_interface *oi, + struct ospf_interface *oi, struct ospf_lsa *new, int rt_recalc) { @@ -2410,7 +2412,7 @@ ospf_network_lsa_install (struct ospf *ospf, /* RFC 2328 Section 13.2 Router-LSAs and network-LSAs The entire routing table must be recalculated, starting with the shortest path calculations for each area (not just the - area whose link-state database has changed). + area whose link-state database has changed). */ if (IS_LSA_SELF (new)) { @@ -2450,7 +2452,7 @@ ospf_summary_lsa_install (struct ospf *ospf, struct ospf_lsa *new, #else /* #if 0 */ ospf_spf_calculate_schedule (ospf); #endif /* #if 0 */ - + if (IS_DEBUG_OSPF (lsa, LSA_INSTALL)) zlog_debug ("ospf_summary_lsa_install(): SPF scheduled"); } @@ -2477,7 +2479,7 @@ ospf_summary_asbr_lsa_install (struct ospf *ospf, struct ospf_lsa *new, #if 0 /* These don't exist yet... */ ospf_summary_incremental_update(new); - /* Isn't this done by the above call? + /* Isn't this done by the above call? - RFC 2328 Section 16.5 implies it should be */ /* ospf_ase_calculate_schedule(); */ #else /* #if 0 */ @@ -2513,7 +2515,7 @@ ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new, if (new->data->type == OSPF_AS_NSSA_LSA) { /* There is no point to register selforiginate Type-7 LSA for - * refreshing. We rely on refreshing Type-5 LSA's + * refreshing. We rely on refreshing Type-5 LSA's */ if (IS_LSA_SELF (new)) return new; @@ -2521,12 +2523,12 @@ ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new, { /* Try refresh type-5 translated LSA for this LSA, if one exists. * New translations will be taken care of by the abr_task. - */ + */ ospf_translated_nssa_refresh (ospf, new, NULL); } } - /* Register self-originated LSA to refresh queue. + /* Register self-originated LSA to refresh queue. * Leave Translated LSAs alone if NSSA is enabled */ if (IS_LSA_SELF (new) && !CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT ) ) @@ -2540,7 +2542,7 @@ ospf_discard_from_db (struct ospf *ospf, struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) { struct ospf_lsa *old; - + if (!lsdb) { zlog_warn ("%s: Called with NULL lsdb!", __func__); @@ -2551,7 +2553,7 @@ ospf_discard_from_db (struct ospf *ospf, lsa->data->type, inet_ntoa (lsa->data->id)); return; } - + old = ospf_lsdb_lookup (lsdb, lsa); if (!old) @@ -2662,11 +2664,11 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi, if (ospf_lsa_is_self_originated(ospf, lsa)) { lsa->data->ls_seqnum = htonl(OSPF_MAX_SEQUENCE_NUMBER); - + if (!IS_LSA_MAXAGE(lsa)) lsa->flags |= OSPF_LSA_PREMATURE_AGE; lsa->data->ls_age = htons (OSPF_LSA_MAXAGE); - + if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) { zlog_debug ("ospf_lsa_install() Premature Aging " @@ -2723,7 +2725,7 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi, if (IS_LSA_SELF (lsa)) lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */ else - ; /* Incoming "oi" for this LSA has set at LSUpd reception. */ + {;}; /* Incoming "oi" for this LSA has set at LSUpd reception. */ /* Fallthrough */ case OSPF_OPAQUE_AREA_LSA: case OSPF_OPAQUE_AS_LSA: @@ -2764,17 +2766,17 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi, } } - /* + /* If received LSA' ls_age is MaxAge, or lsa is being prematurely aged - (it's getting flushed out of the area), set LSA on MaxAge LSA list. + (it's getting flushed out of the area), set LSA on MaxAge LSA list. */ if ((lsa->flags & OSPF_LSA_PREMATURE_AGE) || (IS_LSA_MAXAGE (new) && !IS_LSA_SELF (new))) { if (IS_DEBUG_OSPF (lsa, LSA_INSTALL)) zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge", - new->data->type, - inet_ntoa (new->data->id), + new->data->type, + inet_ntoa (new->data->id), lsa); ospf_lsa_flush (ospf, lsa); } @@ -2782,13 +2784,13 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi, return new; } - + static int ospf_check_nbr_status (struct ospf *ospf) { struct listnode *node, *nnode; struct ospf_interface *oi; - + for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi)) { struct route_node *rn; @@ -2807,7 +2809,7 @@ ospf_check_nbr_status (struct ospf *ospf) return 1; } - + static int ospf_maxage_lsa_remover (struct thread *thread) @@ -2832,11 +2834,11 @@ ospf_maxage_lsa_remover (struct thread *thread) reschedule = 1; continue; } - + /* TODO: maybe convert this function to a work-queue */ if (thread_should_yield (thread)) OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0); - + /* Remove LSA from the LSDB */ if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)) if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) @@ -3077,7 +3079,7 @@ ospf_lsa_lookup (struct ospf_area *area, u_int32_t type, } struct ospf_lsa * -ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32_t type, +ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32_t type, struct in_addr id) { struct ospf_lsa *lsa; @@ -3315,7 +3317,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id)); - + ospf_refresher_unregister_lsa (ospf, lsa); ospf_lsa_flush_area (lsa, area); ospf_lsa_unlock (&area->router_lsa_self); @@ -3331,7 +3333,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id)); - + ospf_refresher_unregister_lsa (ospf, oi->network_lsa_self); ospf_lsa_flush_area (oi->network_lsa_self, area); ospf_lsa_unlock (&oi->network_lsa_self); @@ -3381,7 +3383,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf) /* If there is self-originated LSA, then return 1, otherwise return 0. */ /* An interface-independent version of ospf_lsa_is_self_originated */ -int +int ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa) { struct listnode *node; @@ -3470,7 +3472,7 @@ ospf_lsa_unique_id (struct ospf *ospf, return id; } - + #define LSA_ACTION_FLOOD_AREA 1 #define LSA_ACTION_FLUSH_AREA 2 @@ -3500,6 +3502,8 @@ ospf_lsa_action (struct thread *t) case LSA_ACTION_FLUSH_AREA: ospf_lsa_flush_area (data->lsa, data->area); break; + default: + break ; } ospf_lsa_unlock (&data->lsa); /* Message */ @@ -3533,7 +3537,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa) thread_add_event (master, ospf_lsa_action, data, 0); } - + /* LSA Refreshment functions. */ struct ospf_lsa * ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) @@ -3549,7 +3553,7 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) case OSPF_ROUTER_LSA: new = ospf_router_lsa_refresh (lsa); break; - case OSPF_NETWORK_LSA: + case OSPF_NETWORK_LSA: new = ospf_network_lsa_refresh (lsa); break; case OSPF_SUMMARY_LSA: @@ -3559,7 +3563,7 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa) new = ospf_summary_asbr_lsa_refresh (ospf, lsa); break; case OSPF_AS_EXTERNAL_LSA: - /* Translated from NSSA Type-5s are refreshed when + /* Translated from NSSA Type-5s are refreshed when * from refresh of Type-7 - do not refresh these directly. */ if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) @@ -3587,7 +3591,7 @@ void ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa) { u_int16_t index, current_index; - + assert (lsa->lock > 0); assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); @@ -3597,19 +3601,19 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa) if (LS_AGE (lsa) == 0 && ntohl (lsa->data->ls_seqnum) == OSPF_INITIAL_SEQUENCE_NUMBER) - /* Randomize first update by OSPF_LS_REFRESH_SHIFT factor */ + /* Randomize first update by OSPF_LS_REFRESH_SHIFT factor */ delay = OSPF_LS_REFRESH_SHIFT + (random () % OSPF_LS_REFRESH_TIME); else /* Randomize another updates by +-OSPF_LS_REFRESH_JITTER factor */ delay = OSPF_LS_REFRESH_TIME - LS_AGE (lsa) - OSPF_LS_REFRESH_JITTER - + (random () % (2*OSPF_LS_REFRESH_JITTER)); + + (random () % (2*OSPF_LS_REFRESH_JITTER)); if (delay < 0) delay = 0; current_index = ospf->lsa_refresh_queue.index + (quagga_time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY; - + index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY) % (OSPF_LSA_REFRESHER_SLOTS); @@ -3623,7 +3627,7 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa) lsa->refresh_list = index; if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) zlog_debug ("LSA[Refresh:%s]: ospf_refresher_register_lsa(): " - "setting refresh_list on lsa %p (slod %d)", + "setting refresh_list on lsa %p (slod %d)", inet_ntoa (lsa->data->id), lsa, index); } } @@ -3660,9 +3664,9 @@ ospf_lsa_refresh_walker (struct thread *t) if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) zlog_debug ("LSA[Refresh]:ospf_lsa_refresh_walker(): start"); - + i = ospf->lsa_refresh_queue.index; - + /* Note: if clock has jumped backwards, then time change could be negative, so we are careful to cast the expression to unsigned before taking modulus. */ @@ -3684,7 +3688,7 @@ ospf_lsa_refresh_walker (struct thread *t) "refresh index %d", i); refresh_list = ospf->lsa_refresh_queue.qs [i]; - + assert (i >= 0); ospf->lsa_refresh_queue.qs [i] = NULL; @@ -3695,9 +3699,9 @@ ospf_lsa_refresh_walker (struct thread *t) { if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): " - "refresh lsa %p (slot %d)", + "refresh lsa %p (slot %d)", inet_ntoa (lsa->data->id), lsa, i); - + assert (lsa->lock > 0); list_delete_node (refresh_list, node); lsa->refresh_list = -1; @@ -3717,12 +3721,12 @@ ospf_lsa_refresh_walker (struct thread *t) assert (lsa->lock > 0); ospf_lsa_unlock (&lsa); /* lsa_refresh_queue & temp for lsa_to_refresh*/ } - + list_delete (lsa_to_refresh); - + if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): end"); - + return 0; } diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index 967ca15d..7d0b6e43 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.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 @@ -121,7 +121,7 @@ ospf_nbr_free (struct ospf_neighbor *nbr) ospf_lsdb_cleanup (&nbr->db_sum); ospf_lsdb_cleanup (&nbr->ls_req); ospf_lsdb_cleanup (&nbr->ls_rxmt); - + /* Clear last send packet. */ if (nbr->last_send) ospf_packet_free (nbr->last_send); @@ -153,7 +153,7 @@ ospf_nbr_delete (struct ospf_neighbor *nbr) struct prefix p; oi = nbr->oi; - + /* get appropriate prefix 'key' */ ospf_nbr_key (oi, nbr, &p); @@ -168,7 +168,7 @@ ospf_nbr_delete (struct ospf_neighbor *nbr) * should never have NULL info. */ assert (rn->info); - + if (rn->info) { rn->info = NULL; @@ -215,7 +215,7 @@ ospf_nbr_add_self (struct ospf_interface *oi) oi->nbr_self->router_id = oi->ospf->router_id; oi->nbr_self->src = oi->address->u.prefix4; oi->nbr_self->state = NSM_TwoWay; - + switch (oi->area->external_routing) { case OSPF_AREA_DEFAULT: @@ -228,11 +228,13 @@ ospf_nbr_add_self (struct ospf_interface *oi) UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E); SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP); break; + default: + break ; } - + /* Add nbr_self to nbrs table */ ospf_nbr_key (oi, oi->nbr_self, &p); - + rn = route_node_get (oi->nbrs, &p); if (rn->info) { @@ -282,7 +284,7 @@ ospf_nbr_count_opaque_capable (struct ospf_interface *oi) #endif /* HAVE_OPAQUE_LSA */ /* lookup nbr by address - use this only if you know you must - * otherwise use the ospf_nbr_lookup() wrapper, which deals + * otherwise use the ospf_nbr_lookup() wrapper, which deals * with virtual link neighbours */ struct ospf_neighbor * @@ -300,7 +302,7 @@ ospf_nbr_lookup_by_addr (struct route_table *nbrs, rn = route_node_lookup (nbrs, &p); if (! rn) return NULL; - + /* See comment in ospf_nbr_delete */ assert (rn->info); @@ -386,7 +388,7 @@ ospf_nbr_add (struct ospf_interface *oi, struct ospf_header *ospfh, struct prefix *p) { struct ospf_neighbor *nbr; - + nbr = ospf_nbr_new (oi); nbr->state = NSM_Down; nbr->src = p->u.prefix4; @@ -412,15 +414,15 @@ ospf_nbr_add (struct ospf_interface *oi, struct ospf_header *ospfh, } } } - + /* New nbr, save the crypto sequence number if necessary */ if (ntohs (ospfh->auth_type) == OSPF_AUTH_CRYPTOGRAPHIC) nbr->crypt_seqnum = ospfh->u.crypt.crypt_seqnum; - + if (IS_DEBUG_OSPF_EVENT) zlog_debug ("NSM[%s:%s]: start", IF_NAME (nbr->oi), inet_ntoa (nbr->router_id)); - + return nbr; } @@ -431,7 +433,7 @@ ospf_nbr_get (struct ospf_interface *oi, struct ospf_header *ospfh, struct route_node *rn; struct prefix key; struct ospf_neighbor *nbr; - + key.family = AF_INET; key.prefixlen = IPV4_MAX_BITLEN; @@ -445,7 +447,7 @@ ospf_nbr_get (struct ospf_interface *oi, struct ospf_header *ospfh, { route_unlock_node (rn); nbr = rn->info; - + if (oi->type == OSPF_IFTYPE_NBMA && nbr->state == NSM_Attempt) { nbr->src = iph->ip_src; @@ -456,7 +458,7 @@ ospf_nbr_get (struct ospf_interface *oi, struct ospf_header *ospfh, { rn->info = nbr = ospf_nbr_add (oi, ospfh, p); } - + nbr->router_id = ospfh->router_id; return nbr; diff --git a/tests/bgp_capability_test.c b/tests/bgp_capability_test.c index cae9a12d..85c4da4d 100644 --- a/tests/bgp_capability_test.c +++ b/tests/bgp_capability_test.c @@ -533,6 +533,8 @@ parse_test (struct peer *peer, struct test_segment *t, int type) stream_putw (s, 0); stream_putc (s, BGP_MSG_CAPABILITY);*/ break; + default: + break ; } stream_write (peer->ibuf, t->data, t->len); diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c index 2f01080c..5492f92e 100644 --- a/watchquagga/watchquagga.c +++ b/watchquagga/watchquagga.c @@ -434,6 +434,8 @@ sigchild(void) case 0: zlog_warn("SIGCHLD received, but waitpid did not reap a child"); return; + default: + break ; } if ((restart = find_child(child)) != NULL) @@ -869,6 +871,8 @@ phase_check(void) THREAD_OFF(gs.t_phase_hanging); zlog_notice("Phased global restart has completed."); break; + default: + break ; } } @@ -1273,6 +1277,8 @@ main(int argc, char **argv) return usage(progname,1); } break; + default: + break ; } if (blankstr) |