@@ -186,13 +186,38 @@ impl SimpleNetwork {
186
186
status. to_result_with_val ( || NonNull :: new ( tx_buf. cast ( ) ) )
187
187
}
188
188
189
- /// Place a packet in the transmit queue of a network interface.
189
+ /// Place a packet in the transmit queue of the network interface.
190
+ ///
191
+ /// The packet structure varies based on the type of network interface. In
192
+ /// typical scenarios, the protocol is implemented for Ethernet devices,
193
+ /// meaning this function transmits Ethernet frames.
194
+ ///
195
+ /// The header of the packet can be filled by the function with the given
196
+ /// parameters, but the buffer must already reserve the space for the
197
+ /// header.
198
+ ///
199
+ /// # Arguments
200
+ /// - `header_size`: The size in bytes of the media header to be filled by
201
+ /// the `transmit()` function. If this is `0`, the (ethernet frame) header
202
+ /// will not be filled by the function and taken as-is from the buffer.
203
+ /// If it is nonzero, then it must be equal to `media_header_size` of
204
+ /// the corresponding [`NetworkMode`] and the `dst_addr` and `protocol`
205
+ /// parameters must not be `None`.
206
+ /// - `buffer`: The buffer containing the whole network packet with all
207
+ /// its payload including the header for the medium.
208
+ /// - `src_addr`: The optional source address.
209
+ /// - `dst_addr`: The optional destination address.
210
+ /// - `protocol`: Ether Type as of RFC 3232. See
211
+ /// [IANA IEEE 802 Numbers][ethertype] for examples. Typically, this is
212
+ /// `0x0800` (IPv4) or `0x0806` (ARP).
213
+ ///
214
+ /// [ethertype]: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1
190
215
pub fn transmit (
191
216
& self ,
192
217
header_size : usize ,
193
218
buffer : & [ u8 ] ,
194
219
src_addr : Option < MacAddress > ,
195
- dest_addr : Option < MacAddress > ,
220
+ dst_addr : Option < MacAddress > ,
196
221
protocol : Option < u16 > ,
197
222
) -> Result {
198
223
unsafe {
@@ -202,7 +227,7 @@ impl SimpleNetwork {
202
227
buffer. len ( ) ,
203
228
buffer. as_ptr ( ) . cast ( ) ,
204
229
src_addr. as_ref ( ) . map ( ptr:: from_ref) . unwrap_or ( ptr:: null ( ) ) ,
205
- dest_addr . as_ref ( ) . map ( ptr:: from_ref) . unwrap_or ( ptr:: null ( ) ) ,
230
+ dst_addr . as_ref ( ) . map ( ptr:: from_ref) . unwrap_or ( ptr:: null ( ) ) ,
206
231
protocol. as_ref ( ) . map ( ptr:: from_ref) . unwrap_or ( ptr:: null ( ) ) ,
207
232
)
208
233
}
0 commit comments