host_t *addr = NULL;
u_int tstamp = 0;
bool online = FALSE, valid = FALSE, expired = FALSE;
- char *value, *pool = NULL;
+ char *value, *pos, *pool = NULL;
enum {
FIL_POOL = 0,
FIL_ID,
NULL
};
+ /* if the filter string contains a distinguished name as a ID, we filter
+ * out ", " and replace them by "; " to not confuse the getsubopt parser */
+ pos = filter;
+ while ((pos = strchr(pos, ',')))
+ {
+ if (pos[1] == ' ')
+ {
+ pos[0] = ';';
+ }
+ pos++;
+ }
+
while (filter && *filter != '\0')
{
switch (getsubopt(&filter, token, &value))
case FIL_ID:
if (value)
{
+ /* now re-replace the "; " by ", " */
+ pos = value;
+ while ((pos = strchr(pos, ';')))
+ {
+ if (pos[1] == ' ')
+ {
+ pos[0] = ',';
+ }
+ pos++;
+ }
id = identification_create_from_string(value);
}
if (!id)
int len = utc ? 25 : 21;
found = TRUE;
- printf("%-8s %15s %-33s %-*s %-*s %-7s\n",
- "name", "address", "identity", len, "start", len, "end", "status");
+ printf("%-8s %-15s %-7s %-*s %-*s %s\n",
+ "name", "address", "status", len, "start", len, "end", "identity");
}
address = host_create_from_blob(address_chunk);
identity = identification_create_from_encoding(identity_type, identity_chunk);
- printf("%-8s %15H %-32D %#T ", name, address, identity, &acquired, utc);
- if (released)
+ printf("%-8s %-15H ", name, address);
+ if (released == 0)
{
- printf("%#T ", &released, utc);
+ printf("%-7s ", "online");
}
- else
+ else if (timeout == 0)
{
- printf(" ");
- if (utc)
- {
- printf(" ");
- }
+ printf("%-7s ", "static");
}
- if (released == 0)
+ else if (released >= time(NULL) - timeout)
{
- printf("%-7s\n", "online");
+ printf("%-7s ", "valid");
}
- else if (timeout == 0)
+ else
{
- printf("%-7s\n", "static");
+ printf("%-7s ", "expired");
}
- else if (released >= time(NULL) - timeout)
+
+ printf(" %#T ", &acquired, utc);
+ if (released)
{
- printf("%-7s\n", "valid");
+ printf("%#T ", &released, utc);
}
else
{
- printf("%-7s\n", "expired");
+ printf(" ");
+ if (utc)
+ {
+ printf(" ");
+ }
}
+ printf("%D\n", identity);
DESTROY_IF(address);
identity->destroy(identity);
}
break;
case 'h':
break;
- case 'u':
- utc = TRUE;
- break;
case 'w':
operation = OP_STATUS;
break;
+ case 'u':
+ utc = TRUE;
+ continue;
case 'a':
operation = OP_ADD;
name = optarg;