summaryrefslogtreecommitdiffstats
path: root/src/net/ipv6.c
diff options
context:
space:
mode:
authorMichael Brown2014-03-04 13:54:21 +0100
committerMichael Brown2014-03-04 14:02:58 +0100
commitdb67de6f31a062dc1995d4561be83cd51609d6c4 (patch)
tree642ebb50e33c2a720d40769dd59010ce0d5b8e05 /src/net/ipv6.c
parent[prefix] Ignore PCI autoboot device location if set to 00:00.0 (diff)
downloadipxe-db67de6f31a062dc1995d4561be83cd51609d6c4.tar.gz
ipxe-db67de6f31a062dc1995d4561be83cd51609d6c4.tar.xz
ipxe-db67de6f31a062dc1995d4561be83cd51609d6c4.zip
[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>
Diffstat (limited to 'src/net/ipv6.c')
-rw-r--r--src/net/ipv6.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 2802aef0..6f2e9477 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -322,6 +322,25 @@ static struct ipv6_miniroute * ipv6_route ( unsigned int scope_id,
}
/**
+ * Determine transmitting network device
+ *
+ * @v st_dest Destination network-layer address
+ * @ret netdev Transmitting network device, or NULL
+ */
+static struct net_device * ipv6_netdev ( struct sockaddr_tcpip *st_dest ) {
+ struct sockaddr_in6 *sin6_dest = ( ( struct sockaddr_in6 * ) st_dest );
+ struct in6_addr *dest = &sin6_dest->sin6_addr;
+ struct ipv6_miniroute *miniroute;
+
+ /* Find routing table entry */
+ miniroute = ipv6_route ( sin6_dest->sin6_scope_id, &dest );
+ if ( ! miniroute )
+ return NULL;
+
+ return miniroute->netdev;
+}
+
+/**
* Check that received options can be safely ignored
*
* @v iphdr IPv6 header
@@ -970,6 +989,7 @@ struct tcpip_net_protocol ipv6_tcpip_protocol __tcpip_net_protocol = {
.name = "IPv6",
.sa_family = AF_INET6,
.tx = ipv6_tx,
+ .netdev = ipv6_netdev,
};
/** IPv6 socket address converter */