Merge remote branch 'origin/master'
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 576e3e0..0f44e68 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -43,6 +43,7 @@
 #include "bgpd/bgp_attr.h"
 #include "bgpd/bgp_route.h"
 #include "bgpd/bgp_fsm.h"
+#include "bgpd/bgp_snmp.h"
 
 /* BGP4-MIB described in RFC1657. */
 #define BGP4MIB 1,3,6,1,2,1,15
@@ -128,12 +129,18 @@
 static struct in_addr bgp_empty_addr = {0};
 
 /* Hook functions. */
-static u_char *bgpVersion ();
-static u_char *bgpLocalAs ();
-static u_char *bgpPeerTable ();
-static u_char *bgpRcvdPathAttrTable ();
-static u_char *bgpIdentifier ();
-static u_char *bgp4PathAttrTable ();
+static u_char *bgpVersion (struct variable *, oid [], size_t *, int,
+			   size_t *, WriteMethod **);
+static u_char *bgpLocalAs (struct variable *, oid [], size_t *,
+			   int, size_t *, WriteMethod **);
+static u_char *bgpPeerTable (struct variable *, oid [], size_t *,
+			     int, size_t *, WriteMethod **);
+static u_char *bgpRcvdPathAttrTable (struct variable *, oid [], size_t *,
+				     int, size_t *, WriteMethod **);
+static u_char *bgpIdentifier (struct variable *, oid [], size_t *,
+			      int, size_t *, WriteMethod **);
+static u_char *bgp4PathAttrTable (struct variable *, oid [], size_t *,
+				  int, size_t *, WriteMethod **);
 /* static u_char *bgpTraps (); */
 
 struct variable bgp_variables[] = 
@@ -277,7 +284,7 @@
   return SNMP_INTEGER (bgp->as);
 }
 
-struct peer *
+static struct peer *
 peer_lookup_addr_ipv4 (struct in_addr *src)
 {
   struct bgp *bgp;
@@ -302,7 +309,7 @@
   return NULL;
 }
 
-struct peer *
+static struct peer *
 bgp_peer_lookup_next (struct in_addr *src)
 {
   struct bgp *bgp;
@@ -335,7 +342,7 @@
   return NULL;
 }
 
-struct peer *
+static struct peer *
 bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length, 
 		     struct in_addr *addr, int exact)
 {
@@ -374,7 +381,7 @@
 }
 
 /* BGP write methods. */
-int
+static int
 write_bgpPeerTable (int action, u_char *var_val,
 		    u_char var_val_type, size_t var_val_len,
 		    u_char *statP, oid *name, size_t length,
@@ -383,7 +390,7 @@
   struct in_addr addr;
   struct peer *peer;
   long intval;
-  int bigsize = SNMP_MAX_LEN;
+  size_t bigsize = SNMP_MAX_LEN;
   
   if (var_val_type != ASN_INTEGER) 
     {
@@ -446,7 +453,7 @@
   return SNMP_ERR_NOERROR;
 }
 
-u_char *
+static u_char *
 bgpPeerTable (struct variable *v, oid name[], size_t *length,
 	      int exact, size_t *var_len, WriteMethod **write_method)
 {
@@ -586,7 +593,7 @@
   return NULL;
 }
 
-u_char *
+static u_char *
 bgpIdentifier (struct variable *v, oid name[], size_t *length,
 	       int exact, size_t *var_len, WriteMethod **write_method)
 {
@@ -603,7 +610,7 @@
   return SNMP_IPADDRESS (bgp->router_id);
 }
 
-u_char *
+static u_char *
 bgpRcvdPathAttrTable (struct variable *v, oid name[], size_t *length,
 		      int exact, size_t *var_len, WriteMethod **write_method)
 {
@@ -614,7 +621,7 @@
   return NULL;
 }
 
-struct bgp_info *
+static struct bgp_info *
 bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length,
 		    struct bgp *bgp, struct prefix_ipv4 *addr, int exact)
 {
@@ -751,7 +758,7 @@
   return NULL;
 }
 
