summaryrefslogtreecommitdiffstats
path: root/proto/bgp/packets.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-06-04 19:06:18 +0200
committerMartin Mares <mj@ucw.cz>2000-06-04 19:06:18 +0200
commit54e55169da71a6e6e2d8f9fbc0123297301217d7 (patch)
tree5c84c5ee47451a60b23e33d383b27c52c7e5dbbe /proto/bgp/packets.c
parent3560cf8e0b68ce0cac5a9af2aadbc09d4f529e7c (diff)
downloadbird-54e55169da71a6e6e2d8f9fbc0123297301217d7.tar
bird-54e55169da71a6e6e2d8f9fbc0123297301217d7.zip
BGP documented.
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r--proto/bgp/packets.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index 820d8d3..ffee9f7 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -236,6 +236,16 @@ bgp_create_header(byte *buf, unsigned int len, unsigned int type)
buf[18] = type;
}
+/**
+ * bgp_fire_tx - transmit packets
+ * @conn: connection
+ *
+ * Whenever the transmit buffers of the underlying TCP connection
+ * are free and we have any packets queued for sending, the socket functions
+ * call bgp_fire_tx() which takes care of selecting the highest priority packet
+ * queued (Notification > Keepalive > Open > Update), assembling its header
+ * and body and sending it to the connection.
+ */
static int
bgp_fire_tx(struct bgp_conn *conn)
{
@@ -295,6 +305,13 @@ bgp_fire_tx(struct bgp_conn *conn)
return sk_send(sk, end - buf);
}
+/**
+ * bgp_schedule_packet - schedule a packet for transmission
+ * @conn: connection
+ * @type: packet type
+ *
+ * Schedule a packet of type @type to be sent as soon as possible.
+ */
void
bgp_schedule_packet(struct bgp_conn *conn, int type)
{
@@ -770,6 +787,15 @@ bgp_rx_keepalive(struct bgp_conn *conn, byte *pkt, unsigned len)
}
}
+/**
+ * bgp_rx_packet - handle a received packet
+ * @conn: BGP connection
+ * @pkt: start of the packet
+ * @len: packet size
+ *
+ * bgp_rx_packet() takes a newly received packet and calls the corresponding
+ * packet handler according to the packet type.
+ */
static void
bgp_rx_packet(struct bgp_conn *conn, byte *pkt, unsigned len)
{
@@ -784,6 +810,16 @@ bgp_rx_packet(struct bgp_conn *conn, byte *pkt, unsigned len)
}
}
+/**
+ * bgp_rx - handle received data
+ * @sk: socket
+ * @size: amount of data received
+ *
+ * bgp_rx() is called by the socket layer whenever new data arrive from
+ * the underlying TCP connection. It assembles the data fragments to packets,
+ * checks their headers and framing and passes complete packets to
+ * bgp_rx_packet().
+ */
int
bgp_rx(sock *sk, int size)
{