|
@@ -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
|
|