-u_char *
+static u_char *
 bgp4PathAttrTable (struct variable *v, oid name[], size_t *length,
 		   int exact, size_t *var_len, WriteMethod **write_method)
 {
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index cebde0a..1712c71 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -5150,9 +5150,15 @@
                            BGP_NOTIFY_CEASE_PEER_UNCONFIG);
   
   bgp_cleanup_routes ();
+  
   if (bm->process_main_queue)
-    work_queue_free (bm->process_main_queue);
+    {
+      work_queue_free (bm->process_main_queue);
+      bm->process_main_queue = NULL;
+    }
   if (bm->process_rsclient_queue)
-    work_queue_free (bm->process_rsclient_queue);
+    {
+      work_queue_free (bm->process_rsclient_queue);
+      bm->process_rsclient_queue = NULL;
+    }
 }
-
diff --git a/lib/smux.c b/lib/smux.c
index 4a3696c..fd0c89c 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -138,7 +138,7 @@
   return 0;
 }
 
-int
+static int
 oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len)
 {
   int i;
@@ -156,7 +156,7 @@
   return 0;
 }
 
-void
+static void
 smux_oid_dump (const char *prefix, oid *oid, size_t oid_len)
 {
   unsigned int i;
@@ -173,7 +173,7 @@
   zlog_debug ("%s: %s", prefix, buf);
 }
 
-int
+static int
 smux_socket ()
 {
   int ret;
@@ -266,7 +266,7 @@
   return sock;
 }
 
-void
+static void
 smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat,
 		   long errindex, u_char val_type, void *arg, size_t arg_len)
 {
@@ -324,13 +324,13 @@
   asn_build_sequence(h1,&length,(u_char)SMUX_GETRSP,ptr-h1e);
 
   if (debug_smux)
-    zlog_debug ("SMUX getresp send: %ld", (ptr - buf));
+    zlog_debug ("SMUX getresp send: %td", (ptr - buf));
   
   ret = send (smux_sock, buf, (ptr - buf), 0);
 }
 
-char *
-smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len,
+static u_char *
+smux_var (u_char *ptr, size_t len, oid objid[], size_t *objid_len,
           size_t *var_val_len,
           u_char *var_val_type,
           void **var_value)
@@ -341,14 +341,14 @@
   u_char *val;
 
   if (debug_smux)
-    zlog_debug ("SMUX var parse: len %ld", len);
+    zlog_debug ("SMUX var parse: len %zd", len);
 
   /* Parse header. */
   ptr = asn_parse_header (ptr, &len, &type);
   
   if (debug_smux)
     {
-      zlog_debug ("SMUX var parse: type %d len %ld", type, len);
+      zlog_debug ("SMUX var parse: type %d len %zd", type, len);
       zlog_debug ("SMUX var parse: type must be %d", 
 		 (ASN_SEQUENCE | ASN_CONSTRUCTOR));
     }
@@ -430,7 +430,7 @@
    ucd-snmp smux and as such suppose, that the peer receives in the message
    only one variable. Fortunately, IBM seems to do the same in AIX. */
 
-int
+static int
 smux_set (oid *reqid, size_t *reqid_len,
           u_char val_type, void *val, size_t val_len, int action)
 {
@@ -498,7 +498,7 @@
   return SNMP_ERR_NOSUCHNAME;
 }
 
-int
+static int
 smux_get (oid *reqid, size_t *reqid_len, int exact, 
 	  u_char *val_type,void **val, size_t *val_len)
 {
@@ -564,7 +564,7 @@
   return SNMP_ERR_NOSUCHNAME;
 }
 
-int
+static int
 smux_getnext (oid *reqid, size_t *reqid_len, int exact, 
 	      u_char *val_type,void **val, size_t *val_len)
 {
@@ -650,8 +650,8 @@
 }
 
 /* GET message header. */
-char *
-smux_parse_get_header (char *ptr, size_t *len, long *reqid)
+static u_char *
+smux_parse_get_header (u_char *ptr, size_t *len, long *reqid)
 {
   u_char type;
   long errstat;
@@ -667,19 +667,19 @@
   ptr = asn_parse_int (ptr, len, &type, &errstat, sizeof (errstat));
 
   if (debug_smux)
-    zlog_debug ("SMUX GET errstat %ld len: %ld", errstat, *len);
+    zlog_debug ("SMUX GET errstat %ld len: %zd", errstat, *len);
 
   /* Error index. */
   ptr = asn_parse_int (ptr, len, &type, &errindex, sizeof (errindex));
 
   if (debug_smux)
-    zlog_debug ("SMUX GET errindex %ld len: %ld", errindex, *len);
+    zlog_debug ("SMUX GET errindex %ld len: %zd", errindex, *len);
 
   return ptr;
 }
 
