implement ipsec pool -showattr function
This commit is contained in:
@@ -957,6 +957,7 @@ static void do_args(int argc, char *argv[])
|
||||
OP_ADD_ATTR,
|
||||
OP_DEL,
|
||||
OP_DEL_ATTR,
|
||||
OP_SHOW_ATTR,
|
||||
OP_RESIZE,
|
||||
OP_LEASES,
|
||||
OP_PURGE,
|
||||
@@ -984,6 +985,7 @@ static void do_args(int argc, char *argv[])
|
||||
{ "statusattr", no_argument, NULL, '1' },
|
||||
{ "addattr", required_argument, NULL, '2' },
|
||||
{ "delattr", required_argument, NULL, '3' },
|
||||
{ "showattr", no_argument, NULL, '4' },
|
||||
{ "batch", required_argument, NULL, 'b' },
|
||||
|
||||
{ "start", required_argument, NULL, 's' },
|
||||
@@ -1040,6 +1042,9 @@ static void do_args(int argc, char *argv[])
|
||||
name = optarg;
|
||||
operation = OP_DEL_ATTR;
|
||||
continue;
|
||||
case '4':
|
||||
operation = OP_SHOW_ATTR;
|
||||
continue;
|
||||
case 'r':
|
||||
name = optarg;
|
||||
operation = OP_RESIZE;
|
||||
@@ -1162,6 +1167,9 @@ static void do_args(int argc, char *argv[])
|
||||
|
||||
del_attr(name, value, value_type);
|
||||
break;
|
||||
case OP_SHOW_ATTR:
|
||||
show_attr();
|
||||
break;
|
||||
case OP_RESIZE:
|
||||
if (end == NULL)
|
||||
{
|
||||
|
||||
@@ -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 {
|
||||
@@ -448,3 +455,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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ enum value_type_t {
|
||||
VALUE_SUBNET
|
||||
};
|
||||
|
||||
/**
|
||||
* enum names for value_type_t.
|
||||
*/
|
||||
extern enum_name_t *value_type_names;
|
||||
|
||||
/**
|
||||
* ipsec pool --addattr <type> - add attribute entry
|
||||
*/
|
||||
@@ -43,6 +48,11 @@ void del_attr(char *name, char *value, value_type_t value_type);
|
||||
*/
|
||||
void status_attr(void);
|
||||
|
||||
/**
|
||||
* ipsec pool --showattr - show all supported attribute keywords
|
||||
*/
|
||||
void show_attr(void);
|
||||
|
||||
#endif /* POOL_ATTRIBUTES_H_ */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user