diff options
| author | Michael Brown | 2007-07-05 19:38:14 +0200 |
|---|---|---|
| committer | Michael Brown | 2007-07-05 19:38:14 +0200 |
| commit | 1567b698958cccde4c32e554ef56df7add3a06f6 (patch) | |
| tree | 208ea71016215b02fab90b835428568543619302 /src/net/udp | |
| parent | First draft of PXE extensions API. (diff) | |
| download | ipxe-1567b698958cccde4c32e554ef56df7add3a06f6.tar.gz ipxe-1567b698958cccde4c32e554ef56df7add3a06f6.tar.xz ipxe-1567b698958cccde4c32e554ef56df7add3a06f6.zip | |
Add concept of DHCP option applicators.
Diffstat (limited to 'src/net/udp')
| -rw-r--r-- | src/net/udp/dhcp.c | 34 | ||||
| -rw-r--r-- | src/net/udp/dns.c | 23 |
2 files changed, 29 insertions, 28 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 03e6c9d9b..a8cb9376f 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -30,7 +30,6 @@ #include <gpxe/retry.h> #include <gpxe/tcpip.h> #include <gpxe/ip.h> -#include <gpxe/uri.h> #include <gpxe/dhcp.h> /** @file @@ -826,12 +825,6 @@ int start_dhcp ( struct job_interface *job, struct net_device *netdev, * */ -/* Avoid dragging in dns.o */ -struct sockaddr_tcpip nameserver; - -/* Avoid dragging in syslog.o */ -struct in_addr syslogserver; - /** * Configure network device from DHCP options * @@ -844,10 +837,6 @@ int dhcp_configure_netdev ( struct net_device *netdev, struct in_addr address = { 0 }; struct in_addr netmask = { 0 }; struct in_addr gateway = { INADDR_NONE }; - struct sockaddr_in *sin_nameserver; - struct in_addr tftp_server; - struct uri *uri; - char uri_string[32]; int rc; /* Clear any existing routing table entry */ @@ -866,23 +855,12 @@ int dhcp_configure_netdev ( struct net_device *netdev, return rc; } - /* Retrieve other DHCP options that we care about */ - sin_nameserver = ( struct sockaddr_in * ) &nameserver; - sin_nameserver->sin_family = AF_INET; - find_dhcp_ipv4_option ( options, DHCP_DNS_SERVERS, - &sin_nameserver->sin_addr ); - find_dhcp_ipv4_option ( options, DHCP_LOG_SERVERS, - &syslogserver ); - - /* Set current working URI based on TFTP server */ - find_dhcp_ipv4_option ( options, DHCP_EB_SIADDR, &tftp_server ); - snprintf ( uri_string, sizeof ( uri_string ), - "tftp://%s/", inet_ntoa ( tftp_server ) ); - uri = parse_uri ( uri_string ); - if ( ! uri ) - return -ENOMEM; - churi ( uri ); - uri_put ( uri ); + /* Apply other DHCP options */ + if ( ( rc = apply_dhcp_options ( options ) ) != 0 ) { + DBG ( "Could not apply %s DHCP result options: %s\n", + netdev->name, strerror ( rc ) ); + return rc; + } return 0; } diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c index ff28c7e0a..bd519a26e 100644 --- a/src/net/udp/dns.c +++ b/src/net/udp/dns.c @@ -30,6 +30,7 @@ #include <gpxe/resolv.h> #include <gpxe/retry.h> #include <gpxe/tcpip.h> +#include <gpxe/dhcp.h> #include <gpxe/dns.h> /** @file @@ -503,3 +504,25 @@ struct resolver dns_resolver __resolver ( RESOLV_NORMAL ) = { .name = "DNS", .resolv = dns_resolv, }; + +/** + * Apply DHCP nameserver option + * + * @v tag DHCP option tag + * @v option DHCP option + */ +static int apply_dhcp_nameserver ( unsigned int tag __unused, + struct dhcp_option *option ) { + struct sockaddr_in *sin_nameserver; + + sin_nameserver = ( struct sockaddr_in * ) &nameserver; + sin_nameserver->sin_family = AF_INET; + dhcp_ipv4_option ( option, &sin_nameserver->sin_addr ); + return 0; +} + +/** DHCP nameserver applicator */ +struct dhcp_option_applicator dhcp_nameserver_applicator __dhcp_applicator = { + .tag = DHCP_DNS_SERVERS, + .apply = apply_dhcp_nameserver, +}; |