-void
-smux_parse_set (char *ptr, size_t len, int action)
+static void
+smux_parse_set (u_char *ptr, size_t len, int action)
 {
   long reqid;
   oid oid[MAX_OID_LEN];
@@ -690,7 +690,7 @@
   int ret;
 
   if (debug_smux)
-    zlog_debug ("SMUX SET(%s) message parse: len %ld",
+    zlog_debug ("SMUX SET(%s) message parse: len %zd",
                (RESERVE1 == action) ? "RESERVE1" : ((FREE == action) ? "FREE" : "COMMIT"),
                len);
 
@@ -709,8 +709,8 @@
     smux_getresp_send (oid, oid_len, reqid, ret, 3, ASN_NULL, NULL, 0);
 }
 
-void
-smux_parse_get (char *ptr, size_t len, int exact)
+static void
+smux_parse_get (u_char *ptr, size_t len, int exact)
 {
   long reqid;
   oid oid[MAX_OID_LEN];
@@ -721,7 +721,7 @@
   int ret;
 
   if (debug_smux)
-    zlog_debug ("SMUX GET message parse: len %ld", len);
+    zlog_debug ("SMUX GET message parse: len %zd", len);
   
   /* Parse GET message header. */
   ptr = smux_parse_get_header (ptr, &len, &reqid);
@@ -743,8 +743,8 @@
 }
 
 /* Parse SMUX_CLOSE message. */
-void
-smux_parse_close (char *ptr, int len)
+static void
+smux_parse_close (u_char *ptr, int len)
 {
   long reason = 0;
 
@@ -757,10 +757,10 @@
 }
 
 /* SMUX_RRSP message. */
-void
-smux_parse_rrsp (char *ptr, size_t len)
+static void
+smux_parse_rrsp (u_char *ptr, size_t len)
 {
-  char val;
+  u_char val;
   long errstat;
   
   ptr = asn_parse_int (ptr, &len, &val, &errstat, sizeof (errstat));
@@ -770,8 +770,8 @@
 }
 
 /* Parse SMUX message. */
-int
-smux_parse (char *ptr, size_t len)
+static int
+smux_parse (u_char *ptr, size_t len)
 {
   /* This buffer we'll use for SOUT message. We could allocate it with
      malloc and save only static pointer/lenght, but IMHO static
@@ -791,7 +791,7 @@
   ptr = asn_parse_header (ptr, &len, &type);
 
   if (debug_smux)
-    zlog_debug ("SMUX message received type: %d rest len: %ld", type, len);
+    zlog_debug ("SMUX message received type: %d rest len: %zd", type, len);
 
   switch (type)
     {
@@ -883,7 +883,7 @@
 }
 
 /* SMUX message read function. */
-int
+static int
 smux_read (struct thread *t)
 {
   int sock;
@@ -939,13 +939,13 @@
   return 0;
 }
 
-int
+static int
 smux_open (int sock)
 {
   u_char buf[BUFSIZ];
   u_char *ptr;
   size_t len;
-  u_long version;
+  long version;
   u_char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
 
   if (debug_smux)
@@ -983,7 +983,7 @@
   ptr = asn_build_string (ptr, &len, 
 			  (u_char)
 			  (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
-			  smux_passwd, strlen (smux_passwd));
+			  (u_char *)smux_passwd, strlen (smux_passwd));
 
   /* Fill in real SMUX header.  We exclude ASN header size (2). */
   len = BUFSIZ;
@@ -1034,13 +1034,13 @@
   val = SNMP_TRAP_ENTERPRISESPECIFIC;
   ptr = asn_build_int (ptr, &len, 
 		       (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
-		       &val, sizeof (val));
+		       (long *)&val, sizeof (val));
 
   /* Specific trap integer. */
   val = sptrap;
   ptr = asn_build_int (ptr, &len, 
 		       (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
-		       &val, sizeof (val));
+		       (long *)&val, sizeof (val));
 
   /* Timeticks timestamp. */
   val = 0;
@@ -1118,7 +1118,7 @@
   return send (smux_sock, buf, (ptr - buf), 0);
 }
 
-int
+static int
 smux_register (int sock)
 {
   u_char buf[BUFSIZ];
@@ -1175,7 +1175,7 @@
 }
 
 /* Try to connect to SNMP agent. */
-int
+static int
 smux_connect (struct thread *t)
 {
   int ret;
@@ -1226,7 +1226,7 @@
 }
 
 /* Clear all SMUX related resources. */
-void
+static void
 smux_stop ()
 {
   if (smux_read_thread)
@@ -1269,7 +1269,7 @@
     }
 }
 
-int
+static int
 smux_str2oid (const char *str, oid *oid, size_t *oid_len)
 {
   int len;
@@ -1312,7 +1312,7 @@
   return 0;
 }
 
-oid *
+static oid *
 smux_oid_dup (oid *objid, size_t objid_len)
 {
   oid *new;
@@ -1323,7 +1323,7 @@
   return new;
 }
 
-int
+static int
 smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
 {
   int ret;
@@ -1387,7 +1387,7 @@
   return MATCH_SUCCEEDED;
 }
 
-int
+static int
 smux_peer_default ()
 {
   if (smux_oid)
@@ -1467,7 +1467,7 @@
        "SMUX peering object ID\n"
        "SMUX peering password\n")
 
-int
+static int
 config_write_smux (struct vty *vty)
 {
   int first = 1;
@@ -1504,13 +1504,6 @@
   listnode_add_sort(treelist, tree);
 }
 
-void
-smux_reset ()
-{
-  /* Setting configuration to default. */
-  smux_peer_default ();
-}
-
 /* Compare function to keep treelist sorted */
 static int
 smux_tree_cmp(struct subtree *tree1, struct subtree *tree2)
diff --git a/lib/smux.h b/lib/smux.h
index 79d23e7..bab3587 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -127,12 +127,12 @@
 
 /* Declare SMUX return value. */
 #define SNMP_LOCAL_VARIABLES \
-  static int32_t snmp_int_val; \
+  static long snmp_int_val; \
   static struct in_addr snmp_in_addr_val;
 
 #define SNMP_INTEGER(V) \
   ( \
-    *var_len = sizeof (int32_t), \
+    *var_len = sizeof (snmp_int_val), \
     snmp_int_val = V, \
     (u_char *) &snmp_int_val \
   )
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 1d32d24..7c811ed 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -91,6 +91,9 @@
 void
 work_queue_free (struct work_queue *wq)
 {
+  if (wq->thread != NULL)
+    thread_cancel(wq->thread);
+  
   /* list_delete frees items via callback */
   list_delete (wq->items);
   listnode_delete (&work_queues, wq);
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index 8d9842c..5ac7846 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -47,6 +47,7 @@
 #include "ospf6_message.h"
 #include "ospf6_neighbor.h"
 #include "ospf6d.h"
+#include "ospf6_snmp.h"
 
 /* OSPFv3-MIB */
 #define OSPFv3MIB 1,3,6,1,3,102
@@ -128,9 +129,12 @@
 static struct in_addr ospf6_empty_id = {0};
 
 /* Hook functions. */
-static u_char *ospfv3GeneralGroup ();
-static u_char *ospfv3AreaEntry ();
-static u_char *ospfv3AreaLsdbEntry ();
+static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
+				   int, size_t *, WriteMethod **);
+static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
+				int, size_t *, WriteMethod **);
+static u_char *ospfv3AreaLsdbEntry (struct variable *, oid *, size_t *,
+				    int, size_t *, WriteMethod **);
 
 struct variable ospfv3_variables[] =
 {
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index e6ce1f0..c47d432 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -53,6 +53,7 @@
 #include "ospfd/ospf_flood.h"
 #include "ospfd/ospf_ism.h"
 #include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_snmp.h"
 
 /* OSPF2-MIB. */
 #define OSPF2MIB 1,3,6,1,2,1,14
@@ -220,19 +221,32 @@
 static struct in_addr ospf_empty_addr = {0};
 
 /* Hook functions. */
-static u_char *ospfGeneralGroup ();
-static u_char *ospfAreaEntry ();
-static u_char *ospfStubAreaEntry ();
-static u_char *ospfLsdbEntry ();
-static u_char *ospfAreaRangeEntry ();
-static u_char *ospfHostEntry ();
-static u_char *ospfIfEntry ();
-static u_char *ospfIfMetricEntry ();
-static u_char *ospfVirtIfEntry ();
-static u_char *ospfNbrEntry ();
-static u_char *ospfVirtNbrEntry ();
-static u_char *ospfExtLsdbEntry ();
-static u_char *ospfAreaAggregateEntry ();
+static u_char *ospfGeneralGroup (struct variable *, oid *, size_t *,
+				 int, size_t *, WriteMethod **);
+static u_char *ospfAreaEntry (struct variable *, oid *, size_t *, int,
+			      size_t *, WriteMethod **);
+static u_char *ospfStubAreaEntry (struct variable *, oid *, size_t *,
+				  int, size_t *, WriteMethod **);
+static u_char *ospfLsdbEntry (struct variable *, oid *, size_t *, int,
+			      size_t *, WriteMethod **);
+static u_char *ospfAreaRangeEntry (struct variable *, oid *, size_t *, int,
+				   size_t *, WriteMethod **);
+static u_char *ospfHostEntry (struct variable *, oid *, size_t *, int,
+			      size_t *, WriteMethod **);
+static u_char *ospfIfEntry (struct variable *, oid *, size_t *, int,
+			    size_t *, WriteMethod **);
+static u_char *ospfIfMetricEntry (struct variable *, oid *, size_t *, int,
+				  size_t *, WriteMethod **);
+static u_char *ospfVirtIfEntry (struct variable *, oid *, size_t *, int,
+				size_t *, WriteMethod **);
+static u_char *ospfNbrEntry (struct variable *, oid *, size_t *, int,
+			     size_t *, WriteMethod **);
+static u_char *ospfVirtNbrEntry (struct variable *, oid *, size_t *, int,
+				 size_t *, WriteMethod **);
+static u_char *ospfExtLsdbEntry (struct variable *, oid *, size_t *, int,
+				 size_t *, WriteMethod **);
+static u_char *ospfAreaAggregateEntry (struct variable *, oid *, size_t *,
+				       int, size_t *, WriteMethod **);
 
 struct variable ospf_variables[] = 
 {
@@ -495,7 +509,7 @@
 
 /* The administrative status of OSPF.  When OSPF is enbled on at least
    one interface return 1. */
-int
+static int
 ospf_admin_stat (struct ospf *ospf)
 {
   struct listnode *node;
@@ -612,7 +626,7 @@
   return NULL;
 }
 
-struct ospf_area *
+static struct ospf_area *
 ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
 {
   struct ospf_area *area;
@@ -643,7 +657,7 @@
   return NULL;
 }
 
-struct ospf_area *
+static struct ospf_area *
 ospfAreaLookup (struct variable *v, oid name[], size_t *length,
 		struct in_addr *addr, int exact)
 {
@@ -746,7 +760,7 @@
   return NULL;
 }
 
-struct ospf_area *
+static struct ospf_area *
 ospf_stub_area_lookup_next (struct in_addr *area_id, int first)
 {
   struct ospf_area *area;
@@ -776,7 +790,7 @@
   return NULL;
 }
 
-struct ospf_area *
+static struct ospf_area *
 ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
 		    struct in_addr *addr, int exact)
 {
@@ -877,7 +891,7 @@
   return NULL;
 }
 
-struct ospf_lsa *
+static struct ospf_lsa *
 lsdb_lookup_next (struct ospf_area *area, u_char *type, int type_next,
 		  struct in_addr *ls_id, int ls_id_next,
 		  struct in_addr *router_id, int router_id_next)
@@ -912,7 +926,7 @@
   return NULL;
 }
 
