From 9aecfae2ec82027fe1cf2740e6099397376a3f4f Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sat, 24 Jun 2006 20:05:02 +0000 Subject: [ospfd] Improve two info log messages in ospf_snmp.c 2006-06-24 Andrew J. Schorr * ospf_snmp.c: (ospfTrapNbrStateChange, ospfTrapIfStateChange) Improve info log message to indicate why the trap is being sent. --- ospfd/ospf_snmp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_snmp.c') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 71cb3085..4a6cc159 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -50,6 +50,7 @@ #include "ospfd/ospf_nsm.h" #include "ospfd/ospf_flood.h" #include "ospfd/ospf_ism.h" +#include "ospfd/ospf_dump.h" /* OSPF2-MIB. */ #define OSPF2MIB 1,3,6,1,2,1,14 @@ -2565,8 +2566,11 @@ void ospfTrapNbrStateChange (struct ospf_neighbor *on) { oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; + char msgbuf[16]; - zlog (NULL, LOG_INFO, "ospfTrapNbrStateChange trap sent"); + ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf)); + zlog (NULL, LOG_INFO, "ospfTrapNbrStateChange trap sent: %s now %s", + inet_ntoa(on->address.u.prefix4), msgbuf); oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; @@ -2600,7 +2604,9 @@ ospfTrapIfStateChange (struct ospf_interface *oi) { oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; - zlog (NULL, LOG_INFO, "ospfTrapIfStateChange trap sent"); + zlog (NULL, LOG_INFO, "ospfTrapIfStateChange trap sent: %s now %s", + inet_ntoa(oi->address->u.prefix4), + LOOKUP(ospf_ism_state_msg, oi->state)); oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); index[IN_ADDR_SIZE] = 0; -- cgit v1.2.3 From e4529636b77124285cca96a62799d0ff6a7addeb Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 12 Dec 2006 19:18:21 +0000 Subject: [PtP over ethernet] New peer flag allows much more addressing flexibility 2006-12-12 Andrew J. Schorr * if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating whether a peer address has been configured. Comment now shows the new interpretation of the destination addr: if ZEBRA_IFA_PEER is set, then it must contain the destination address, otherwise it may contain the broadcast address or be NULL. (CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete macros that were specific to IPv4 and not fully general. (CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag. (CONNECTED_PREFIX) New macro giving the prefix to insert into the RIB: if CONNECTED_PEER, then use the destination (peer) address, else use the address field. (CONNECTED_ID) New macro to come up with an identifying address for the struct connected. * if.c: (if_lookup_address, connected_lookup_address) Streamline logic with new CONNECTED_PREFIX macro. * prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros for better performance than the general prefix_copy function. * zclient.c: (zebra_interface_address_read) For non-null destination addresses, set prefixlen to equal the address prefixlen. This is needed to get the new CONNECTED_PREFIX macro to work properly. * connected.c: (connected_up_ipv4, connected_down_ipv4, connected_up_ipv6, connected_down_ipv6) Simplify logic using the new CONNECTED_PREFIX macro. (connected_add_ipv4) Set prefixlen in destination addresses (required by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead of testing for IFF_POINTOPOINT. Delete invalid warning message. Warn about cases where the ZEBRA_IFA_PEER is set but no destination address has been supplied (and turn off the flag). (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning. Set prefixlen in destination address so CONNECTED_PREFIX will work. * connected.h: (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. * interface.c: (connected_dump_vty) Use CONNECTED_PEER macro to decide whether the destination address is a peer or broadcast address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT). * if_ioctl.c: (if_getaddrs) Instead of setting a peer address only when the IFF_POINTOPOINT is set, we now accept a peer address whenever it is available and not the same as the local address. Otherwise (no peer address assigned), we check for a broadcast address (regardless of the IFF_BROADCAST flag). And must now pass a flags value of ZEBRA_IFA_PEER to connected_add_ipv4 when a peer address is assigned. The same new logic is used with the IPv6 code as well (and we pass the new flags argument to connected_add_ipv6). (if_get_addr) Do not bother to check IFF_POINTOPOINT: just issue the SIOCGIFDSTADDR ioctl and see if we get back a peer address not matching the local address (and set the ZEBRA_IFA_PEER in that case). If there's no peer address, try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set. * if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl without bothering to check the IFF_POINTOPOINT flag. And if no peer address was found, just try the SIOCGLIFBRDADDR ioctl without checking the IFF_BROADCAST flag. Call connected_add_ipv4 and connected_add_ipv6 with appropriate flags. * if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to connected_add_ipv6. * kernel_socket.c: (ifam_read) Must pass new flags argument to connected_add_ipv6. * rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2 to determine local and possible peer address (so there's no longer a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately. Pass new flags argument to connected_add_ipv6. (netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast to determine whether the connected destination address is a broadcast address. * bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete) Simplify logic by using new CONNECTED_PREFIX macro. * ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix, ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX macro. * ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX macro, both options collapse into the same code. * ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new CONNECTED_ID macro. (ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX macro. * ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro instead of testing the IFF_POINTOPOINT flag. * ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro instead of testing with if_is_pointopoint. And add commented-out code to implement alternative (in my opinion) more elegant behavior that has no special-case treatment for PtP addresses. (ospf_network_run) Use new CONNECTED_ID macro to simplify logic. * rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID macro to simplify logic. (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does not give a useful result if prefixlen is 32 (we require a peer address in such cases). * ripd.c: (rip_update_interface) Fix same bug as above. --- ospfd/ospf_snmp.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'ospfd/ospf_snmp.c') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 4a6cc159..bc594b3a 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -1439,10 +1439,7 @@ ospf_snmp_if_update (struct interface *ifp) /* Lookup first IPv4 address entry. */ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) { - if (CONNECTED_POINTOPOINT_HOST(ifc)) - p = ifc->destination; - else - p = ifc->address; + p = CONNECTED_ID(ifc); if (p->family == AF_INET) { @@ -1492,19 +1489,13 @@ ospf_snmp_if_update (struct interface *ifp) int ospf_snmp_is_if_have_addr (struct interface *ifp) { - struct prefix *p; struct listnode *nn; struct connected *ifc; /* Is this interface having any connected IPv4 address ? */ for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, ifc)) { - if (if_is_pointopoint (ifp)) - p = ifc->destination; - else - p = ifc->address; - - if (p->family == AF_INET) + if (CONNECTED_PREFIX(ifc)->family == AF_INET) return 1; } -- cgit v1.2.3 From ad81f8cc2e77275cdeef1267d1ff4173eb89e093 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Wed, 14 Mar 2007 22:05:18 +0000 Subject: [ospfd] Return SNMP standard neighbor state values, not quagga internal ones 2007-03-14 Andrew J. Schorr * ospf_snmp.c: (ospf_snmp_neighbor_state) New function to map internal quagga neighbor states to SNMP standard values. (ospfNbrEntry) Call new ospf_snmp_neighbor_state function. --- ospfd/ospf_snmp.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'ospfd/ospf_snmp.c') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index bc594b3a..6e972605 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2216,6 +2216,44 @@ ospfNbrLookup (struct variable *v, oid *name, size_t *length, return NULL; } +/* map internal quagga neighbor states to official MIB values: + +ospfNbrState OBJECT-TYPE + SYNTAX INTEGER { + down (1), + attempt (2), + init (3), + twoWay (4), + exchangeStart (5), + exchange (6), + loading (7), + full (8) + } +*/ +static int32_t +ospf_snmp_neighbor_state(u_char nst) +{ + switch (nst) + { + case NSM_Attempt: + return 2; + case NSM_Init: + return 3; + case NSM_TwoWay: + return 4; + case NSM_ExStart: + return 5; + case NSM_Exchange: + return 6; + case NSM_Loading: + return 7; + case NSM_Full: + return 8; + default: + return 1; /* down */ + } +} + static u_char * ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) @@ -2254,7 +2292,7 @@ ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact, return SNMP_INTEGER (nbr->priority); break; case OSPFNBRSTATE: - return SNMP_INTEGER (nbr->state); + return SNMP_INTEGER (ospf_snmp_neighbor_state(nbr->state)); break; case OSPFNBREVENTS: return SNMP_INTEGER (nbr->state_change); -- cgit v1.2.3 From fb62a3cef5960885119f9e87c833520ddf2a9b49 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 13 May 2008 20:03:32 +0200 Subject: Make --enable-snmp cross compile and make libcrypto optional with --without-crypto Autoconfig work by me, the rest was done by "Kirill K. Smirnov" --- ospfd/ospf_snmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ospfd/ospf_snmp.c') diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 6e972605..e6ce1f01 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -27,10 +27,12 @@ #ifdef HAVE_SNMP #ifdef HAVE_NETSNMP #include -#endif +#include +#else #include #include #include +#endif #include "if.h" #include "log.h" -- cgit v1.2.3