Author: adrian.chadd
Date: Mon Feb 23 22:59:22 2009
New Revision: 13858
Modified:
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_conn.c
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_core.c
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c
playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.h
Log:
Strip out bgp_instance_t from being needed in bgp_packet.c
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_conn.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_conn.c (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_conn.c Mon Feb 23 22:59:22 2009
@@ -88,7 +88,7 @@
if (hold_timer <= 0)
return;
- r = bgp_send_keepalive(&bc->bi, bc->fd);
+ r = bgp_send_keepalive(bc->fd);
if (r <= 0) {
bgp_conn_close_and_restart(bc);
return;
@@ -156,7 +156,7 @@
switch(bc->bi.state) {
case BGP_OPEN:
/* Send OPEN; set state to OPEN_CONFIRM */
- r = bgp_send_hello(&bc->bi, fd, bc->bi.lcl.asn,
bc->bi.lcl.hold_timer, bc->bi.lcl.bgp_id);
+ r = bgp_send_hello(fd, bc->bi.lcl.asn,
bc->bi.lcl.hold_timer,
bc->bi.lcl.bgp_id);
if (r <= 0) {
bgp_conn_close_and_restart(bc);
return;
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_core.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_core.c (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_core.c Mon Feb 23 22:59:22 2009
@@ -88,6 +88,7 @@
u_int8_t type;
u_int16_t pkt_len;
bgp_update_state_t us;
+ bgp_open_state_t os;
int i;
/* XXX should check the marker is 16 bytes */
@@ -98,7 +99,16 @@
debug(85, 2) ("bgp_decode_message: type %d; len %d\n", type,
pkt_len);
switch (type) {
case 1: /* OPEN */
- r = bgp_handle_open(bi, fd, buf + 19, pkt_len -
19);
+ r = bgp_handle_open(buf + 19, pkt_len - 19, &os);
+ /* handle error? */
+ bi->rem.asn = os.asn;
+ bi->rem.hold_timer = os.hold_timer;
+ bi->rem.version = os.version;
+ memcpy(&bi->rem.bgp_id, &os.bgp_id, sizeof(struct
in_addr));
+ bgp_free_open(&os);
+
+ /* Queue a keepalive message */
+ bgp_send_keepalive(fd);
break;
case 2: /* UPDATE */
r = bgp_handle_update(buf + 19, pkt_len - 19, &us);
@@ -115,7 +125,7 @@
bgp_free_update(&us);
break;
case 3: /* NOTIFICATION */
- r = bgp_handle_notification(bi, fd, buf + 19,
pkt_len - 19);
+ r = bgp_handle_notification(fd, buf + 19, pkt_len
- 19);
break;
case 4: /* KEEPALIVE */
r = bgp_handle_keepalive(fd, buf + 19, pkt_len -
19);
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c Mon Feb 23 22:59:22 2009
@@ -72,7 +72,7 @@
* XXX absolutely hacky!
*/
int
-bgp_send_hello(bgp_instance_t *bi, int fd, unsigned short asnum, short
hold_time, struct in_addr bgp_id)
+bgp_send_hello(int fd, unsigned short asnum, short hold_time, struct
in_addr bgp_id)
{
char send_buf[128];
char *p = send_buf;
@@ -127,7 +127,7 @@
}
int
-bgp_send_keepalive(bgp_instance_t *bi, int fd)
+bgp_send_keepalive(int fd)
{
char send_buf[128];
char *p = send_buf;
@@ -159,7 +159,7 @@
}
int
-bgp_handle_notification(bgp_instance_t *bi, int fd, const char *buf, int
len)
+bgp_handle_notification(int fd, const char *buf, int len)
{
u_int8_t err_code;
u_int8_t err_subcode;
@@ -173,27 +173,28 @@
}
int
-bgp_handle_open(bgp_instance_t *bi, int fd, const char *buf, int len)
+bgp_handle_open(const char *buf, int len, bgp_open_state_t *os)
{
- int parm_len;
-
/* XXX should ensure we have enough space! */
/* XXX should check version!? */
- bi->rem.version = * (u_int8_t *) buf;
- bi->rem.asn = ntohs(* (u_int16_t *) (buf + 1));
- bi->rem.hold_timer = ntohs(* (u_int16_t *) (buf + 3));
- memcpy(&bi->rem.bgp_id, buf + 5, 4);
+ os->version = * (u_int8_t *) buf;
+ os->asn = ntohs(* (u_int16_t *) (buf + 1));
+ os->hold_timer = ntohs(* (u_int16_t *) (buf + 3));
+ memcpy(&os->bgp_id, buf + 5, 4);
- parm_len = * (u_int8_t *) (buf + 9);
+ os->parm_len = * (u_int8_t *) (buf + 9);
/* XXX don't bother decoding the OPEN parameters for now! */
- debug(85, 2) ("bgp_handle_open: got version %d, AS %d, timer %d,
parm_len %d\n", bi->rem.version, bi->rem.asn, bi->rem.hold_timer, parm_len);
-
- /* Queue a keepalive message */
- bgp_send_keepalive(bi, fd);
+ debug(85, 2) ("bgp_handle_open: got version %d, AS %d, timer %d,
parm_len %d\n", os->version, os->asn, os->hold_timer, os->parm_len);
return 1;
+}
+
+void
+bgp_free_open(bgp_open_state_t *os)
+{
+
}
int
Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.h
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.h (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.h Mon Feb 23 22:59:22 2009
@@ -6,8 +6,14 @@
extern int bgp_msg_isvalid(const char *buf, int len);
extern int bgp_msg_complete(const char *buf, int len);
-/* XXX eww? */
-struct _bgp_instance;
+struct _bgp_open_state {
+ u_int8_t version;
+ u_int16_t asn;
+ u_int16_t hold_timer;
+ struct in_addr bgp_id;
+ u_int8_t parm_len;
+};
+typedef struct _bgp_open_state bgp_open_state_t;
struct _bgp_update_state {
u_int8_t aspath_type;
@@ -24,19 +30,18 @@
};
typedef struct _bgp_update_state bgp_update_state_t;
-/*
- * XXX can we get away with -not- passing in the bgp_instance here?
- * XXX now that the RIB related stuff can be done elsewhere?
- */
-extern int bgp_send_keepalive(struct _bgp_instance *bi, int fd);
-extern int bgp_send_hello(struct _bgp_instance *bi, int fd, unsigned short
asnum, short hold_time, struct in_addr bgp_id);
+extern int bgp_send_keepalive(int fd);
+extern int bgp_send_hello(int fd, unsigned short asnum, short hold_time,
struct in_addr bgp_id);
+
+extern int bgp_handle_open(const char *buf, int len, bgp_open_state_t *os);
+extern void bgp_free_open(bgp_open_state_t *os);
-extern int bgp_handle_open(struct _bgp_instance *bi, int fd, const char
*buf, int len);
extern int bgp_handle_update(const char *buf, int len, bgp_update_state_t
*us);
-extern int bgp_handle_notification(struct _bgp_instance *bi, int fd, const
char *buf, int len);
+extern void bgp_free_update(bgp_update_state_t *us);
+
+extern int bgp_handle_notification(int fd, const char *buf, int len);
extern int bgp_handle_keepalive(int fd, const char *buf, int len);
-extern void bgp_free_update(bgp_update_state_t *us);
#endif
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---