PXENV_UDP_WRITE
[PXE UDP API]

UDP WRITE. More...


Data Structures

struct  s_PXENV_UDP_WRITE
 Parameter block for pxenv_udp_write(). More...

Defines

#define PXENV_UDP_WRITE   0x0033
 PXE API function code for pxenv_udp_write().

Typedefs

typedef struct s_PXENV_UDP_WRITE PXENV_UDP_WRITE_t

Functions

PXENV_EXIT_t pxenv_udp_write (struct s_PXENV_UDP_WRITE *udp_write)
 UDP WRITE.


Detailed Description

UDP WRITE.

Define Documentation

#define PXENV_UDP_WRITE   0x0033

PXE API function code for pxenv_udp_write().

Definition at line 784 of file pxe_api.h.

Referenced by pxe_api_call().


Typedef Documentation

Definition at line 797 of file pxe_api.h.


Function Documentation

PXENV_EXIT_t pxenv_udp_write ( struct s_PXENV_UDP_WRITE pxenv_udp_write  ) 

UDP WRITE.

Parameters:
pxenv_udp_write Pointer to a struct s_PXENV_UDP_WRITE
s_PXENV_UDP_WRITE::ip Destination IP address
s_PXENV_UDP_WRITE::gw Relay agent IP address, or 0.0.0.0
s_PXENV_UDP_WRITE::src_port Source UDP port, or 0
s_PXENV_UDP_WRITE::dst_port Destination UDP port
s_PXENV_UDP_WRITE::buffer_size Length of the UDP payload
s_PXENV_UDP_WRITE::buffer Address of the UDP payload
Return values:
PXENV_EXIT_SUCCESS Packet was transmitted successfully
PXENV_EXIT_FAILURE Packet could not be transmitted
s_PXENV_UDP_WRITE::Status PXE status code
Exceptions:
PXENV_STATUS_UDP_CLOSED UDP connection is not open
PXENV_STATUS_UNDI_TRANSMIT_ERROR Could not transmit packet
Transmits a single UDP packet. A valid IP and UDP header will be prepended to the payload in s_PXENV_UDP_WRITE::buffer; the buffer should not contain precomputed IP and UDP headers, nor should it contain space allocated for these headers. The first byte of the buffer will be transmitted as the first byte following the UDP header.

If s_PXENV_UDP_WRITE::gw is 0.0.0.0, normal IP routing will take place. See the relevant implementation note for more details.

If s_PXENV_UDP_WRITE::src_port is 0, port 2069 will be used.

You must have opened a UDP connection with pxenv_udp_open() before calling pxenv_udp_write().

On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)

Note:
Etherboot currently ignores the s_PXENV_UDP_WRITE::gw parameter.

Definition at line 256 of file pxe_udp.c.

References AF_INET, s_PXENV_UDP_WRITE::buffer, s_PXENV_UDP_WRITE::buffer_size, copy_from_user(), DBG, s_PXENV_UDP_WRITE::dst_port, htons, inet_ntoa(), iob_put, s_PXENV_UDP_WRITE::ip, pxe_udp_connection::local, memset(), ntohs, s_SEGOFF16::offset, pxe_netdev, PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS, PXENV_STATUS_OUT_OF_RESOURCES, PXENV_STATUS_SUCCESS, real_to_user(), in_addr::s_addr, s_SEGOFF16::segment, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, xfer_metadata::src, s_PXENV_UDP_WRITE::src_port, s_PXENV_UDP_WRITE::Status, pxe_udp_connection::xfer, xfer_alloc_iob(), and xfer_deliver_iob_meta().

Referenced by pxe_api_call().

00256                                                                            {
00257         struct sockaddr_in dest;
00258         struct xfer_metadata meta = {
00259                 .src = ( struct sockaddr * ) &pxe_udp.local,
00260                 .dest = ( struct sockaddr * ) &dest,
00261                 .netdev = pxe_netdev,
00262         };
00263         size_t len;
00264         struct io_buffer *iobuf;
00265         userptr_t buffer;
00266         int rc;
00267 
00268         DBG ( "PXENV_UDP_WRITE" );
00269 
00270         /* Construct destination socket address */
00271         memset ( &dest, 0, sizeof ( dest ) );
00272         dest.sin_family = AF_INET;
00273         dest.sin_addr.s_addr = pxenv_udp_write->ip;
00274         dest.sin_port = pxenv_udp_write->dst_port;
00275 
00276         /* Set local (source) port.  PXE spec says source port is 2069
00277          * if not specified.  Really, this ought to be set at UDP open
00278          * time but hey, we didn't design this API.
00279          */
00280         pxe_udp.local.sin_port = pxenv_udp_write->src_port;
00281         if ( ! pxe_udp.local.sin_port )
00282                 pxe_udp.local.sin_port = htons ( 2069 );
00283 
00284         /* FIXME: we ignore the gateway specified, since we're
00285          * confident of being able to do our own routing.  We should
00286          * probably allow for multiple gateways.
00287          */
00288 
00289         /* Allocate and fill data buffer */
00290         len = pxenv_udp_write->buffer_size;
00291         iobuf = xfer_alloc_iob ( &pxe_udp.xfer, len );
00292         if ( ! iobuf ) {
00293                 pxenv_udp_write->Status = PXENV_STATUS_OUT_OF_RESOURCES;
00294                 return PXENV_EXIT_FAILURE;
00295         }
00296         buffer = real_to_user ( pxenv_udp_write->buffer.segment,
00297                                 pxenv_udp_write->buffer.offset );
00298         copy_from_user ( iob_put ( iobuf, len ), buffer, 0, len );
00299 
00300         DBG ( " %04x:%04x+%x %d->%s:%d", pxenv_udp_write->buffer.segment,
00301               pxenv_udp_write->buffer.offset, pxenv_udp_write->buffer_size,
00302               ntohs ( pxenv_udp_write->src_port ),
00303               inet_ntoa ( dest.sin_addr ),
00304               ntohs ( pxenv_udp_write->dst_port ) );
00305         
00306         /* Transmit packet */
00307         if ( ( rc = xfer_deliver_iob_meta ( &pxe_udp.xfer, iobuf,
00308                                             &meta ) ) != 0 ) {
00309                 pxenv_udp_write->Status = PXENV_STATUS ( rc );
00310                 return PXENV_EXIT_FAILURE;
00311         }
00312 
00313         pxenv_udp_write->Status = PXENV_STATUS_SUCCESS;
00314         return PXENV_EXIT_SUCCESS;
00315 }


Generated on Tue Apr 6 20:01:59 2010 for gPXE by  doxygen 1.5.7.1