diff options
author | Anselm Martin Hoffmeister <stockholm@users.sourceforge.net> | 2007-04-09 17:34:10 +0000 |
---|---|---|
committer | Anselm Martin Hoffmeister <stockholm@users.sourceforge.net> | 2007-04-09 17:34:10 +0000 |
commit | ff5aac826ae2019476b20ab7143e7f80e3cf26c7 (patch) | |
tree | 46e80af209be852ed7f74aca328365ffd125440e /src/net/udp.c | |
parent | 0d9b3e2dd259674f322f0b777ad21b2e0551a1d5 (diff) | |
download | ipxe-ff5aac826ae2019476b20ab7143e7f80e3cf26c7.zip ipxe-ff5aac826ae2019476b20ab7143e7f80e3cf26c7.tar.gz ipxe-ff5aac826ae2019476b20ab7143e7f80e3cf26c7.tar.bz2 |
hoffmeis: Fixing situation where absence of a newdata() handler for UDP
connections might break things. Only-sending applications like syslog()
do not need a newdata() handler, so added a check if that handler exists.
Diffstat (limited to 'src/net/udp.c')
-rw-r--r-- | src/net/udp.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/net/udp.c b/src/net/udp.c index 34acc53..1f74d65 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -260,7 +260,7 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src, struct udp_connection *conn; size_t ulen; uint16_t csum; - int rc; + int rc = 0; /* Sanity check packet */ if ( pkb_len ( pkb ) < sizeof ( *udphdr ) ) { @@ -314,11 +314,16 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src, } /* Pass data to application */ - rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ), + if ( conn->udp_op->newdata ) { + rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ), st_src, st_dest ); - if ( rc != 0 ) { - DBGC ( conn, "UDP %p application rejected packet: %s\n", - conn, strerror ( rc ) ); + if ( rc != 0 ) { + DBGC ( conn, "UDP %p application rejected packet: %s\n", + conn, strerror ( rc ) ); + } + } else { + DBGC ( conn, "UDP %p application has no newdata handler for " \ + "incoming packet\n", conn ); } done: |