-struct ospf_lsa *
+static struct ospf_lsa *
 ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
 		struct in_addr *area_id, u_char *type,
 		struct in_addr *ls_id, struct in_addr *router_id, int exact)
@@ -1124,7 +1138,7 @@
   return NULL;
 }
 
-struct ospf_area_range *
+static struct ospf_area_range *
 ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
 		     struct in_addr *area_id, struct in_addr *range_net,
 		     int exact)
@@ -1273,7 +1287,7 @@
   return NULL;
 }
 
-struct ospf_nbr_nbma *
+static struct ospf_nbr_nbma *
 ospfHostLookup (struct variable *v, oid *name, size_t *length,
 		struct in_addr *addr, int exact)
 {
@@ -1388,7 +1402,7 @@
   struct interface *ifp;
 };
 
-struct ospf_snmp_if *
+static struct ospf_snmp_if *
 ospf_snmp_if_new ()
 {
   struct ospf_snmp_if *osif;
@@ -1398,7 +1412,7 @@
   return osif;
 }
 
-void
+static void
 ospf_snmp_if_free (struct ospf_snmp_if *osif)
 {
   XFREE (0, osif);
@@ -1488,7 +1502,7 @@
   listnode_add_after (ospf_snmp_iflist, pn, osif);
 }
 
-int
+static int
 ospf_snmp_is_if_have_addr (struct interface *ifp)
 {
   struct listnode *nn;
@@ -1504,7 +1518,7 @@
   return 0;
 }
 
