From 18e5353bed3bd66c8d07b2dbb23d989239da9937 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 9 Jan 2007 20:56:31 +0000 Subject: [PATCH] Rename pkb_available() to pkb_tailroom() for consistency with Linux's skb_tailroom(). Add pkb_headroom(). --- src/arch/i386/drivers/net/undinet.c | 4 ++-- src/include/gpxe/pkbuff.h | 16 +++++++++++++--- src/net/tcp.c | 6 +++--- src/net/udp.c | 6 +++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/arch/i386/drivers/net/undinet.c b/src/arch/i386/drivers/net/undinet.c index 42b0cfb7..c53ff53c 100644 --- a/src/arch/i386/drivers/net/undinet.c +++ b/src/arch/i386/drivers/net/undinet.c @@ -437,10 +437,10 @@ static void undinet_poll ( struct net_device *netdev ) { /* Fragment will be dropped */ goto done; } - if ( frag_len > pkb_available ( pkb ) ) { + if ( frag_len > pkb_tailroom ( pkb ) ) { DBGC ( undinic, "UNDINIC %p fragment too " "large\n", undinic ); - frag_len = pkb_available ( pkb ); + frag_len = pkb_tailroom ( pkb ); } copy_from_real ( pkb_put ( pkb, frag_len ), undi_isr.Frame.segment, diff --git a/src/include/gpxe/pkbuff.h b/src/include/gpxe/pkbuff.h index 21a77167..dc3d24c4 100644 --- a/src/include/gpxe/pkbuff.h +++ b/src/include/gpxe/pkbuff.h @@ -137,12 +137,22 @@ static inline size_t pkb_len ( struct pk_buff *pkb ) { } /** - * Calculate available space in a packet buffer + * Calculate available space at start of a packet buffer * * @v pkb Packet buffer - * @ret len Length of data available in buffer + * @ret len Length of data available at start of buffer */ -static inline size_t pkb_available ( struct pk_buff *pkb ) { +static inline size_t pkb_headroom ( struct pk_buff *pkb ) { + return ( pkb->data - pkb->head ); +} + +/** + * Calculate available space at end of a packet buffer + * + * @v pkb Packet buffer + * @ret len Length of data available at end of buffer + */ +static inline size_t pkb_tailroom ( struct pk_buff *pkb ) { return ( pkb->end - pkb->tail ); } diff --git a/src/net/tcp.c b/src/net/tcp.c index 8df01f3e..b1ed0c09 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -255,7 +255,7 @@ static int tcp_senddata_conn ( struct tcp_connection *conn, int force_send ) { if ( TCP_CAN_SEND_DATA ( conn->tcp_state ) && app && app->tcp_op->senddata ) { conn->tx_pkb = pkb; - app->tcp_op->senddata ( app, pkb->data, pkb_available ( pkb )); + app->tcp_op->senddata ( app, pkb->data, pkb_tailroom ( pkb ) ); conn->tx_pkb = NULL; } @@ -364,8 +364,8 @@ int tcp_send ( struct tcp_application *app, const void *data, size_t len ) { } /* Truncate length to fit packet buffer */ - if ( len > pkb_available ( pkb ) ) - len = pkb_available ( pkb ); + if ( len > pkb_tailroom ( pkb ) ) + len = pkb_tailroom ( pkb ); /* Copy payload */ memmove ( pkb_put ( pkb, len ), data, len ); diff --git a/src/net/udp.c b/src/net/udp.c index ffe282c9..0a9cea8b 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -104,7 +104,7 @@ int udp_senddata ( struct udp_connection *conn ) { } pkb_reserve ( conn->tx_pkb, UDP_MAX_HLEN ); rc = conn->udp_op->senddata ( conn, conn->tx_pkb->data, - pkb_available ( conn->tx_pkb ) ); + pkb_tailroom ( conn->tx_pkb ) ); if ( conn->tx_pkb ) free_pkb ( conn->tx_pkb ); return rc; @@ -137,8 +137,8 @@ int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer, conn->tx_pkb = NULL; /* Avoid overflowing TX buffer */ - if ( len > pkb_available ( pkb ) ) - len = pkb_available ( pkb ); + if ( len > pkb_tailroom ( pkb ) ) + len = pkb_tailroom ( pkb ); /* Copy payload */ memmove ( pkb_put ( pkb, len ), data, len );