pmc: add a command to select the target port.
This patch adds a new pmc command called "target" that lets the user address a particular clock and port. Previously all management requests were sent to the wild card address. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
923ff5bbc1
commit
a3762c506e
19
pmc.c
19
pmc.c
|
@ -596,6 +596,19 @@ static int parse_id(char *s)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_target(const char *str)
|
||||||
|
{
|
||||||
|
struct PortIdentity pid;
|
||||||
|
|
||||||
|
if (str[0] == '*') {
|
||||||
|
memset(&pid, 0xff, sizeof(pid));
|
||||||
|
} else if (str2pid(str, &pid)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pmc_target(pmc, &pid);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_help(FILE *fp)
|
static void print_help(FILE *fp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -608,6 +621,9 @@ static void print_help(FILE *fp)
|
||||||
fprintf(fp, "\tThe [action] can be GET, SET, CMD, or COMMAND\n");
|
fprintf(fp, "\tThe [action] can be GET, SET, CMD, or COMMAND\n");
|
||||||
fprintf(fp, "\tCommands are case insensitive and may be abbreviated.\n");
|
fprintf(fp, "\tCommands are case insensitive and may be abbreviated.\n");
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
|
fprintf(fp, "\tTARGET [portIdentity]\n");
|
||||||
|
fprintf(fp, "\tTARGET *\n");
|
||||||
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_command(char *str)
|
static int do_command(char *str)
|
||||||
|
@ -623,6 +639,9 @@ static int do_command(char *str)
|
||||||
if (2 != sscanf(str, " %10s %64s", action_str, id_str))
|
if (2 != sscanf(str, " %10s %64s", action_str, id_str))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (0 == strncasecmp(action_str, "TARGET", strlen(action_str)))
|
||||||
|
return parse_target(id_str);
|
||||||
|
|
||||||
action = parse_action(action_str);
|
action = parse_action(action_str);
|
||||||
id = parse_id(id_str);
|
id = parse_id(id_str);
|
||||||
|
|
||||||
|
|
16
util.c
16
util.c
|
@ -82,6 +82,22 @@ char *pid2str(struct PortIdentity *id)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int str2pid(const char *s, struct PortIdentity *result)
|
||||||
|
{
|
||||||
|
struct PortIdentity pid;
|
||||||
|
unsigned char *ptr = pid.clockIdentity.id;
|
||||||
|
int c;
|
||||||
|
c = sscanf(s, " %02hhx%02hhx%02hhx.%02hhx%02hhx.%02hhx%02hhx%02hhx-%hu",
|
||||||
|
&ptr[0], &ptr[1], &ptr[2], &ptr[3],
|
||||||
|
&ptr[4], &ptr[5], &ptr[6], &ptr[7],
|
||||||
|
&pid.portNumber);
|
||||||
|
if (c == 9) {
|
||||||
|
*result = pid;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int generate_clock_identity(struct ClockIdentity *ci, char *name)
|
int generate_clock_identity(struct ClockIdentity *ci, char *name)
|
||||||
{
|
{
|
||||||
unsigned char mac[6];
|
unsigned char mac[6];
|
||||||
|
|
9
util.h
9
util.h
|
@ -55,6 +55,15 @@ char *cid2str(struct ClockIdentity *id);
|
||||||
*/
|
*/
|
||||||
char *pid2str(struct PortIdentity *id);
|
char *pid2str(struct PortIdentity *id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan a string containing a port identity and convert it into binary form.
|
||||||
|
*
|
||||||
|
* @param s String in human readable form.
|
||||||
|
* @param result Pointer to a buffer to hold the result.
|
||||||
|
* @return Zero on success, or -1 if the string is incorrectly formatted.
|
||||||
|
*/
|
||||||
|
int str2pid(const char *s, struct PortIdentity *result);
|
||||||
|
|
||||||
int generate_clock_identity(struct ClockIdentity *ci, char *name);
|
int generate_clock_identity(struct ClockIdentity *ci, char *name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue