summaryrefslogtreecommitdiff
path: root/lib/prefix.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h83
1 files changed, 43 insertions, 40 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index 506d644e..7afe7a1e 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -23,6 +23,8 @@
#ifndef _ZEBRA_PREFIX_H
#define _ZEBRA_PREFIX_H
+#include "sockunion.h"
+
/*
* A struct prefix contains an address family, a prefix length, and an
* address. This can represent either a 'network prefix' as defined
@@ -125,58 +127,59 @@ struct prefix_rd
#define PREFIX_FAMILY(p) ((p)->family)
/* Prototypes. */
-int afi2family (int);
-int family2afi (int);
-
-struct prefix *prefix_new ();
-void prefix_free (struct prefix *);
-const char *prefix_family_str (const struct prefix *);
-int prefix_blen (const struct prefix *);
-int str2prefix (const char *, struct prefix *);
-int prefix2str (const struct prefix *, char *, int);
-int prefix_match (const struct prefix *, const struct prefix *);
-int prefix_same (const struct prefix *, const struct prefix *);
-int prefix_cmp (const struct prefix *, const struct prefix *);
-void prefix_copy (struct prefix *dest, const struct prefix *src);
-void apply_mask (struct prefix *);
-
-struct prefix *sockunion2prefix ();
-struct prefix *sockunion2hostprefix ();
-
-struct prefix_ipv4 *prefix_ipv4_new ();
-void prefix_ipv4_free (struct prefix_ipv4 *);
-int str2prefix_ipv4 (const char *, struct prefix_ipv4 *);
-void apply_mask_ipv4 (struct prefix_ipv4 *);
-
-int prefix_ipv4_any (const struct prefix_ipv4 *);
-void apply_classful_mask_ipv4 (struct prefix_ipv4 *);
-
-u_char ip_masklen (struct in_addr);
-void masklen2ip (int, struct in_addr *);
+extern int afi2family (int);
+extern int family2afi (int);
+
+extern struct prefix *prefix_new (void);
+extern void prefix_free (struct prefix *);
+extern const char *prefix_family_str (const struct prefix *);
+extern int prefix_blen (const struct prefix *);
+extern int str2prefix (const char *, struct prefix *);
+extern int prefix2str (const struct prefix *, char *, int);
+extern int prefix_match (const struct prefix *, const struct prefix *);
+extern int prefix_same (const struct prefix *, const struct prefix *);
+extern int prefix_cmp (const struct prefix *, const struct prefix *);
+extern void prefix_copy (struct prefix *dest, const struct prefix *src);
+extern void apply_mask (struct prefix *);
+
+extern struct prefix *sockunion2prefix (const union sockunion *dest,
+ const union sockunion *mask);
+extern struct prefix *sockunion2hostprefix (const union sockunion *);
+
+extern struct prefix_ipv4 *prefix_ipv4_new (void);
+extern void prefix_ipv4_free (struct prefix_ipv4 *);
+extern int str2prefix_ipv4 (const char *, struct prefix_ipv4 *);
+extern void apply_mask_ipv4 (struct prefix_ipv4 *);
+
+extern int prefix_ipv4_any (const struct prefix_ipv4 *);
+extern void apply_classful_mask_ipv4 (struct prefix_ipv4 *);
+
+extern u_char ip_masklen (struct in_addr);
+extern void masklen2ip (int, struct in_addr *);
/* returns the network portion of the host address */
-in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);
+extern in_addr_t ipv4_network_addr (in_addr_t hostaddr, int masklen);
/* given the address of a host on a network and the network mask length,
* calculate the broadcast address for that network;
* special treatment for /31: returns the address of the other host
* on the network by flipping the host bit */
-in_addr_t ipv4_broadcast_addr (in_addr_t hostaddr, int masklen);
+extern in_addr_t ipv4_broadcast_addr (in_addr_t hostaddr, int masklen);
-int netmask_str2prefix_str (const char *, const char *, char *);
+extern int netmask_str2prefix_str (const char *, const char *, char *);
#ifdef HAVE_IPV6
-struct prefix_ipv6 *prefix_ipv6_new ();
-void prefix_ipv6_free (struct prefix_ipv6 *);
-int str2prefix_ipv6 (const char *, struct prefix_ipv6 *);
-void apply_mask_ipv6 (struct prefix_ipv6 *);
+extern struct prefix_ipv6 *prefix_ipv6_new (void);
+extern void prefix_ipv6_free (struct prefix_ipv6 *);
+extern int str2prefix_ipv6 (const char *, struct prefix_ipv6 *);
+extern void apply_mask_ipv6 (struct prefix_ipv6 *);
-int ip6_masklen (struct in6_addr);
-void masklen2ip6 (int, struct in6_addr *);
+extern int ip6_masklen (struct in6_addr);
+extern void masklen2ip6 (int, struct in6_addr *);
-void str2in6_addr (const char *, struct in6_addr *);
-const char *inet6_ntoa (struct in6_addr);
+extern void str2in6_addr (const char *, struct in6_addr *);
+extern const char *inet6_ntoa (struct in6_addr);
#endif /* HAVE_IPV6 */
-int all_digit (const char *);
+extern int all_digit (const char *);
#endif /* _ZEBRA_PREFIX_H */