Browse Source

Convert some trivial functions to static inlines.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
eb24eece0e
2 changed files with 56 additions and 31 deletions
  1. 56
    3
      src/include/gpxe/udp.h
  2. 0
    28
      src/net/udp.c

+ 56
- 3
src/include/gpxe/udp.h View File

@@ -95,10 +95,63 @@ struct udp_connection {
95 95
  * Functions provided to the application layer
96 96
  */
97 97
 
98
+/**
99
+ * Bind UDP connection to all local ports
100
+ *
101
+ * @v conn		UDP connection
102
+ *
103
+ * A promiscuous UDP connection will receive packets with any
104
+ * destination UDP port.  This is required in order to support the PXE
105
+ * UDP API.
106
+ *
107
+ * If the promiscuous connection is not the only UDP connection, the
108
+ * behaviour is undefined.
109
+ */
110
+static inline void udp_bind_promisc ( struct udp_connection *conn ) {
111
+	conn->local_port = 0;
112
+}
113
+
114
+/**
115
+ * Connect UDP connection to remote host and port
116
+ *
117
+ * @v conn		UDP connection
118
+ * @v peer		Destination socket address
119
+ *
120
+ * This function sets the default address for transmitted packets,
121
+ * i.e. the address used when udp_send() is called rather than
122
+ * udp_sendto().
123
+ */
124
+static inline void udp_connect ( struct udp_connection *conn,
125
+				 struct sockaddr_tcpip *peer ) {
126
+	memcpy ( &conn->peer, peer, sizeof ( conn->peer ) );
127
+}
128
+
129
+/**
130
+ * Connect UDP connection to remote port
131
+ *
132
+ * @v conn		UDP connection
133
+ * @v port		Destination port
134
+ *
135
+ * This function sets only the port part of the default address for
136
+ * transmitted packets.
137
+ */
138
+static inline void udp_connect_port ( struct udp_connection *conn,
139
+				      uint16_t port ) {
140
+	conn->peer.st_port = port;
141
+}
142
+
143
+/**
144
+ * Get default address for transmitted packets
145
+ *
146
+ * @v conn		UDP connection
147
+ * @ret peer		Default destination socket address
148
+ */
149
+static inline struct sockaddr_tcpip *
150
+udp_peer ( struct udp_connection *conn ) {
151
+	return &conn->peer;
152
+}
153
+
98 154
 extern int udp_bind ( struct udp_connection *conn, uint16_t local_port );
99
-extern void udp_bind_promisc ( struct udp_connection *conn );
100
-extern void udp_connect ( struct udp_connection *conn,
101
-			  struct sockaddr_tcpip *peer );
102 155
 extern int udp_open ( struct udp_connection *conn, uint16_t local_port );
103 156
 extern void udp_close ( struct udp_connection *conn );
104 157
 

+ 0
- 28
src/net/udp.c View File

@@ -38,34 +38,6 @@ int udp_bind ( struct udp_connection *conn, uint16_t local_port ) {
38 38
 	return 0;
39 39
 }
40 40
 
41
-/**
42
- * Bind UDP connection to all local ports
43
- *
44
- * @v conn		UDP connection
45
- *
46
- * A promiscuous UDP connection will receive packets with any
47
- * destination UDP port.  This is required in order to support the PXE
48
- * UDP API.
49
- *
50
- * If the promiscuous connection is not the only UDP connection, the
51
- * behaviour is undefined.
52
- */
53
-void udp_bind_promisc ( struct udp_connection *conn ) {
54
-	conn->local_port = 0;
55
-}
56
-
57
-/**
58
- * Connect UDP connection to remote host and port
59
- *
60
- * @v conn		UDP connection
61
- * @v peer		Destination socket address
62
- *
63
- * This function stores the socket address within the connection
64
- */
65
-void udp_connect ( struct udp_connection *conn, struct sockaddr_tcpip *peer ) {
66
-	memcpy ( &conn->peer, peer, sizeof ( conn->peer ) );
67
-}
68
-
69 41
 /**
70 42
  * Open a local port
71 43
  *

Loading…
Cancel
Save