summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2006-08-04 01:42:03 +0200
committerMichael Brown2006-08-04 01:42:03 +0200
commiteb24eece0e23eea241d5779b949a5dc77c6ae8ab (patch)
treeec7d52113c11af3e72939282aed9078aa1502524 /src/include
parentMake the UDP senddata() methods return a status code. (diff)
downloadipxe-eb24eece0e23eea241d5779b949a5dc77c6ae8ab.tar.gz
ipxe-eb24eece0e23eea241d5779b949a5dc77c6ae8ab.tar.xz
ipxe-eb24eece0e23eea241d5779b949a5dc77c6ae8ab.zip
Convert some trivial functions to static inlines.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/udp.h59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/include/gpxe/udp.h b/src/include/gpxe/udp.h
index a07198503..d32c87823 100644
--- a/src/include/gpxe/udp.h
+++ b/src/include/gpxe/udp.h
@@ -95,10 +95,63 @@ struct udp_connection {
* Functions provided to the application layer
*/
+/**
+ * Bind UDP connection to all local ports
+ *
+ * @v conn UDP connection
+ *
+ * A promiscuous UDP connection will receive packets with any
+ * destination UDP port. This is required in order to support the PXE
+ * UDP API.
+ *
+ * If the promiscuous connection is not the only UDP connection, the
+ * behaviour is undefined.
+ */
+static inline void udp_bind_promisc ( struct udp_connection *conn ) {
+ conn->local_port = 0;
+}
+
+/**
+ * Connect UDP connection to remote host and port
+ *
+ * @v conn UDP connection
+ * @v peer Destination socket address
+ *
+ * This function sets the default address for transmitted packets,
+ * i.e. the address used when udp_send() is called rather than
+ * udp_sendto().
+ */
+static inline void udp_connect ( struct udp_connection *conn,
+ struct sockaddr_tcpip *peer ) {
+ memcpy ( &conn->peer, peer, sizeof ( conn->peer ) );
+}
+
+/**
+ * Connect UDP connection to remote port
+ *
+ * @v conn UDP connection
+ * @v port Destination port
+ *
+ * This function sets only the port part of the default address for
+ * transmitted packets.
+ */
+static inline void udp_connect_port ( struct udp_connection *conn,
+ uint16_t port ) {
+ conn->peer.st_port = port;
+}
+
+/**
+ * Get default address for transmitted packets
+ *
+ * @v conn UDP connection
+ * @ret peer Default destination socket address
+ */
+static inline struct sockaddr_tcpip *
+udp_peer ( struct udp_connection *conn ) {
+ return &conn->peer;
+}
+
extern int udp_bind ( struct udp_connection *conn, uint16_t local_port );
-extern void udp_bind_promisc ( struct udp_connection *conn );
-extern void udp_connect ( struct udp_connection *conn,
- struct sockaddr_tcpip *peer );
extern int udp_open ( struct udp_connection *conn, uint16_t local_port );
extern void udp_close ( struct udp_connection *conn );