+/** A 16-bit integer configuration setting */
+struct config_setting_type config_setting_type_int16 __config_setting_type = {
+ .name = "int16",
+ .description = "16-bit integer",
+ .show = show_int,
+ .set = set_int16,
+};
+
+/** A 32-bit integer configuration setting */
+struct config_setting_type config_setting_type_int32 __config_setting_type = {
+ .name = "int32",
+ .description = "32-bit integer",
+ .show = show_int,
+ .set = set_int32,
+};
+
+/**
+ * Set value of hex-string setting
+ *
+ * @v context Configuration context
+ * @v setting Configuration setting
+ * @v value Setting value (as a string)
+ * @ret rc Return status code
+ */
+static int set_hex ( struct config_context *context,
+ struct config_setting *setting,
+ const char *value ) {
+ struct dhcp_option *option;
+ char *ptr = ( char * ) value;
+ uint8_t bytes[ strlen ( value ) ]; /* cannot exceed strlen(value) */
+ unsigned int len = 0;
+
+ while ( 1 ) {
+ bytes[len++] = strtoul ( ptr, &ptr, 16 );
+ switch ( *ptr ) {
+ case '\0' :
+ option = set_dhcp_option ( context->options,
+ setting->tag, bytes, len );
+ if ( ! option )
+ return -ENOSPC;
+ return 0;
+ case ':' :
+ ptr++;
+ break;
+ default :
+ return -EINVAL;
+ }
+ }
+}
+
+/**
+ * Show value of hex-string setting
+ *
+ * @v context Configuration context
+ * @v setting Configuration setting
+ * @v buf Buffer to contain value
+ * @v len Length of buffer
+ * @ret len Length of formatted value, or negative error
+ */
+static int show_hex ( struct config_context *context,
+ struct config_setting *setting,
+ char *buf, size_t len ) {
+ struct dhcp_option *option;
+ int used = 0;
+ int i;
+
+ option = find_dhcp_option ( context->options, setting->tag );
+ if ( ! option )
+ return -ENODATA;
+
+ for ( i = 0 ; i < option->len ; i++ ) {
+ used += ssnprintf ( ( buf + used ), ( len - used ),
+ "%s%02x", ( used ? ":" : "" ),
+ option->data.bytes[i] );
+ }
+ return used;
+}
+
+/** A hex-string configuration setting */
+struct config_setting_type config_setting_type_hex __config_setting_type = {
+ .name = "hex",
+ .description = "Hex string",
+ .show = show_hex,
+ .set = set_hex,
+};
+