diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-23 11:21:17 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-23 11:21:17 +0000 |
commit | 0341d5ce47c301b4a4d92b77a83930da4fdc8fb3 (patch) | |
tree | acff360d75d85e711d65e8d4fbe5139bf19b25e0 /lib | |
parent | eeda1184fa60c5077c2d404d0a8415d11e836ccd (diff) | |
download | quagga-0341d5ce47c301b4a4d92b77a83930da4fdc8fb3.tar.bz2 quagga-0341d5ce47c301b4a4d92b77a83930da4fdc8fb3.tar.xz |
Blitz on bgp_msg_read, particularly OPEN message handling
In the BGP Engine the OPEN message needs to be processed into the open_recv
structure in the *connection*. The OPEN that arrives must be checked
for acceptability before it is acknowledged. Later the connection may be
discarded in collision resolution, or the connection may become the
Established connection, and the open_recv structure is passed to the
session and hence to the Peering Engine.
modified: bgpd/bgp.h
modified: bgpd/bgp_common.c
modified: bgpd/bgp_common.h
modified: bgpd/bgp_connection.c
modified: bgpd/bgp_connection.h
modified: bgpd/bgp_fsm.c
modified: bgpd/bgp_msg_read.c
modified: bgpd/bgp_msg_read.h
modified: bgpd/bgp_msg_write.c
modified: bgpd/bgp_notification.c
modified: bgpd/bgp_notification.h
modified: bgpd/bgp_open.h
modified: bgpd/bgp_open_state.c
modified: bgpd/bgp_open_state.h
modified: bgpd/bgp_packet.c
modified: bgpd/bgp_session.h
modified: lib/distribute.c
modified: lib/if_rmap.c
modified: lib/qafi_safi.h
modified: lib/stream.c
modified: lib/stream.h
Diffstat (limited to 'lib')
-rw-r--r-- | lib/distribute.c | 66 | ||||
-rw-r--r-- | lib/if_rmap.c | 54 | ||||
-rw-r--r-- | lib/qafi_safi.h | 21 | ||||
-rw-r--r-- | lib/stream.c | 7 | ||||
-rw-r--r-- | lib/stream.h | 1 |
5 files changed, 103 insertions, 46 deletions
diff --git a/lib/distribute.c b/lib/distribute.c index 242a225c..6e7ccc67 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -34,7 +34,7 @@ struct hash *disthash; /* Hook functions. */ void (*distribute_add_hook) (struct distribute *); void (*distribute_delete_hook) (struct distribute *); - + static struct distribute * distribute_new (void) { @@ -68,11 +68,18 @@ distribute_lookup (const char *ifname) struct distribute key; struct distribute *dist; + union { + const char* waxon ; + char* waxoff ; + } miyagi ; + + miyagi.waxon = ifname ; + /* temporary reference */ - key.ifname = (char *)ifname; + key.ifname = miyagi.waxoff ; dist = hash_lookup (disthash, &key); - + return dist; } @@ -107,9 +114,16 @@ distribute_get (const char *ifname) { struct distribute key; + union { + const char* waxon ; + char* waxoff ; + } miyagi ; + + miyagi.waxon = ifname ; + /* temporary reference */ - key.ifname = (char *)ifname; - + key.ifname = miyagi.waxoff ; + return hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc); } @@ -138,10 +152,10 @@ distribute_cmp (const struct distribute *dist1, const struct distribute *dist2) return 1; return 0; } - + /* Set access-list name to the distribute list. */ static struct distribute * -distribute_list_set (const char *ifname, enum distribute_type type, +distribute_list_set (const char *ifname, enum distribute_type type, const char *alist_name) { struct distribute *dist; @@ -163,14 +177,14 @@ distribute_list_set (const char *ifname, enum distribute_type type, /* Apply this distribute-list to the interface. */ (*distribute_add_hook) (dist); - + return dist; } /* Unset distribute-list. If matched distribute-list exist then return 1. */ static int -distribute_list_unset (const char *ifname, enum distribute_type type, +distribute_list_unset (const char *ifname, enum distribute_type type, const char *alist_name) { struct distribute *dist; @@ -187,7 +201,7 @@ distribute_list_unset (const char *ifname, enum distribute_type type, return 0; free (dist->list[DISTRIBUTE_IN]); - dist->list[DISTRIBUTE_IN] = NULL; + dist->list[DISTRIBUTE_IN] = NULL; } if (type == DISTRIBUTE_OUT) @@ -198,7 +212,7 @@ distribute_list_unset (const char *ifname, enum distribute_type type, return 0; free (dist->list[DISTRIBUTE_OUT]); - dist->list[DISTRIBUTE_OUT] = NULL; + dist->list[DISTRIBUTE_OUT] = NULL; } /* Apply this distribute-list to the interface. */ @@ -241,7 +255,7 @@ distribute_list_prefix_set (const char *ifname, enum distribute_type type, /* Apply this distribute-list to the interface. */ (*distribute_add_hook) (dist); - + return dist; } @@ -265,7 +279,7 @@ distribute_list_prefix_unset (const char *ifname, enum distribute_type type, return 0; free (dist->prefix[DISTRIBUTE_IN]); - dist->prefix[DISTRIBUTE_IN] = NULL; + dist->prefix[DISTRIBUTE_IN] = NULL; } if (type == DISTRIBUTE_OUT) @@ -276,7 +290,7 @@ distribute_list_prefix_unset (const char *ifname, enum distribute_type type, return 0; free (dist->prefix[DISTRIBUTE_OUT]); - dist->prefix[DISTRIBUTE_OUT] = NULL; + dist->prefix[DISTRIBUTE_OUT] = NULL; } /* Apply this distribute-list to the interface. */ @@ -401,7 +415,7 @@ DEFUN (distribute_list, dist = distribute_list_set (argv[2], type, argv[0]); return CMD_SUCCESS; -} +} ALIAS (distribute_list, ipv6_distribute_list_cmd, @@ -442,7 +456,7 @@ DEFUN (no_districute_list, no_distribute_list_cmd, return CMD_WARNING; } return CMD_SUCCESS; -} +} ALIAS (no_districute_list, no_ipv6_distribute_list_cmd, "no distribute-list WORD (in|out) WORD", @@ -472,7 +486,7 @@ DEFUN (districute_list_prefix_all, type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", + vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); return CMD_WARNING; } @@ -481,7 +495,7 @@ DEFUN (districute_list_prefix_all, dist = distribute_list_prefix_set (NULL, type, argv[0]); return CMD_SUCCESS; -} +} ALIAS (districute_list_prefix_all, ipv6_distribute_list_prefix_all_cmd, @@ -512,7 +526,7 @@ DEFUN (no_districute_list_prefix_all, type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", + vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); return CMD_WARNING; } @@ -524,7 +538,7 @@ DEFUN (no_districute_list_prefix_all, return CMD_WARNING; } return CMD_SUCCESS; -} +} ALIAS (no_districute_list_prefix_all, no_ipv6_distribute_list_prefix_all_cmd, @@ -555,7 +569,7 @@ DEFUN (districute_list_prefix, distribute_list_prefix_cmd, type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", + vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); return CMD_WARNING; } @@ -564,7 +578,7 @@ DEFUN (districute_list_prefix, distribute_list_prefix_cmd, dist = distribute_list_prefix_set (argv[2], type, argv[0]); return CMD_SUCCESS; -} +} ALIAS (districute_list_prefix, ipv6_distribute_list_prefix_cmd, "distribute-list prefix WORD (in|out) WORD", @@ -595,7 +609,7 @@ DEFUN (no_districute_list_prefix, no_distribute_list_prefix_cmd, type = DISTRIBUTE_OUT; else { - vty_out (vty, "distribute list direction must be [in|out]%s", + vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE); return CMD_WARNING; } @@ -607,7 +621,7 @@ DEFUN (no_districute_list_prefix, no_distribute_list_prefix_cmd, return CMD_WARNING; } return CMD_SUCCESS; -} +} ALIAS (no_districute_list_prefix, no_ipv6_distribute_list_prefix_cmd, "no distribute-list prefix WORD (in|out) WORD", @@ -714,7 +728,7 @@ config_write_distribute (struct vty *vty) if (dist->list[DISTRIBUTE_IN]) { - vty_out (vty, " distribute-list %s in %s%s", + vty_out (vty, " distribute-list %s in %s%s", dist->list[DISTRIBUTE_IN], dist->ifname ? dist->ifname : "", VTY_NEWLINE); @@ -723,7 +737,7 @@ config_write_distribute (struct vty *vty) if (dist->list[DISTRIBUTE_OUT]) { - vty_out (vty, " distribute-list %s out %s%s", + vty_out (vty, " distribute-list %s out %s%s", dist->list[DISTRIBUTE_OUT], dist->ifname ? dist->ifname : "", diff --git a/lib/if_rmap.c b/lib/if_rmap.c index ddc62fd5..dfb66260 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING. If not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * 02111-1307, USA. */ #include <zebra.h> @@ -32,7 +32,7 @@ struct hash *ifrmaphash; /* Hook functions. */ static void (*if_rmap_add_hook) (struct if_rmap *) = NULL; static void (*if_rmap_delete_hook) (struct if_rmap *) = NULL; - + static struct if_rmap * if_rmap_new (void) { @@ -63,11 +63,18 @@ if_rmap_lookup (const char *ifname) struct if_rmap key; struct if_rmap *if_rmap; - /* temporary copy */ - key.ifname = (char *)ifname; + union { + const char* waxon ; + char* waxoff ; + } miyagi ; + + miyagi.waxon = ifname ; + + /* temporary reference */ + key.ifname = miyagi.waxoff ; if_rmap = hash_lookup (ifrmaphash, &key); - + return if_rmap; } @@ -100,8 +107,15 @@ if_rmap_get (const char *ifname) { struct if_rmap key; - /* temporary copy */ - key.ifname = (char *)ifname; + union { + const char* waxon ; + char* waxoff ; + } miyagi ; + + miyagi.waxon = ifname ; + + /* temporary reference */ + key.ifname = miyagi.waxoff ; return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc); } @@ -127,9 +141,9 @@ if_rmap_hash_cmp (const void *arg1, const void* arg2) return strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0; } - + static struct if_rmap * -if_rmap_set (const char *ifname, enum if_rmap_type type, +if_rmap_set (const char *ifname, enum if_rmap_type type, const char *routemap_name) { struct if_rmap *if_rmap; @@ -140,25 +154,25 @@ if_rmap_set (const char *ifname, enum if_rmap_type type, { if (if_rmap->routemap[IF_RMAP_IN]) XFREE (MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_IN]); - if_rmap->routemap[IF_RMAP_IN] + if_rmap->routemap[IF_RMAP_IN] = XSTRDUP (MTYPE_IF_RMAP_NAME, routemap_name); } if (type == IF_RMAP_OUT) { if (if_rmap->routemap[IF_RMAP_OUT]) XFREE (MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_OUT]); - if_rmap->routemap[IF_RMAP_OUT] + if_rmap->routemap[IF_RMAP_OUT] = XSTRDUP (MTYPE_IF_RMAP_NAME, routemap_name); } if (if_rmap_add_hook) (*if_rmap_add_hook) (if_rmap); - + return if_rmap; } static int -if_rmap_unset (const char *ifname, enum if_rmap_type type, +if_rmap_unset (const char *ifname, enum if_rmap_type type, const char *routemap_name) { struct if_rmap *if_rmap; @@ -175,7 +189,7 @@ if_rmap_unset (const char *ifname, enum if_rmap_type type, return 0; XFREE (MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_IN]); - if_rmap->routemap[IF_RMAP_IN] = NULL; + if_rmap->routemap[IF_RMAP_IN] = NULL; } if (type == IF_RMAP_OUT) @@ -186,7 +200,7 @@ if_rmap_unset (const char *ifname, enum if_rmap_type type, return 0; XFREE (MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_OUT]); - if_rmap->routemap[IF_RMAP_OUT] = NULL; + if_rmap->routemap[IF_RMAP_OUT] = NULL; } if (if_rmap_delete_hook) @@ -227,7 +241,7 @@ DEFUN (if_rmap, if_rmap = if_rmap_set (argv[2], type, argv[0]); return CMD_SUCCESS; -} +} ALIAS (if_rmap, if_ipv6_rmap_cmd, @@ -268,7 +282,7 @@ DEFUN (no_if_rmap, return CMD_WARNING; } return CMD_SUCCESS; -} +} ALIAS (no_if_rmap, no_if_ipv6_rmap_cmd, @@ -279,7 +293,7 @@ ALIAS (no_if_rmap, "Route map for input filtering\n" "Route map for output filtering\n" "Route map interface name\n") - + /* Configuration write function. */ int config_write_if_rmap (struct vty *vty) @@ -297,7 +311,7 @@ config_write_if_rmap (struct vty *vty) if (if_rmap->routemap[IF_RMAP_IN]) { - vty_out (vty, " route-map %s in %s%s", + vty_out (vty, " route-map %s in %s%s", if_rmap->routemap[IF_RMAP_IN], if_rmap->ifname, VTY_NEWLINE); @@ -306,7 +320,7 @@ config_write_if_rmap (struct vty *vty) if (if_rmap->routemap[IF_RMAP_OUT]) { - vty_out (vty, " route-map %s out %s%s", + vty_out (vty, " route-map %s out %s%s", if_rmap->routemap[IF_RMAP_OUT], if_rmap->ifname, VTY_NEWLINE); diff --git a/lib/qafi_safi.h b/lib/qafi_safi.h index bf0f0360..40915ca5 100644 --- a/lib/qafi_safi.h +++ b/lib/qafi_safi.h @@ -118,6 +118,27 @@ enum qSAFI } ; /*============================================================================== + * iAFI_SAFI and qAFI_SAFI structures + */ +struct iAFI_SAFI +{ + iAFI_t afi ; + iSAFI_t safi ; +} ; + +typedef struct iAFI_SAFI iAFI_SAFI_t ; +typedef struct iAFI_SAFI* iAFI_SAFI ; + +struct qAFI_SAFI +{ + qAFI_t afi ; + qSAFI_t safi ; +} ; + +typedef struct qAFI_SAFI qAFI_SAFI_t ; +typedef struct qAFI_SAFI* qAFI_SAFI ; + +/*============================================================================== * Quagga AFI/SAFI values -- original macro definitions */ diff --git a/lib/stream.c b/lib/stream.c index dc636361..79ce1791 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -215,6 +215,13 @@ stream_get_endp (struct stream *s) } size_t +stream_get_left (struct stream *s) +{ + STREAM_VERIFY_SANE(s); + return s->endp - s->getp ; +} + +size_t stream_get_size (struct stream *s) { STREAM_VERIFY_SANE(s); diff --git a/lib/stream.h b/lib/stream.h index 957bf495..094cf0c6 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -143,6 +143,7 @@ extern struct stream* stream_dup_pending(struct stream*) ; extern size_t stream_resize (struct stream *, size_t); extern size_t stream_get_getp (struct stream *); extern size_t stream_get_endp (struct stream *); +extern size_t stream_get_left (struct stream *s) ; extern size_t stream_get_size (struct stream *); extern u_char *stream_get_data (struct stream *); |