Fix most compiler warnings in default GCC build.

Fix lots of warnings. Some const and type-pun breaks strict-aliasing
warnings left but much reduced.

* bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to
  (struct fifo), so just use that.  Makes it clearer the beginning of
  (struct bgp_advertise) is compatible with with (struct fifo), which seems
  to be enough for gcc.
  Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up
  type-punning breaks strict aliasing warnings.
* bgp_packet.c: Use BGP_ADV_FIFO_HEAD.
  (bgp_route_refresh_receive) fix an interesting logic error in
  (!ok || (ret != BLAH)) where ret is only well-defined if ok.
* bgp_vty.c: Peer commands should use bgp_vty_return to set their return.
* jhash.{c,h}: Can take const on * args without adding issues & fix warnings.
* libospf.h: LSA sequence numbers use the unsigned range of values, and
  constants need to be set to unsigned, or it causes warnings in ospf6d.
* md5.h: signedness of caddr_t is implementation specific, change to an
  explicit (uint_8 *), fix sign/unsigned comparison warnings.
* vty.c: (vty_log_fixed) const on level is well-intentioned, but not going
  to fly given iov_base.
* workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always
  true for address of static variable.  Correct but pointless warning in
  this case, but use a 2nd pointer to shut it up.
* ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2
  different 32 bit IDs into in (struct ospf6_route), and the resulting
  type-pun strict-alias breakage warnings this causes.  Need to use 2
  different fields to fix that warning?

general:

* remove unused variables, other than a few cases where they serve a
  sufficiently useful documentary purpose (e.g.  for code that needs
  fixing), or they're required dummies.  In those cases, try mark them as
  unused.
* Remove dead code that can't be reached.
* Quite a few 'no ...' forms of vty commands take arguments, but do not
  check the argument matches the command being negated.  E.g., should
  'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set?
  Or should it be required that the distance match the previously configured
  distance for the prefix?
  Ultimately, probably better to be strict about this.  However, changing
  from slack to strict might expose problems in command aliases and tools.
* Fix uninitialised use of variables.
* Fix sign/unsigned comparison warnings by making signedness of types consistent.
* Mark functions as static where their use is restricted to the same compilation
  unit.
* Add required headers
* Move constants defined in headers into code.
* remove dead, unused functions that have no debug purpose.
diff --git a/ospf6d/ospf6_abr.h b/ospf6d/ospf6_abr.h
index 816f596..e5e2660 100644
--- a/ospf6d/ospf6_abr.h
+++ b/ospf6d/ospf6_abr.h
@@ -24,6 +24,8 @@
 
 /* for struct ospf6_route */
 #include "ospf6_route.h"
