mirror of
https://github.com/ipxe/ipxe
synced 2025-12-28 02:28:57 +03:00
[tcpip] Provide tcpip_netdev() to determine the transmitting network device
Provide the function tcpip_netdev() to allow external code to determine the transmitting network device for a given socket address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -137,6 +137,25 @@ static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine transmitting network device
|
||||
*
|
||||
* @v st_dest Destination network-layer address
|
||||
* @ret netdev Transmitting network device, or NULL
|
||||
*/
|
||||
static struct net_device * ipv4_netdev ( struct sockaddr_tcpip *st_dest ) {
|
||||
struct sockaddr_in *sin_dest = ( ( struct sockaddr_in * ) st_dest );
|
||||
struct in_addr dest = sin_dest->sin_addr;
|
||||
struct ipv4_miniroute *miniroute;
|
||||
|
||||
/* Find routing table entry */
|
||||
miniroute = ipv4_route ( &dest );
|
||||
if ( ! miniroute )
|
||||
return NULL;
|
||||
|
||||
return miniroute->netdev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if IPv4 fragment matches fragment reassembly buffer
|
||||
*
|
||||
@@ -603,6 +622,7 @@ struct tcpip_net_protocol ipv4_tcpip_protocol __tcpip_net_protocol = {
|
||||
.name = "IPv4",
|
||||
.sa_family = AF_INET,
|
||||
.tx = ipv4_tx,
|
||||
.netdev = ipv4_netdev,
|
||||
};
|
||||
|
||||
/** IPv4 ARP protocol */
|
||||
|
||||
Reference in New Issue
Block a user