Skip to content

Commit

Permalink
Distinguish between get and set management requests.
Browse files Browse the repository at this point in the history
The code previously treated all supported request as 'get' actions and
ignored the actual action field in the message. This commit makes the
code look at the action field when processing the requests.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Dec 4, 2012
1 parent 502b521 commit 2aaae08
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
10 changes: 5 additions & 5 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ static void clock_freq_est_reset(struct clock *c)
c->fest.count = 0;
};

static int clock_management_response(struct clock *c, struct port *p, int id,
struct ptp_message *req)
static int clock_management_get_response(struct clock *c, struct port *p,
int id, struct ptp_message *req)
{
int datalen = 0, err, pdulen, respond = 0;
struct management_tlv *tlv;
Expand Down Expand Up @@ -614,6 +614,9 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)

switch (management_action(msg)) {
case GET:
if (clock_management_get_response(c, p, mgt->id, msg))
return;
break;
case SET:
case COMMAND:
break;
Expand All @@ -623,9 +626,6 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
return;
}

if (clock_management_response(c, p, mgt->id, msg))
return;

switch (mgt->id) {
case USER_DESCRIPTION:
case SAVE_IN_NON_VOLATILE_STORAGE:
Expand Down
23 changes: 19 additions & 4 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ static int port_ignore(struct port *p, struct ptp_message *m)
return 0;
}

static int port_management_response(struct port *target, struct port *ingress,
int id, struct ptp_message *req)
static int port_management_get_response(struct port *target,
struct port *ingress, int id,
struct ptp_message *req)
{
int datalen = 0, err, pdulen, respond = 0;
struct management_tlv *tlv;
Expand Down Expand Up @@ -1613,9 +1614,23 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
return 0;
}
mgt = (struct management_tlv *) msg->management.suffix;
if (port_management_response(p, ingress, mgt->id, msg)) {
return 0;

switch (management_action(msg)) {
case GET:
if (port_management_get_response(p, ingress, mgt->id, msg))
return 0;
break;
case SET:
if (port_managment_error(p->portIdentity, ingress, msg,
NOT_SUPPORTED))
pr_err("port %hu: management error failed", portnum(p));
break;
case COMMAND:
case RESPONSE:
case ACKNOWLEDGE:
return -1;
}

switch (mgt->id) {
case CLOCK_DESCRIPTION:
case LOG_ANNOUNCE_INTERVAL:
Expand Down

0 comments on commit 2aaae08

Please sign in to comment.