+/* for struct ospf6_prefix */
+#include "ospf6_proto.h"
 
 /* Debug option */
 extern unsigned char conf_debug_ospf6_abr;
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 4b4ca13..9b70422 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -518,13 +518,11 @@
        "Filter networks sent from this area\n")
 {
   struct ospf6_area *area;
-  struct prefix_list *plist;
 
   OSPF6_CMD_AREA_GET (argv[0], area);
   argc--;
   argv++;
 
-  plist = prefix_list_lookup (AFI_IP6, argv[0]);
   if (strncmp (argv[1], "in", 2) == 0)
     {
       if (PREFIX_NAME_IN (area))
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 6ba6cdf..b1620d4 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -58,18 +58,13 @@
 {
   char buffer[OSPF6_MAX_LSASIZE];
   struct ospf6_lsa_header *lsa_header;
-  struct ospf6_lsa *old, *lsa;
+  struct ospf6_lsa *lsa;
   struct ospf6_external_info *info = route->route_option;
 
   struct ospf6_as_external_lsa *as_external_lsa;
   char buf[64];
   caddr_t p;
 
-  /* find previous LSA */
-  old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_AS_EXTERNAL),
-                           route->path.origin.id, ospf6->router_id,
-                           ospf6->lsdb);
-
   if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE (AS_EXTERNAL))
     {
       prefix2str (&route->prefix, buf, sizeof (buf));
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index f0ef790..772caff 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -1283,7 +1283,6 @@
 {
   struct ospf6_interface *oi;
   struct interface *ifp;
-  unsigned long int lcost;
 
   ifp = (struct interface *) vty->index;
   assert (ifp);
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 2e61535..e57306b 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -493,7 +493,7 @@
   vty_out (vty, "Flag: %x %s", lsa->flag, VNL);
   vty_out (vty, "Lock: %d %s", lsa->lock, VNL);
   vty_out (vty, "ReTx Count: %d%s", lsa->retrans_count, VNL);
-  vty_out (vty, "Threads: Expire: %x, Refresh: %x %s",
+  vty_out (vty, "Threads: Expire: 0x%p, Refresh: 0x%p %s",
 	   lsa->expire, lsa->refresh, VNL);
   vty_out (vty, "%s", VNL);
   return;
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 7f6c6c5..f20c83b 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -46,6 +46,31 @@
 { "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange",
   "Loading", "Full", NULL };
 
+static const char *ospf6_neighbor_event_str[] =
+  {
+    "NoEvent",
+    "HelloReceived",
+    "2-WayReceived",
+    "NegotiationDone",
+    "ExchangeDone",
+    "LoadingDone",
+    "AdjOK?",
+    "SeqNumberMismatch",
+    "BadLSReq",
+    "1-WayReceived",
+    "InactivityTimer",
+  };
+
+static const char *
+ospf6_neighbor_event_string (int event)
+{
+  #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
+
+  if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
+      return ospf6_neighbor_event_str[event];
+  return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
+}
+
 int
 ospf6_neighbor_cmp (void *va, void *vb)
 {
diff --git a/ospf6d/ospf6_neighbor.h b/ospf6d/ospf6_neighbor.h
index 65c43fd..93ffa28 100644
--- a/ospf6d/ospf6_neighbor.h
+++ b/ospf6d/ospf6_neighbor.h
@@ -122,33 +122,8 @@
 #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER    10
 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT           11
 
-static const char *ospf6_neighbor_event_str[] =
-  {
-    "NoEvent",
-    "HelloReceived",
-    "2-WayReceived",
-    "NegotiationDone",
-    "ExchangeDone",
-    "LoadingDone",
-    "AdjOK?",
-    "SeqNumberMismatch",
-    "BadLSReq",
-    "1-WayReceived",
-    "InactivityTimer",
-  };
-
-static const char *ospf6_neighbor_event_string (int event)
-{
-  #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
-
-  if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
-      return ospf6_neighbor_event_str[event];
-  return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
-}
-
 extern const char *ospf6_neighbor_state_str[];
 
-
 /* Function Prototypes */
 int ospf6_neighbor_cmp (void *va, void *vb);
 void ospf6_neighbor_dbex_init (struct ospf6_neighbor *on);
diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c
index 74cfbec..e0be38b 100644
--- a/ospf6d/ospf6_network.c
+++ b/ospf6d/ospf6_network.c
@@ -37,18 +37,8 @@
 struct in6_addr allspfrouters6;
 struct in6_addr alldrouters6;
 
-/* setsockopt ReUseAddr to on */
-void
-ospf6_set_reuseaddr (void)
-{
-  u_int on = 0;
-  if (setsockopt (ospf6_sock, SOL_SOCKET, SO_REUSEADDR, &on,
-                  sizeof (u_int)) < 0)
-    zlog_warn ("Network: set SO_REUSEADDR failed: %s", safe_strerror (errno));
-}
-
 /* setsockopt MulticastLoop to off */
-void
+static void
 ospf6_reset_mcastloop (void)
 {
   u_int off = 0;
@@ -58,13 +48,13 @@
                safe_strerror (errno));
 }
 
-void
+static void
 ospf6_set_pktinfo (void)
 {
   setsockopt_ipv6_pktinfo (ospf6_sock, 1);
 }
 
-void
+static void
 ospf6_set_transport_class (void)
 {
 #ifdef IPTOS_PREC_INTERNETCONTROL
@@ -72,7 +62,7 @@
 #endif
 }
 
-void
+static void
 ospf6_set_checksum (void)
 {
   int offset = 12;
diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h
index 947834d..127bf45 100644
--- a/ospf6d/ospf6_network.h
+++ b/ospf6d/ospf6_network.h
@@ -28,12 +28,6 @@
 extern struct in6_addr allspfrouters6;
 extern struct in6_addr alldrouters6;
 
-/* Function Prototypes */
-extern void ospf6_set_reuseaddr (void);
-extern void ospf6_reset_mcastloop (void);
-extern void ospf6_set_pktinfo (void);
-extern void ospf6_set_checksum (void);
-
 extern int ospf6_serv_sock (void);
 extern void ospf6_sso (u_int ifindex, struct in6_addr *group, int option);
 
diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h
index b384824..c0dcf9f 100644
--- a/ospf6d/ospf6_route.h
+++ b/ospf6d/ospf6_route.h
@@ -122,6 +122,10 @@
   /* Destination Type */
   u_char type;
 
+  /* XXX: It would likely be better to use separate struct in_addr's
+   * for the advertising router-ID and prefix IDs, instead of stuffing them
+   * into one. See also XXX below.
+   */
   /* Destination ID */
   struct prefix prefix;
 
@@ -235,6 +239,7 @@
            sizeof (struct ospf6_nexthop) * OSPF6_MULTI_PATH_LIMIT) == 0)
 #define ospf6_route_is_best(r) (CHECK_FLAG ((r)->flag, OSPF6_ROUTE_BEST))
 
+/* XXX: This gives GCC heartburn aboutbreaking aliasing rules. */
 #define ospf6_linkstate_prefix_adv_router(x) \
   (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[0]))
 #define ospf6_linkstate_prefix_id(x) \
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index 3ef5485..d0e9101 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -40,6 +40,7 @@
 #include "ospf6_intra.h"
 #include "ospf6_interface.h"
 #include "ospf6d.h"
+#include "ospf6_abr.h"
 
 unsigned char conf_debug_ospf6_spf = 0;
 
@@ -391,7 +392,7 @@
 
 void ospf6_spf_reason_string (unsigned int reason, char *buf, int size)
 {
-  int bit;
+  size_t bit;
   int len = 0;
 
   if (!buf)
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 7191270..e4e6f17 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -180,6 +180,7 @@
 }
 
 static void
+__attribute__((unused))
 ospf6_enable (struct ospf6 *o)
 {
   struct listnode *node, *nnode;
@@ -219,7 +220,7 @@
     }
 }
 
-int
+static int
 ospf6_maxage_remover (struct thread *thread)
 {
   struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
@@ -471,14 +472,11 @@
        "OSPF6 area ID in IPv4 address notation\n"
        )
 {
-  struct ospf6 *o;
   struct ospf6_interface *oi;
   struct ospf6_area *oa;
   struct interface *ifp;
   u_int32_t area_id;
 
-  o = (struct ospf6 *) vty->index;
-
   ifp = if_lookup_by_name (argv[0]);
   if (ifp == NULL)
     {