Browse Source

[dhcp] Send user class in DHCP requests

tags/v0.9.7
Michael Brown 16 years ago
parent
commit
4502c04360
3 changed files with 29 additions and 3 deletions
  1. 3
    0
      src/include/gpxe/dhcp.h
  2. 1
    1
      src/include/gpxe/settings.h
  3. 25
    2
      src/net/udp/dhcp.c

+ 3
- 0
src/include/gpxe/dhcp.h View File

203
  */
203
  */
204
 #define DHCP_BOOTFILE_NAME 67
204
 #define DHCP_BOOTFILE_NAME 67
205
 
205
 
206
+/** User class identifier */
207
+#define DHCP_USER_CLASS_ID 77
208
+
206
 /** Client system architecture */
209
 /** Client system architecture */
207
 #define DHCP_CLIENT_ARCHITECTURE 93
210
 #define DHCP_CLIENT_ARCHITECTURE 93
208
 
211
 

+ 1
- 1
src/include/gpxe/settings.h View File

225
 extern struct setting username_setting __setting;
225
 extern struct setting username_setting __setting;
226
 extern struct setting password_setting __setting;
226
 extern struct setting password_setting __setting;
227
 extern struct setting priority_setting __setting;
227
 extern struct setting priority_setting __setting;
228
-extern struct setting bios_drive_setting __setting;
229
 extern struct setting uuid_setting __setting;
228
 extern struct setting uuid_setting __setting;
230
 extern struct setting next_server_setting __setting;
229
 extern struct setting next_server_setting __setting;
231
 extern struct setting mac_setting __setting;
230
 extern struct setting mac_setting __setting;
231
+extern struct setting user_class_setting __setting;
232
 
232
 
233
 /**
233
 /**
234
  * Initialise a settings block
234
  * Initialise a settings block

+ 25
- 2
src/net/udp/dhcp.c View File

101
 	.type = &setting_type_ipv4,
101
 	.type = &setting_type_ipv4,
102
 };
102
 };
103
 
103
 
104
+/** DHCP user class setting */
105
+struct setting user_class_setting __setting = {
106
+	.name = "user-class",
107
+	.description = "User class identifier",
108
+	.tag = DHCP_USER_CLASS_ID,
109
+	.type = &setting_type_string,
110
+};
111
+
104
 /**
112
 /**
105
  * Name a DHCP packet type
113
  * Name a DHCP packet type
106
  *
114
  *
834
 	struct dhcp_client_uuid client_uuid;
842
 	struct dhcp_client_uuid client_uuid;
835
 	size_t dhcp_features_len;
843
 	size_t dhcp_features_len;
836
 	size_t ll_addr_len;
844
 	size_t ll_addr_len;
845
+	ssize_t len;
837
 	int rc;
846
 	int rc;
838
 
847
 
839
 	/* Create DHCP packet */
848
 	/* Create DHCP packet */
885
 
894
 
886
 	/* Add client UUID, if we have one.  Required for PXE. */
895
 	/* Add client UUID, if we have one.  Required for PXE. */
887
 	client_uuid.type = DHCP_CLIENT_UUID_TYPE;
896
 	client_uuid.type = DHCP_CLIENT_UUID_TYPE;
888
-	if ( ( rc = fetch_uuid_setting ( NULL, &uuid_setting,
889
-					 &client_uuid.uuid ) ) >= 0 ) {
897
+	if ( ( len = fetch_uuid_setting ( NULL, &uuid_setting,
898
+					  &client_uuid.uuid ) ) >= 0 ) {
890
 		if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_CLIENT_UUID,
899
 		if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_CLIENT_UUID,
891
 					    &client_uuid,
900
 					    &client_uuid,
892
 					    sizeof ( client_uuid ) ) ) != 0 ) {
901
 					    sizeof ( client_uuid ) ) ) != 0 ) {
896
 		}
905
 		}
897
 	}
906
 	}
898
 
907
 
908
+	/* Add user class, if we have one. */
909
+	if ( ( len = fetch_setting_len ( NULL, &user_class_setting ) ) >= 0 ) {
910
+		char user_class[len];
911
+		fetch_setting ( NULL, &user_class_setting, user_class,
912
+				sizeof ( user_class ) );
913
+		if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_USER_CLASS_ID,
914
+					    &user_class,
915
+					    sizeof ( user_class ) ) ) != 0 ) {
916
+			DBG ( "DHCP could not set user class: %s\n",
917
+			      strerror ( rc ) );
918
+			return rc;
919
+		}
920
+	}
921
+
899
 	return 0;
922
 	return 0;
900
 }
923
 }
901
 
924
 

Loading…
Cancel
Save