Ver código fonte

Create "username" and "password" DHCP options, ready for placing this

information in NVS.
tags/v0.9.3
Michael Brown 18 anos atrás
pai
commit
74c41fac06
2 arquivos alterados com 25 adições e 2 exclusões
  1. 18
    0
      src/include/gpxe/dhcp.h
  2. 7
    2
      src/tests/dhcptest.c

+ 18
- 0
src/include/gpxe/dhcp.h Ver arquivo

@@ -167,6 +167,24 @@
167 167
  */
168 168
 #define DHCP_EB_BIOS_DRIVE DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbd )
169 169
 
170
+/** Username
171
+ *
172
+ * This will be used as the username for any required authentication.
173
+ * It is expected that this option's value will be held in
174
+ * non-volatile storage, rather than transmitted as part of a DHCP
175
+ * packet.
176
+ */
177
+#define DHCP_EB_USERNAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbe )
178
+
179
+/** Password
180
+ *
181
+ * This will be used as the password for any required authentication.
182
+ * It is expected that this option's value will be held in
183
+ * non-volatile storage, rather than transmitted as part of a DHCP
184
+ * packet.
185
+ */
186
+#define DHCP_EB_PASSWORD DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbf )
187
+
170 188
 /** Maximum normal DHCP option */
171 189
 #define DHCP_MAX_OPTION 254
172 190
 

+ 7
- 2
src/tests/dhcptest.c Ver arquivo

@@ -16,8 +16,8 @@ static int test_dhcp_aoe_boot ( struct net_device *netdev,
16 16
 
17 17
 static int test_dhcp_iscsi_boot ( struct net_device *netdev, char *iscsiname ) {
18 18
 	char *initiator_iqn = "iqn.1900-01.localdomain.localhost:initiator";
19
-	char *username = "joe";
20
-	char *password = "secret";
19
+	char username[32];
20
+	char password[32];
21 21
 	char *target_iqn;
22 22
 	union {
23 23
 		struct sockaddr_in sin;
@@ -35,6 +35,11 @@ static int test_dhcp_iscsi_boot ( struct net_device *netdev, char *iscsiname ) {
35 35
 	}
36 36
 	inet_aton ( iscsiname, &target.sin.sin_addr );
37 37
 
38
+	dhcp_snprintf ( username, sizeof ( username ),
39
+			find_global_dhcp_option ( DHCP_EB_USERNAME ) );
40
+	dhcp_snprintf ( password, sizeof ( password ),
41
+			find_global_dhcp_option ( DHCP_EB_PASSWORD ) );
42
+
38 43
 	return test_iscsiboot ( initiator_iqn, &target.st, target_iqn,
39 44
 				username, password, netdev );
40 45
 }

Carregando…
Cancelar
Salvar