diff options
author | Michael Brown | 2007-06-20 02:13:35 +0200 |
---|---|---|
committer | Michael Brown | 2007-06-20 02:13:35 +0200 |
commit | e381714c079b3f2e6b525216f34a5bba0fdb239f (patch) | |
tree | 4eb73b379a920c19221a9f5298eebfb50eca89de /src/interface | |
parent | Add iob_ensure_headroom() placeholder. (diff) | |
download | ipxe-e381714c079b3f2e6b525216f34a5bba0fdb239f.tar.gz ipxe-e381714c079b3f2e6b525216f34a5bba0fdb239f.tar.xz ipxe-e381714c079b3f2e6b525216f34a5bba0fdb239f.zip |
Partial migration of UDP to data-xfer interface. (Will not link at
present; DHCP is broken).
Diffstat (limited to 'src/interface')
-rw-r--r-- | src/interface/pxe/pxe_udp.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/src/interface/pxe/pxe_udp.c b/src/interface/pxe/pxe_udp.c index be2bc130..d85028e4 100644 --- a/src/interface/pxe/pxe_udp.c +++ b/src/interface/pxe/pxe_udp.c @@ -34,8 +34,6 @@ struct pxe_udp_connection { /** Data transfer interface to UDP stack */ struct xfer_interface xfer; - /** "Connection is open" flag */ - int open; /** Local address */ struct sockaddr_in local; /** Current PXENV_UDP_READ parameter block */ @@ -169,21 +167,19 @@ static struct pxe_udp_connection pxe_udp = { * */ PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *pxenv_udp_open ) { + int rc; DBG ( "PXENV_UDP_OPEN" ); - /* Check connection is not already open */ - if ( pxe_udp.open ) { - pxenv_udp_open->Status = PXENV_STATUS_UDP_OPEN; - return PXENV_EXIT_FAILURE; - } - /* Record source IP address */ pxe_udp.local.sin_addr.s_addr = pxenv_udp_open->src_ip; /* Open promiscuous UDP connection */ - udp_open_promisc ( &pxe_udp.xfer ); - pxe_udp.open = 1; + xfer_close ( &pxe_udp.xfer, 0 ); + if ( ( rc = udp_open_promisc ( &pxe_udp.xfer ) ) != 0 ) { + pxenv_udp_open->Status = PXENV_STATUS ( rc ); + return PXENV_EXIT_FAILURE; + } pxenv_udp_open->Status = PXENV_STATUS_SUCCESS; return PXENV_EXIT_SUCCESS; @@ -213,15 +209,8 @@ PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *pxenv_udp_open ) { PXENV_EXIT_t pxenv_udp_close ( struct s_PXENV_UDP_CLOSE *pxenv_udp_close ) { DBG ( "PXENV_UDP_CLOSE" ); - /* Check connection is open */ - if ( ! pxe_udp.open ) { - pxenv_udp_close->Status = PXENV_STATUS_UDP_CLOSED; - return PXENV_EXIT_SUCCESS; /* Well, it *is* closed */ - } - /* Close UDP connection */ - udp_close_promisc ( &pxe_udp.xfer ); - pxe_udp.open = 0; + xfer_close ( &pxe_udp.xfer, 0 ); pxenv_udp_close->Status = PXENV_STATUS_SUCCESS; return PXENV_EXIT_SUCCESS; @@ -281,12 +270,6 @@ PXENV_EXIT_t pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) { DBG ( "PXENV_UDP_WRITE" ); - /* Check connection is open */ - if ( ! pxe_udp.open ) { - pxenv_udp_write->Status = PXENV_STATUS_UDP_CLOSED; - return PXENV_EXIT_FAILURE; - } - /* Construct destination socket address */ memset ( &dest, 0, sizeof ( dest ) ); dest.sin_family = AF_INET; @@ -383,12 +366,6 @@ PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) { DBG ( "PXENV_UDP_READ" ); - /* Check connection is open */ - if ( ! pxe_udp.open ) { - pxenv_udp_read->Status = PXENV_STATUS_UDP_CLOSED; - return PXENV_EXIT_FAILURE; - } - /* Try receiving a packet */ pxe_udp.pxenv_udp_read = pxenv_udp_read; step(); |