Home | History | Annotate | Download | only in net

Lines Matching refs:udp

12 #include <gpxe/udp.h>
16 * UDP protocol
22 * A UDP connection
28 /** List of UDP connections */
41 * List of registered UDP connections
50 * Bind UDP connection to local port
52 * @v udp UDP connection
55 * Opens the UDP connection and binds to the specified local port. If
58 static int udp_bind ( struct udp_connection *udp ) {
63 if ( ! udp->local.st_port ) {
68 udp->local.st_port = htons ( try_port );
69 if ( udp_bind ( udp ) == 0 )
77 if ( existing->local.st_port == udp->local.st_port ) {
78 DBGC ( udp, "UDP %p could not bind: port %d in use\n",
79 udp, ntohs ( udp->local.st_port ) );
84 /* Add to UDP connection list */
85 DBGC ( udp, "UDP %p bound to port %d\n",
86 udp, ntohs ( udp->local.st_port ) );
92 * Open a UDP connection
105 struct udp_connection *udp;
109 udp = zalloc ( sizeof ( *udp ) );
110 if ( ! udp )
112 DBGC ( udp, "UDP %p allocated\n", udp );
113 xfer_init ( &udp->xfer, &udp_xfer_operations, &udp->refcnt );
115 memcpy ( &udp->peer, st_peer, sizeof ( udp->peer ) );
117 memcpy ( &udp->local, st_local, sizeof ( udp->local ) );
121 if ( ( rc = udp_bind ( udp ) ) != 0 )
128 xfer_plug_plug ( &udp->xfer, xfer );
129 list_add ( &udp->list, &udp_conns );
133 ref_put ( &udp->refcnt );
138 * Open a UDP connection
151 * Open a promiscuous UDP connection
156 * Promiscuous UDP connections are required in order to support the
164 * Close a UDP connection
166 * @v udp UDP connection
169 static void udp_close ( struct udp_connection *udp, int rc ) {
172 xfer_nullify ( &udp->xfer );
173 xfer_close ( &udp->xfer, rc );
176 list_del ( &udp->list );
177 ref_put ( &udp->refcnt );
179 DBGC ( udp, "UDP %p closed\n", udp );
183 * Transmit data via a UDP connection to a specified address
185 * @v udp UDP connection
192 static int udp_tx ( struct udp_connection *udp, struct io_buffer *iobuf,
207 src = &udp->local;
209 dest = &udp->peer;
211 /* Add the UDP header */
221 DBGC ( udp, "UDP %p TX %d->%d len %d\n", udp,
228 DBGC ( udp, "UDP %p could not transmit packet: %s\n",
229 udp, strerror ( rc ) );
237 * Identify UDP connection by local address
240 * @ret udp UDP connection, or NULL
244 struct udp_connection *udp;
246 list_for_each_entry ( udp, &udp_conns, list ) {
247 if ( ( ( udp->local.st_family == local->st_family ) ||
248 ( udp->local.st_family == 0 ) ) &&
249 ( ( udp->local.st_port == local->st_port ) ||
250 ( udp->local.st_port == 0 ) ) &&
251 ( ( memcmp ( udp->local.pad, local->pad,
252 sizeof ( udp->local.pad ) ) == 0 ) ||
253 ( memcmp ( udp->local.pad, empty_sockaddr.pad,
254 sizeof ( udp->local.pad ) ) == 0 ) ) ) {
255 return udp;
273 struct udp_connection *udp;
281 DBG ( "UDP packet too short at %zd bytes (min %zd bytes)\n",
289 DBG ( "UDP length too short at %zd bytes "
295 DBG ( "UDP length too long at %zd bytes (packet is %zd "
303 DBG ( "UDP checksum incorrect (is %04x including "
313 udp = udp_demux ( st_dest );
318 DBGC ( udp, "UDP %p RX %d<-%d len %zd\n", udp,
322 if ( ! udp ) {
323 DBG ( "No UDP connection listening on port %d\n",
333 rc = xfer_deliver_iob_meta ( &udp->xfer, iob_disown ( iobuf ), &meta );
341 .name = "UDP",
360 struct udp_connection *udp =
364 udp_close ( udp, rc );
368 * Allocate I/O buffer for UDP
376 struct udp_connection *udp =
382 DBGC ( udp, "UDP %p cannot allocate buffer of length %zd\n",
383 udp, len );
401 struct udp_connection *udp =
405 udp_tx ( udp, iobuf, ( ( struct sockaddr_tcpip * ) meta->src ),
411 /** UDP data transfer interface operations */
428 /** UDP socket opener */
439 * Open UDP URI
459 /** UDP URI opener */
461 .scheme = "udp",