oops, removed stray parenthesis
[strongswan.git] / src / libhydra / plugins / attr_sql / pool_attributes.c
index 5b1c670..0fdfc87 100644 (file)
@@ -29,6 +29,13 @@ extern database_t *db;
 
 #define UNITY_NETWORK_LEN      14
 
+ENUM(value_type_names, VALUE_HEX, VALUE_SUBNET,
+       "hex",
+       "string",
+       "server",
+       "subnet"
+);
+
 typedef struct attr_info_t attr_info_t;
 
 struct attr_info_t {
@@ -225,6 +232,12 @@ static bool parse_attributes(char *name, char *value, value_type_t *value_type,
                free(blob->ptr);
                return FALSE;
        }
+       if (*type < 1 || *type > 32767)
+       {
+               fprintf(stderr, "the attribute type must lie in the range 1..32767.\n");
+               free(blob->ptr);
+               return FALSE;
+       }
        if (*value_type == VALUE_NONE)
        {
                *value_type = VALUE_HEX;
@@ -448,3 +461,35 @@ void status_attr(void)
                enumerator->destroy(enumerator);
        }
 }
+
+/**
+ * ipsec pool --showattr - show all supported attribute keywords
+ */
+void show_attr(void)
+{
+       int i;
+
+       for (i = 0; i < countof(attr_info); i++)
+       {
+               char value_name[10];
+               
+               
+               snprintf(value_name, sizeof(value_name), "%N",
+                       value_type_names, attr_info[i].value_type);
+       
+               printf("%-19s  --%-6s  (%N", 
+                               attr_info[i].keyword, value_name, 
+                               configuration_attribute_type_names, attr_info[i].type);
+
+               if (attr_info[i].type_ip6)
+               {
+                       printf(", %N)\n",
+                               configuration_attribute_type_names, attr_info[i].type_ip6);
+               }
+               else
+               {
+                       printf(")\n");
+               }
+       }
+}
+