aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2015-09-01 16:18:32 +0100
committerMichael Brown <mcb30@ipxe.org>2015-09-01 21:04:45 +0100
commit84306426424aabb69cbbb24e7e9da2288b23e693 (patch)
tree72fb883af083362e990615e3bb7a4df7855e5c0e /src/net
parentf6e1da5cbf70a372f2b622c8021c98503cab8323 (diff)
downloadipxe-84306426424aabb69cbbb24e7e9da2288b23e693.zip
ipxe-84306426424aabb69cbbb24e7e9da2288b23e693.tar.gz
ipxe-84306426424aabb69cbbb24e7e9da2288b23e693.tar.bz2
[tcpip] Allow supported address families to be detected at runtime
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ipv4.c1
-rw-r--r--src/net/ipv6.c1
-rw-r--r--src/net/tcpip.c15
3 files changed, 9 insertions, 8 deletions
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index a547840..7959cf3 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -714,6 +714,7 @@ struct tcpip_net_protocol ipv4_tcpip_protocol __tcpip_net_protocol = {
.name = "IPv4",
.sa_family = AF_INET,
.header_len = sizeof ( struct iphdr ),
+ .net_protocol = &ipv4_protocol,
.tx = ipv4_tx,
.netdev = ipv4_netdev,
};
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index a75e72d..012ba59 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -1001,6 +1001,7 @@ struct tcpip_net_protocol ipv6_tcpip_protocol __tcpip_net_protocol = {
.name = "IPv6",
.sa_family = AF_INET6,
.header_len = sizeof ( struct ipv6_header ),
+ .net_protocol = &ipv6_protocol,
.tx = ipv6_tx,
.netdev = ipv6_netdev,
};
diff --git a/src/net/tcpip.c b/src/net/tcpip.c
index 5ad982f..c9e4ee7 100644
--- a/src/net/tcpip.c
+++ b/src/net/tcpip.c
@@ -62,19 +62,18 @@ int tcpip_rx ( struct io_buffer *iobuf, struct net_device *netdev,
/**
* Find TCP/IP network-layer protocol
*
- * @v st_dest Destination address
+ * @v sa_family Address family
* @ret tcpip_net TCP/IP network-layer protocol, or NULL if not found
*/
-static struct tcpip_net_protocol *
-tcpip_net_protocol ( struct sockaddr_tcpip *st_dest ) {
+struct tcpip_net_protocol * tcpip_net_protocol ( sa_family_t sa_family ) {
struct tcpip_net_protocol *tcpip_net;
for_each_table_entry ( tcpip_net, TCPIP_NET_PROTOCOLS ) {
- if ( tcpip_net->sa_family == st_dest->st_family )
+ if ( tcpip_net->sa_family == sa_family )
return tcpip_net;
}
- DBG ( "Unrecognised TCP/IP address family %d\n", st_dest->st_family );
+ DBG ( "Unrecognised TCP/IP address family %d\n", sa_family );
return NULL;
}
@@ -95,7 +94,7 @@ int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol,
struct tcpip_net_protocol *tcpip_net;
/* Hand off packet to the appropriate network-layer protocol */
- tcpip_net = tcpip_net_protocol ( st_dest );
+ tcpip_net = tcpip_net_protocol ( st_dest->st_family );
if ( tcpip_net ) {
DBG ( "TCP/IP sending %s packet\n", tcpip_net->name );
return tcpip_net->tx ( iobuf, tcpip_protocol, st_src, st_dest,
@@ -116,7 +115,7 @@ struct net_device * tcpip_netdev ( struct sockaddr_tcpip *st_dest ) {
struct tcpip_net_protocol *tcpip_net;
/* Hand off to the appropriate network-layer protocol */
- tcpip_net = tcpip_net_protocol ( st_dest );
+ tcpip_net = tcpip_net_protocol ( st_dest->st_family );
if ( tcpip_net )
return tcpip_net->netdev ( st_dest );
@@ -135,7 +134,7 @@ size_t tcpip_mtu ( struct sockaddr_tcpip *st_dest ) {
size_t mtu;
/* Find appropriate network-layer protocol */
- tcpip_net = tcpip_net_protocol ( st_dest );
+ tcpip_net = tcpip_net_protocol ( st_dest->st_family );
if ( ! tcpip_net )
return 0;