From c73bff7ae5053da239c1fd2a9fdef7ac6b555bbb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 28 Jun 2007 21:22:25 +0100 Subject: [PATCH] Set current working URI based on TFTP server specified by DHCP. --- src/net/udp/dhcp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index dc826b81..fc0be374 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include /** @file @@ -857,6 +859,9 @@ int dhcp_configure_netdev ( struct net_device *netdev, 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 */ @@ -883,5 +888,15 @@ int dhcp_configure_netdev ( struct net_device *netdev, 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 ); + return 0; }