| 
				
			 | 
			
			
				
				@@ -32,6 +32,9 @@ 
			 | 
		
		
	
		
			
			| 
				32
			 | 
			
				32
			 | 
			
			
				
				 #include <gpxe/retry.h> 
			 | 
		
		
	
		
			
			| 
				33
			 | 
			
				33
			 | 
			
			
				
				 #include <gpxe/features.h> 
			 | 
		
		
	
		
			
			| 
				34
			 | 
			
				34
			 | 
			
			
				
				 #include <gpxe/bitmap.h> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				
				+#include <gpxe/settings.h> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				
				+#include <gpxe/dhcp.h> 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				
				+#include <gpxe/uri.h> 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				38
			 | 
			
			
				
				 #include <gpxe/tftp.h> 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				39
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				40
			 | 
			
			
				
				 /** @file 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -1089,3 +1092,43 @@ struct uri_opener mtftp_uri_opener __uri_opener = { 
			 | 
		
		
	
		
			
			| 
				1089
			 | 
			
				1092
			 | 
			
			
				
				 	.scheme	= "mtftp", 
			 | 
		
		
	
		
			
			| 
				1090
			 | 
			
				1093
			 | 
			
			
				
				 	.open	= mtftp_open, 
			 | 
		
		
	
		
			
			| 
				1091
			 | 
			
				1094
			 | 
			
			
				
				 }; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1095
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1096
			 | 
			
			
				
				+/** 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1097
			 | 
			
			
				
				+ * Apply TFTP configuration settings 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1098
			 | 
			
			
				
				+ * 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1099
			 | 
			
			
				
				+ * @ret rc		Return status code 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1100
			 | 
			
			
				
				+ */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1101
			 | 
			
			
				
				+static int tftp_apply_settings ( void ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1102
			 | 
			
			
				
				+	static struct in_addr tftp_server = { 0 }; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1103
			 | 
			
			
				
				+	struct in_addr last_tftp_server; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1104
			 | 
			
			
				
				+	char uri_string[32]; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1105
			 | 
			
			
				
				+	struct uri *uri; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1106
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1107
			 | 
			
			
				
				+	/* Retrieve TFTP server setting */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1108
			 | 
			
			
				
				+	last_tftp_server = tftp_server; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1109
			 | 
			
			
				
				+	fetch_ipv4_setting ( NULL, DHCP_EB_SIADDR, &tftp_server ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1110
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1111
			 | 
			
			
				
				+	/* If TFTP server setting has changed, set the current working 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1112
			 | 
			
			
				
				+	 * URI to match.  Do it only when the TFTP server has changed 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1113
			 | 
			
			
				
				+	 * to try to minimise surprises to the user, who probably 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1114
			 | 
			
			
				
				+	 * won't expect the CWURI to change just because they updated 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1115
			 | 
			
			
				
				+	 * an unrelated setting and triggered all the settings 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1116
			 | 
			
			
				
				+	 * applicators. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1117
			 | 
			
			
				
				+	 */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1118
			 | 
			
			
				
				+	if ( tftp_server.s_addr != last_tftp_server.s_addr ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1119
			 | 
			
			
				
				+		snprintf ( uri_string, sizeof ( uri_string ), 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1120
			 | 
			
			
				
				+			   "tftp://%s/", inet_ntoa ( tftp_server ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1121
			 | 
			
			
				
				+		uri = parse_uri ( uri_string ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1122
			 | 
			
			
				
				+		if ( ! uri ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1123
			 | 
			
			
				
				+			return -ENOMEM; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1124
			 | 
			
			
				
				+		churi ( uri ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1125
			 | 
			
			
				
				+		uri_put ( uri ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1126
			 | 
			
			
				
				+	} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1127
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1128
			 | 
			
			
				
				+	return 0; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1129
			 | 
			
			
				
				+} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1130
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1131
			 | 
			
			
				
				+/** TFTP settings applicator */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1132
			 | 
			
			
				
				+struct settings_applicator tftp_settings_applicator __settings_applicator = { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1133
			 | 
			
			
				
				+	.apply = tftp_apply_settings, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				1134
			 | 
			
			
				
				+}; 
			 |