Browse Source

Set current working URI based on TFTP server specified by DHCP.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
c73bff7ae5
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      src/net/udp/dhcp.c

+ 15
- 0
src/net/udp/dhcp.c View File

18
 
18
 
19
 #include <string.h>
19
 #include <string.h>
20
 #include <stdlib.h>
20
 #include <stdlib.h>
21
+#include <stdio.h>
21
 #include <errno.h>
22
 #include <errno.h>
22
 #include <assert.h>
23
 #include <assert.h>
23
 #include <byteswap.h>
24
 #include <byteswap.h>
29
 #include <gpxe/retry.h>
30
 #include <gpxe/retry.h>
30
 #include <gpxe/tcpip.h>
31
 #include <gpxe/tcpip.h>
31
 #include <gpxe/ip.h>
32
 #include <gpxe/ip.h>
33
+#include <gpxe/uri.h>
32
 #include <gpxe/dhcp.h>
34
 #include <gpxe/dhcp.h>
33
 
35
 
34
 /** @file
36
 /** @file
857
 	struct in_addr netmask = { 0 };
859
 	struct in_addr netmask = { 0 };
858
 	struct in_addr gateway = { INADDR_NONE };
860
 	struct in_addr gateway = { INADDR_NONE };
859
 	struct sockaddr_in *sin_nameserver;
861
 	struct sockaddr_in *sin_nameserver;
862
+	struct in_addr tftp_server;
863
+	struct uri *uri;
864
+	char uri_string[32];
860
 	int rc;
865
 	int rc;
861
 
866
 
862
 	/* Clear any existing routing table entry */
867
 	/* Clear any existing routing table entry */
883
 	find_dhcp_ipv4_option ( options, DHCP_LOG_SERVERS,
888
 	find_dhcp_ipv4_option ( options, DHCP_LOG_SERVERS,
884
 				&syslogserver );
889
 				&syslogserver );
885
 
890
 
891
+	/* Set current working URI based on TFTP server */
892
+	find_dhcp_ipv4_option ( options, DHCP_EB_SIADDR, &tftp_server );
893
+	snprintf ( uri_string, sizeof ( uri_string ),
894
+		   "tftp://%s/", inet_ntoa ( tftp_server ) );
895
+	uri = parse_uri ( uri_string );
896
+	if ( ! uri )
897
+		return -ENOMEM;
898
+	churi ( uri );
899
+	uri_put ( uri );
900
+
886
 	return 0;
901
 	return 0;
887
 }
902
 }

Loading…
Cancel
Save