2005-05-23 Paul Jakma <paul@dishone.st>

	* bgp_fsm.h: Add extern qualifier to exported functions
	* bgp_nexthop.c: add static to nexthop specific globals
	* *.h: Add guard defines
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 3d90346..686a642 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,6 +1,9 @@
 2005-05-23 Paul Jakma <paul@dishone.st>
 
 	* bgp_routemap.c: add semi-colons to VTY_GET_* to match vty.h change
+	* bgp_fsm.h: Add extern qualifier to exported functions
+	* bgp_nexthop.c: add static to nexthop specific globals
+	* *.h: Add guard defines
 
 2005-05-19 Paul Jakma <paul@dishone.st>
 
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h
index e2ae010..995245a 100644
--- a/bgpd/bgp_advertise.h
+++ b/bgpd/bgp_advertise.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ADVERTISE_H
+#define _QUAGGA_BGP_ADVERTISE_H
+
 /* BGP advertise FIFO.  */
 struct bgp_advertise_fifo
 {
@@ -99,39 +102,6 @@
   struct bgp_advertise_fifo withdraw_low;
 };
 
-/* FIFO -- first in first out structure and macros.  */
-struct fifo
-{
-  struct fifo *next;
-  struct fifo *prev;
-};
-
-#define FIFO_INIT(F)                                  \
-  do {                                                \
-    struct fifo *Xfifo = (struct fifo *)(F);          \
-    Xfifo->next = Xfifo->prev = Xfifo;                \
-  } while (0)
-
-#define FIFO_ADD(F,N)                                 \
-  do {                                                \
-    struct fifo *Xfifo = (struct fifo *)(F);          \
-    struct fifo *Xnode = (struct fifo *)(N);          \
-    Xnode->next = Xfifo;                              \
-    Xnode->prev = Xfifo->prev;                        \
-    Xfifo->prev = Xfifo->prev->next = Xnode;          \
-  } while (0)
-
-#define FIFO_DEL(N)                                   \
-  do {                                                \
-    struct fifo *Xnode = (struct fifo *)(N);          \
-    Xnode->prev->next = Xnode->next;                  \
-    Xnode->next->prev = Xnode->prev;                  \
-  } while (0)
-
-#define FIFO_HEAD(F)                                  \
-  ((((struct fifo *)(F))->next == (struct fifo *)(F)) \
-  ? NULL : (F)->next)
-
 /* BGP adjacency linked list.  */
 #define BGP_INFO_ADD(N,A,TYPE)                        \
   do {                                                \
@@ -176,3 +146,5 @@
 
 void bgp_sync_init (struct peer *);
 void bgp_sync_delete (struct peer *);
+
+#endif /* _QUAGGA_BGP_ADVERTISE_H */
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index bfe4f5e..a140d40 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ASPATH_H
+#define _QUAGGA_BGP_ASPATH_H
+
 /* AS path segment type.  */
 #define AS_SET                       1
 #define AS_SEQUENCE                  2
@@ -80,3 +83,5 @@
 int aspath_private_as_check (struct aspath *);
 int aspath_firstas_check (struct aspath *, as_t);
 unsigned long aspath_count ();
+
+#endif /* _QUAGGA_BGP_ASPATH_H */
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index c9acc71..70e27ae 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ATTR_H
+#define _QUAGGA_BGP_ATTR_H
+
 /* Simple bit mapping. */
 #define BITMAP_NBBY 8
 
@@ -132,3 +135,5 @@
 
 /* Transit attribute prototypes. */
 void transit_unintern (struct transit *);
+
+#endif /* _QUAGGA_BGP_ATTR_H */
diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h
index 6f1faf0..ad6491e 100644
--- a/bgpd/bgp_clist.h
+++ b/bgpd/bgp_clist.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_CLIST_H
+#define _QUAGGA_BGP_CLIST_H
+
 /* Master Community-list. */
 #define COMMUNITY_LIST_MASTER          0
 #define EXTCOMMUNITY_LIST_MASTER       1
@@ -145,3 +148,5 @@
 struct community *
 community_list_match_delete (struct community *,
 			     struct community_list *);
+
+#endif /* _QUAGGA_BGP_CLIST_H */
diff --git a/bgpd/bgp_community.h b/bgpd/bgp_community.h
index 016b0f6..21a9419 100644
--- a/bgpd/bgp_community.h
+++ b/bgpd/bgp_community.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_COMMUNITY_H
+#define _QUAGGA_BGP_COMMUNITY_H
+
 /* Communities attribute.  */
 struct community 
 {
@@ -66,3 +69,5 @@
 void community_del_val (struct community *, u_int32_t *);
 unsigned long community_count ();
 struct hash *community_hash ();
+
+#endif /* _QUAGGA_BGP_COMMUNITY_H */
diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h
index 09b953e..1aa2508 100644
--- a/bgpd/bgp_damp.h
+++ b/bgpd/bgp_damp.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_DAMP_H
+#define _QUAGGA_BGP_DAMP_H
+
 /* Structure maintained on a per-route basis. */
 struct bgp_damp_info
 {
@@ -140,3 +143,5 @@
 int bgp_config_write_damp (struct vty *);
 void bgp_damp_info_vty (struct vty *, struct bgp_info *);
 char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *);
+
+#endif /* _QUAGGA_BGP_DAMP_H */
diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h
index d060961..6f95184 100644
--- a/bgpd/bgp_debug.h
+++ b/bgpd/bgp_debug.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_DEBUG_H
+#define _QUAGGA_BGP_DEBUG_H
+
 /* sort of packet direction */
 #define DUMP_ON        1
 #define DUMP_SEND      2
@@ -111,3 +114,5 @@
 
 extern struct message bgp_status_msg[];
 extern int bgp_status_msg_max;
+
+#endif /* _QUAGGA_BGP_DEBUG_H */
diff --git a/bgpd/bgp_dump.h b/bgpd/bgp_dump.h
index b4479e5..16aa126 100644
--- a/bgpd/bgp_dump.h
+++ b/bgpd/bgp_dump.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_DUMP_H
+#define _QUAGGA_BGP_DUMP_H
+
 /* MRT compatible packet dump values.  */
 /* type value */
 #define MSG_PROTOCOL_BGP4MP  16
@@ -33,3 +36,5 @@
 void bgp_dump_init ();
 void bgp_dump_state (struct peer *, int, int);
 void bgp_dump_packet (struct peer *, int, struct stream *);
+
+#endif /* _QUAGGA_BGP_DUMP_H */
diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h
index 56e9f18..0dbd12c 100644
--- a/bgpd/bgp_ecommunity.h
+++ b/bgpd/bgp_ecommunity.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ECOMMUNITY_H
+#define _QUAGGA_BGP_ECOMMUNITY_H
+
 /* High-order octet of the Extended Communities type field.  */
 #define ECOMMUNITY_ENCODE_AS                0x00
 #define ECOMMUNITY_ENCODE_IP                0x01
@@ -75,3 +78,5 @@
 char *ecommunity_ecom2str (struct ecommunity *, int);
 int ecommunity_match (const struct ecommunity *, const struct ecommunity *);
 char *ecommunity_str (struct ecommunity *);
+
+#endif /* _QUAGGA_BGP_ECOMMUNITY_H */
diff --git a/bgpd/bgp_filter.h b/bgpd/bgp_filter.h
index ec48ca1..77d74c9 100644
--- a/bgpd/bgp_filter.h
+++ b/bgpd/bgp_filter.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_FILTER_H
+#define _QUAGGA_BGP_FILTER_H
+
 enum as_filter_type
 {
   AS_FILTER_DENY,
@@ -29,3 +32,5 @@
 struct as_list *as_list_lookup (const char *);
 void as_list_add_hook (void (*func) ());
 void as_list_delete_hook (void (*func) ());
+
+#endif /* _QUAGGA_BGP_FILTER_H */
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index 20fc2d7..db4a915 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -19,6 +19,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_FSM_H
+#define _QUAGGA_BGP_FSM_H
+
 /* Macro for BGP read, write and timer thread.  */
 #define BGP_READ_ON(T,F,V)   THREAD_READ_ON(master,T,F,peer,V)
 #define BGP_READ_OFF(X)      THREAD_READ_OFF(X)
@@ -36,8 +39,10 @@
     thread_cancel_event (master, (P))
 
 /* Prototypes. */
-int bgp_event (struct thread *);
-int bgp_stop (struct peer *peer);
-void bgp_timer_set (struct peer *);
-void bgp_fsm_change_status (struct peer *peer, int status);
+extern int bgp_event (struct thread *);
+extern int bgp_stop (struct peer *peer);
+extern void bgp_timer_set (struct peer *);
+extern void bgp_fsm_change_status (struct peer *peer, int status);
 extern const char *peer_down_str[];
+
+#endif /* _QUAGGA_BGP_FSM_H */
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index 5d8d6fb..6be37b8 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_MPLSVPN_H
+#define _QUAGGA_BGP_MPLSVPN_H
+
 #define RD_TYPE_AS      0
 #define RD_TYPE_IP      1
 
@@ -43,3 +46,5 @@
 int str2prefix_rd (const char *, struct prefix_rd *);
 int str2tag (const char *, u_char *);
 char *prefix_rd2str (struct prefix_rd *, char *, size_t);
+
+#endif /* _QUAGGA_BGP_MPLSVPN_H */
diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h
index b994987..7bcd25a 100644
--- a/bgpd/bgp_network.h
+++ b/bgpd/bgp_network.h
@@ -18,6 +18,11 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_NETWORK_H
+#define _QUAGGA_BGP_NETWORK_H
+
 int bgp_socket (struct bgp *, unsigned short);
 int bgp_connect (struct peer *);
 void bgp_getsockname (struct peer *);
+
+#endif /* _QUAGGA_BGP_NETWORK_H */
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index df55f32..20434e1 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -45,24 +45,24 @@
 #endif /* HAVE_IPV6 */
 
 /* Only one BGP scan thread are activated at the same time. */
-struct thread *bgp_scan_thread = NULL;
+static struct thread *bgp_scan_thread = NULL;
 
 /* BGP import thread */
-struct thread *bgp_import_thread = NULL;
+static struct thread *bgp_import_thread = NULL;
 
 /* BGP scan interval. */
-int bgp_scan_interval;
+static int bgp_scan_interval;
 
 /* BGP import interval. */
-int bgp_import_interval;
+static int bgp_import_interval;
 
 /* Route table for next-hop lookup cache. */
-struct bgp_table *bgp_nexthop_cache_table[AFI_MAX];
-struct bgp_table *cache1_table[AFI_MAX];
-struct bgp_table *cache2_table[AFI_MAX];
+static struct bgp_table *bgp_nexthop_cache_table[AFI_MAX];
+static struct bgp_table *cache1_table[AFI_MAX];
+static struct bgp_table *cache2_table[AFI_MAX];
 
 /* Route table for connected route. */
-struct bgp_table *bgp_connected_table[AFI_MAX];
+static struct bgp_table *bgp_connected_table[AFI_MAX];
 
 /* BGP nexthop lookup query client. */
 static struct zclient *zlookup = NULL;
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index 5f4255d..733f518 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_NEXTHOP_H
+#define _QUAGGA_BGP_NEXTHOP_H
+
 #define BGP_SCAN_INTERVAL_DEFAULT   60
 #define BGP_IMPORT_INTERVAL_DEFAULT 15
 
@@ -50,3 +53,5 @@
 int bgp_config_write_scan_time (struct vty *);
 int bgp_nexthop_check_ebgp (afi_t, struct attr *);
 int bgp_nexthop_self (afi_t, struct attr *);
+
+#endif /* _QUAGGA_BGP_NEXTHOP_H */
diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h
index 014bc33..aa7f8cb 100644
--- a/bgpd/bgp_open.h
+++ b/bgpd/bgp_open.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_OPEN_H
+#define _QUAGGA_BGP_OPEN_H
+
 /* MP Capability information. */
 struct capability_mp
 {
@@ -79,3 +82,5 @@
 int bgp_open_option_parse (struct peer *, u_char, int *);
 void bgp_open_capability (struct stream *, struct peer *);
 void bgp_capability_vty_out (struct vty *, struct peer *);
+
+#endif /* _QUAGGA_BGP_OPEN_H */
diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h
index d9afd5c..6576a56 100644
--- a/bgpd/bgp_packet.h
+++ b/bgpd/bgp_packet.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_PACKET_H
+#define _QUAGGA_BGP_PACKET_H
+
 #define BGP_NLRI_LENGTH       1U
 #define BGP_TOTAL_ATTR_LEN    2U
 #define BGP_UNFEASIBLE_LEN    2U
@@ -48,3 +51,5 @@
 void bgp_default_update_send (struct peer *, struct attr *,
 			      afi_t, safi_t, struct peer *);
 void bgp_default_withdraw_send (struct peer *, afi_t, safi_t);
+
+#endif /* _QUAGGA_BGP_PACKET_H */
diff --git a/bgpd/bgp_regex.h b/bgpd/bgp_regex.h
index 1320711..3e0905f 100644
--- a/bgpd/bgp_regex.h
+++ b/bgpd/bgp_regex.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_REGEX_H
+#define _QUAGGA_BGP_REGEX_H
+
 #include <zebra.h>
 
 #ifdef HAVE_GNU_REGEX
@@ -29,3 +32,5 @@
 void bgp_regex_free (regex_t *regex);
 regex_t *bgp_regcomp (const char *str);
 int bgp_regexec (regex_t *regex, struct aspath *aspath);
+
+#endif /* _QUAGGA_BGP_REGEX_H */
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 46ae54d..0c96a79 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ROUTE_H
+#define _QUAGGA_BGP_ROUTE_H
+
 struct bgp_info
 {
   /* For linked list. */
@@ -173,3 +176,5 @@
 void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
 void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
 void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t);
+
+#endif /* _QUAGGA_BGP_ROUTE_H */
diff --git a/bgpd/bgp_snmp.h b/bgpd/bgp_snmp.h
index a8af032..60daf0f 100644
--- a/bgpd/bgp_snmp.h
+++ b/bgpd/bgp_snmp.h
@@ -18,6 +18,11 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_SNMP_H
+#define _QUAGGA_BGP_SNMP_H
+
 void bgp_snmp_init ();
 void bgpTrapEstablished (struct peer *);
 void bgpTrapBackwardTransition (struct peer *);
+
+#endif /* _QUAGGA_BGP_SNMP_H */
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index f979ac6..b964079 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_TABLE_H
+#define _QUAGGA_BGP_TABLE_H
+
 typedef enum
 {
   BGP_TABLE_MAIN,
@@ -74,3 +77,5 @@
 struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *,
 					  struct in6_addr *);
 #endif /* HAVE_IPV6 */
+
+#endif /* _QUAGGA_BGP_TABLE_H */
diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h
index 74bc185..5256728 100644
--- a/bgpd/bgp_vty.h
+++ b/bgpd/bgp_vty.h
@@ -18,5 +18,10 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_VTY_H
+#define _QUAGGA_BGP_VTY_H
+
 void bgp_vty_init ();
 char *afi_safi_print (afi_t, safi_t);
+
+#endif /* _QUAGGA_BGP_VTY_H */
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index d8407e8..84577e1 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -18,6 +18,9 @@
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGP_ZEBRA_H
+#define _QUAGGA_BGP_ZEBRA_H
+
 int bgp_if_update_all ();
 int bgp_config_write_redistribute (struct vty *, struct bgp *, afi_t, safi_t,
 				   int *);
@@ -37,3 +40,5 @@
 struct interface *if_lookup_by_ipv6 (struct in6_addr *);
 struct interface *if_lookup_by_ipv6_exact (struct in6_addr *);
 #endif /* HAVE_IPV6 */
+
+#endif /* _QUAGGA_BGP_ZEBRA_H */
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index a0cf7e8..f2b75de 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -18,6 +18,9 @@
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef _QUAGGA_BGPD_H
+#define _QUAGGA_BGPD_H
+
 /* For union sockunion.  */
 #include "sockunion.h"
 
@@ -905,3 +908,5 @@
 int peer_clear_soft (struct peer *, afi_t, safi_t, enum bgp_clear_type);
 
 void peer_nsf_stop (struct peer *);
+
+#endif /* _QUAGGA_BGPD_H */