|
@@ -122,8 +122,8 @@ find_or_build_config_setting ( const char *name,
|
122
|
122
|
* @v len Length of buffer
|
123
|
123
|
* @ret rc Return status code
|
124
|
124
|
*/
|
125
|
|
-int ( show_setting ) ( struct config_context *context, const char *name,
|
126
|
|
- char *buf, size_t len ) {
|
|
125
|
+int show_setting ( struct config_context *context, const char *name,
|
|
126
|
+ char *buf, size_t len ) {
|
127
|
127
|
struct config_setting *setting;
|
128
|
128
|
struct config_setting tmp_setting;
|
129
|
129
|
|
|
@@ -140,8 +140,8 @@ int ( show_setting ) ( struct config_context *context, const char *name,
|
140
|
140
|
* @v value Setting value (as a string)
|
141
|
141
|
* @ret rc Return status code
|
142
|
142
|
*/
|
143
|
|
-int ( set_setting ) ( struct config_context *context, const char *name,
|
144
|
|
- const char *value ) {
|
|
143
|
+int set_setting ( struct config_context *context, const char *name,
|
|
144
|
+ const char *value ) {
|
145
|
145
|
struct config_setting *setting;
|
146
|
146
|
struct config_setting tmp_setting;
|
147
|
147
|
|
|
@@ -167,7 +167,7 @@ static int show_string ( struct config_context *context,
|
167
|
167
|
|
168
|
168
|
option = find_dhcp_option ( context->options, setting->tag );
|
169
|
169
|
if ( ! option )
|
170
|
|
- return -ENOENT;
|
|
170
|
+ return -ENODATA;
|
171
|
171
|
dhcp_snprintf ( buf, len, option );
|
172
|
172
|
return 0;
|
173
|
173
|
}
|
|
@@ -215,7 +215,7 @@ static int show_ipv4 ( struct config_context *context,
|
215
|
215
|
|
216
|
216
|
option = find_dhcp_option ( context->options, setting->tag );
|
217
|
217
|
if ( ! option )
|
218
|
|
- return -ENOENT;
|
|
218
|
+ return -ENODATA;
|
219
|
219
|
dhcp_ipv4_option ( option, &ipv4 );
|
220
|
220
|
snprintf ( buf, len, inet_ntoa ( ipv4 ) );
|
221
|
221
|
return 0;
|
|
@@ -252,35 +252,23 @@ struct config_setting_type config_setting_type_ipv4 __config_setting_type = {
|
252
|
252
|
};
|
253
|
253
|
|
254
|
254
|
/** Some basic setting definitions */
|
255
|
|
-struct config_setting basic_config_settings[] __config_setting = {
|
256
|
|
- {
|
257
|
|
- .name = "hostname",
|
258
|
|
- .tag = DHCP_HOST_NAME,
|
259
|
|
- .type = &config_setting_type_string,
|
260
|
|
- },
|
261
|
|
- {
|
262
|
|
- .name = "ip",
|
263
|
|
- .tag = DHCP_EB_YIADDR,
|
264
|
|
- .type = &config_setting_type_ipv4,
|
265
|
|
- },
|
|
255
|
+struct config_setting ip_config_setting __config_setting = {
|
|
256
|
+ .name = "ip",
|
|
257
|
+ .tag = DHCP_EB_YIADDR,
|
|
258
|
+ .type = &config_setting_type_ipv4,
|
|
259
|
+};
|
|
260
|
+struct config_setting hostname_config_setting __config_setting = {
|
|
261
|
+ .name = "hostname",
|
|
262
|
+ .tag = DHCP_HOST_NAME,
|
|
263
|
+ .type = &config_setting_type_string,
|
|
264
|
+};
|
|
265
|
+struct config_setting username_config_setting __config_setting = {
|
|
266
|
+ .name = "username",
|
|
267
|
+ .tag = DHCP_EB_USERNAME,
|
|
268
|
+ .type = &config_setting_type_string,
|
|
269
|
+};
|
|
270
|
+struct config_setting password_config_setting __config_setting = {
|
|
271
|
+ .name = "password",
|
|
272
|
+ .tag = DHCP_EB_PASSWORD,
|
|
273
|
+ .type = &config_setting_type_string,
|
266
|
274
|
};
|
267
|
|
-
|
268
|
|
-
|
269
|
|
-
|
270
|
|
-/* Quick and dirty proof of concept */
|
271
|
|
-int cmdl_show ( int argc, char **argv ) {
|
272
|
|
- char buf[256];
|
273
|
|
- struct config_context dummy_context = { NULL };
|
274
|
|
- int rc;
|
275
|
|
-
|
276
|
|
- if ( argc < 2 )
|
277
|
|
- return -EINVAL;
|
278
|
|
-
|
279
|
|
- if ( ( rc = show_setting ( &dummy_context, argv[1],
|
280
|
|
- buf, sizeof ( buf ) ) ) != 0 )
|
281
|
|
- return rc;
|
282
|
|
-
|
283
|
|
- printf ( "%s = %s\n", argv[1], buf );
|
284
|
|
- return 0;
|
285
|
|
-}
|
286
|
|
-
|