-struct ospf_interface *
+static struct ospf_interface *
 ospf_snmp_if_lookup (struct in_addr *ifaddr, unsigned int *ifindex)
 {
   struct listnode *node;
@@ -1528,7 +1542,7 @@
   return oi;
 }
 
-struct ospf_interface *
+static struct ospf_interface *
 ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex,
 			  int ifaddr_next, int ifindex_next)
 {
@@ -1563,19 +1577,21 @@
     {
       /* Usual interface */
       if (ifaddr->s_addr) 
-        /* The interface must have valid AF_INET connected address */
-        /* it must have lager IPv4 address value than the lookup entry */
-        if ((ospf_snmp_is_if_have_addr(osif->ifp)) &&
-            (ntohl (osif->addr.s_addr) > ntohl (ifaddr->s_addr)))
-          {
-            *ifaddr = osif->addr;
-            *ifindex = osif->ifindex;
+	{
+	  /* The interface must have valid AF_INET connected address */
+	  /* it must have lager IPv4 address value than the lookup entry */
+	  if ((ospf_snmp_is_if_have_addr(osif->ifp)) &&
+	      (ntohl (osif->addr.s_addr) > ntohl (ifaddr->s_addr)))
+	    {
+	      *ifaddr = osif->addr;
+	      *ifindex = osif->ifindex;
         
-            /* and it must be an OSPF interface */
-            oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
-            if (oi)
-              return oi;
-          }
+	      /* and it must be an OSPF interface */
+	      oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
+	      if (oi)
+		return oi;
+	    }
+	}
       /* Unnumbered interface */
       else  
         /* The interface must NOT have valid AF_INET connected address */
@@ -1595,7 +1611,7 @@
   return NULL;
 }
 
-int
+static int
 ospf_snmp_iftype (struct interface *ifp)
 {
 #define ospf_snmp_iftype_broadcast         1
@@ -1609,7 +1625,7 @@
   return ospf_snmp_iftype_broadcast;
 }
 
-struct ospf_interface *
+static struct ospf_interface *
 ospfIfLookup (struct variable *v, oid *name, size_t *length,
 	      struct in_addr *ifaddr, unsigned int *ifindex, int exact)
 {
@@ -1665,7 +1681,7 @@
 
 static u_char *
 ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact,
-	     size_t  *var_len, WriteMethod **write_method)
+	     size_t *var_len, WriteMethod **write_method)
 {
   unsigned int ifindex;
   struct in_addr ifaddr;
@@ -1769,7 +1785,7 @@
 
 #define OSPF_SNMP_METRIC_VALUE 1
 
-struct ospf_interface *
+static struct ospf_interface *
 ospfIfMetricLookup (struct variable *v, oid *name, size_t *length,
 		    struct in_addr *ifaddr, unsigned int *ifindex, int exact)
 {
@@ -1915,7 +1931,7 @@
   route_unlock_node (rn);
 }
 
-struct ospf_vl_data *
+static struct ospf_vl_data *
 ospf_snmp_vl_lookup (struct in_addr *area_id, struct in_addr *neighbor)
 {
   struct prefix_ls lp;
@@ -1938,7 +1954,7 @@
   return NULL;
 }
 
-struct ospf_vl_data *
+static struct ospf_vl_data *
 ospf_snmp_vl_lookup_next (struct in_addr *area_id, struct in_addr *neighbor,
 			  int first)
 {
@@ -1975,7 +1991,7 @@
   return NULL;
 }
 
-struct ospf_vl_data *
+static struct ospf_vl_data *
 ospfVirtIfLookup (struct variable *v, oid *name, size_t *length,
 		  struct in_addr *area_id, struct in_addr *neighbor, int exact)
 {
@@ -2025,7 +2041,7 @@
 
 static u_char *
 ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact,
-		 size_t  *var_len, WriteMethod **write_method)
+		 size_t *var_len, WriteMethod **write_method)
 {
   struct ospf_vl_data *vl_data;
   struct ospf_interface *oi;
@@ -2089,7 +2105,7 @@
   return NULL;
 }
 
-struct ospf_neighbor *
+static struct ospf_neighbor *
 ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
 		      unsigned int *ifindex)
 {
@@ -2118,7 +2134,7 @@
   return NULL;
 }
 
-struct ospf_neighbor *
+static struct ospf_neighbor *
 ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex,
 			   int first)
 {
@@ -2164,7 +2180,7 @@
   return NULL;
 }
 
-struct ospf_neighbor *
+static struct ospf_neighbor *
 ospfNbrLookup (struct variable *v, oid *name, size_t *length,
 	       struct in_addr *nbr_addr, unsigned int *ifindex, int exact)
 {
@@ -2258,7 +2274,7 @@
 
 static u_char *
 ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
-	      size_t  *var_len, WriteMethod **write_method)
+	      size_t *var_len, WriteMethod **write_method)
 {
   struct in_addr nbr_addr;
   unsigned int ifindex;
@@ -2320,7 +2336,7 @@
 
 static u_char *
 ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
-		  size_t  *var_len, WriteMethod **write_method)
+		  size_t *var_len, WriteMethod **write_method)
 {
   struct ospf_vl_data *vl_data;
   struct in_addr area_id;
@@ -2373,7 +2389,7 @@
   return NULL;
 }
 
-struct ospf_lsa *
+static struct ospf_lsa *
 ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
 		   struct in_addr *ls_id, struct in_addr *router_id, int exact)
 {
@@ -2466,7 +2482,7 @@
 
 static u_char *
 ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
-		  size_t  *var_len, WriteMethod **write_method)
+		  size_t *var_len, WriteMethod **write_method)
 {
   struct ospf_lsa *lsa;
   struct lsa_header *lsah;
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index a723827..c4abe7e 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2115,8 +2115,10 @@
     abr_type = OSPF_ABR_CISCO;
   else if (strncmp (argv[0], "i", 1) == 0)
     abr_type = OSPF_ABR_IBM;
-  else if (strncmp (argv[0], "s", 1) == 0)
+  else if (strncmp (argv[0], "sh", 2) == 0)
     abr_type = OSPF_ABR_SHORTCUT;
+  else if (strncmp (argv[0], "st", 2) == 0)
+    abr_type = OSPF_ABR_STAND;
   else
     return CMD_WARNING;
 
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index b6d9240..7c5577b 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -591,7 +591,7 @@
 	      {
 		rip_zebra_ipv4_delete ((struct prefix_ipv4 *) &rp->p,
 				       &rinfo->nexthop,
-				       rinfo->ifindex);
+				       rinfo->metric);
 
 		rip_redistribute_delete (rinfo->type,rinfo->sub_type,
 					 (struct prefix_ipv4 *)&rp->p,
diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c
index d02c761..61c47c7 100644
--- a/ripd/rip_snmp.c
+++ b/ripd/rip_snmp.c
@@ -93,10 +93,14 @@
 struct route_table *rip_ifaddr_table;
 
 /* Hook functions. */
-static u_char *rip2Globals ();
-static u_char *rip2IfStatEntry ();
-static u_char *rip2IfConfAddress ();
-static u_char *rip2PeerTable ();
+static u_char *rip2Globals (struct variable *, oid [], size_t *,
+			    int, size_t *, WriteMethod **);
+static u_char *rip2IfStatEntry (struct variable *, oid [], size_t *,
+				int, size_t *, WriteMethod **);
+static u_char *rip2IfConfAddress (struct variable *, oid [], size_t *,
+				  int, size_t *, WriteMethod **);
+static u_char *rip2PeerTable (struct variable *, oid [], size_t *,
+			      int, size_t *, WriteMethod **);
 
 struct variable rip_variables[] = 
 {
@@ -215,7 +219,7 @@
     }
 }
 
-struct interface *
+static struct interface *
 rip_ifaddr_lookup_next (struct in_addr *addr)
 {
   struct prefix_ipv4 p;
diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c
index 7e66e2f..0fde4bb 100644
--- a/zebra/zebra_snmp.c
+++ b/zebra/zebra_snmp.c
@@ -90,10 +90,14 @@
 oid ipfw_oid [] = { IPFWMIB };
 
 /* Hook functions. */
-u_char * ipFwNumber ();
-u_char * ipFwTable ();
-u_char * ipCidrNumber ();
-u_char * ipCidrTable ();
+static u_char * ipFwNumber (struct variable *, oid [], size_t *,
+		     int, size_t *, WriteMethod **);
+static u_char * ipFwTable (struct variable *, oid [], size_t *,
+			   int, size_t *, WriteMethod **);
+static u_char * ipCidrNumber (struct variable *, oid [], size_t *,
+			      int, size_t *, WriteMethod **);
+static u_char * ipCidrTable (struct variable *, oid [], size_t *,
+			     int, size_t *, WriteMethod **);
 
 struct variable zebra_variables[] = 
   {
@@ -133,7 +137,7 @@
   };
 
 
-u_char *
+static u_char *
 ipFwNumber (struct variable *v, oid objid[], size_t *objid_len,
 	    int exact, size_t *val_len, WriteMethod **write_method)
 {
@@ -158,7 +162,7 @@
   return (u_char *)&result;
 }
 
-u_char *
+static u_char *
 ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len,
 	      int exact, size_t *val_len, WriteMethod **write_method)
 {
@@ -183,7 +187,7 @@
   return (u_char *)&result;
 }
 
-int
+static int
 in_addr_cmp(u_char *p1, u_char *p2)
 {
   int i;
@@ -199,7 +203,7 @@
   return 0;
 }
 
-int 
+static int 
 in_addr_add(u_char *p, int num)
 {
   int i, ip0;
@@ -224,7 +228,8 @@
   return 1;
 }
 
-int proto_trans(int type)
+static int
+proto_trans(int type)
 {
   switch (type)
     {
@@ -251,7 +256,7 @@
     }
 }
 
-void
+static void
 check_replace(struct route_node *np2, struct rib *rib2, 
               struct route_node **np, struct rib **rib)
 {
@@ -294,7 +299,7 @@
   return;
 }
 
-void
+static void
 get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, 
 		       int exact, struct route_node **np, struct rib **rib)
 {
@@ -339,7 +344,7 @@
    * ipForwardDest, ipForwardProto, ipForwardPolicy, ipForwardNextHop
    */
 
-  if (*objid_len > v->namelen)
+  if (*objid_len > (unsigned) v->namelen)
     oid2in_addr (objid + v->namelen, MIN(4, *objid_len - v->namelen), &dest);
 
   if (*objid_len > (unsigned) v->namelen + 4)
@@ -441,7 +446,7 @@
   return;
 }
 
-u_char *
+static u_char *
 ipFwTable (struct variable *v, oid objid[], size_t *objid_len,
 	   int exact, size_t *val_len, WriteMethod **write_method)
 {
@@ -546,7 +551,7 @@
   return NULL;
 }
 
-u_char *
+static u_char *
 ipCidrTable (struct variable *v, oid objid[], size_t *objid_len,
 	     int exact, size_t *val_len, WriteMethod **write_method)
 {