Skip to content

Commit

Permalink
Prefix TLV IDs.
Browse files Browse the repository at this point in the history
To avoid conflicts in generic names add TLV_ prefix to all TLV IDs
defined in tlv.h.

Signed-off-by: Miroslav Lichvar <[email protected]>
  • Loading branch information
mlichvar authored and richardcochran committed Jul 9, 2014
1 parent 93b7807 commit 70dd682
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 288 deletions.
116 changes: 58 additions & 58 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,76 +336,76 @@ static int clock_management_fill_response(struct clock *c, struct port *p,
tlv->id = id;

switch (id) {
case USER_DESCRIPTION:
case TLV_USER_DESCRIPTION:
text = (struct PTPText *) tlv->data;
text->length = c->desc.userDescription.length;
memcpy(text->text, c->desc.userDescription.text, text->length);
datalen = 1 + text->length;
respond = 1;
break;
case DEFAULT_DATA_SET:
case TLV_DEFAULT_DATA_SET:
memcpy(tlv->data, &c->dds, sizeof(c->dds));
datalen = sizeof(c->dds);
respond = 1;
break;
case CURRENT_DATA_SET:
case TLV_CURRENT_DATA_SET:
memcpy(tlv->data, &c->cur, sizeof(c->cur));
datalen = sizeof(c->cur);
respond = 1;
break;
case PARENT_DATA_SET:
case TLV_PARENT_DATA_SET:
memcpy(tlv->data, &c->dad.pds, sizeof(c->dad.pds));
datalen = sizeof(c->dad.pds);
respond = 1;
break;
case TIME_PROPERTIES_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
memcpy(tlv->data, &c->tds, sizeof(c->tds));
datalen = sizeof(c->tds);
respond = 1;
break;
case PRIORITY1:
case TLV_PRIORITY1:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->dds.priority1;
datalen = sizeof(*mtd);
respond = 1;
break;
case PRIORITY2:
case TLV_PRIORITY2:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->dds.priority2;
datalen = sizeof(*mtd);
respond = 1;
break;
case DOMAIN:
case TLV_DOMAIN:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->dds.domainNumber;
datalen = sizeof(*mtd);
respond = 1;
break;
case SLAVE_ONLY:
case TLV_SLAVE_ONLY:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->dds.flags & DDS_SLAVE_ONLY;
datalen = sizeof(*mtd);
respond = 1;
break;
case CLOCK_ACCURACY:
case TLV_CLOCK_ACCURACY:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->dds.clockQuality.clockAccuracy;
datalen = sizeof(*mtd);
respond = 1;
break;
case TRACEABILITY_PROPERTIES:
case TLV_TRACEABILITY_PROPERTIES:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->tds.flags & (TIME_TRACEABLE|FREQ_TRACEABLE);
datalen = sizeof(*mtd);
respond = 1;
break;
case TIMESCALE_PROPERTIES:
case TLV_TIMESCALE_PROPERTIES:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = c->tds.flags & PTP_TIMESCALE;
datalen = sizeof(*mtd);
respond = 1;
break;
case TIME_STATUS_NP:
case TLV_TIME_STATUS_NP:
tsn = (struct time_status_np *) tlv->data;
tsn->master_offset = c->master_offset;
tsn->ingress_time = tmv_to_nanoseconds(c->t2);
Expand All @@ -423,7 +423,7 @@ static int clock_management_fill_response(struct clock *c, struct port *p,
datalen = sizeof(*tsn);
respond = 1;
break;
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
gsn = (struct grandmaster_settings_np *) tlv->data;
gsn->clockQuality = c->dds.clockQuality;
gsn->utc_offset = c->utc_offset;
Expand All @@ -432,7 +432,7 @@ static int clock_management_fill_response(struct clock *c, struct port *p,
datalen = sizeof(*gsn);
respond = 1;
break;
case SUBSCRIBE_EVENTS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
if (p != c->port[c->nports]) {
/* Only the UDS port allowed. */
break;
Expand Down Expand Up @@ -483,7 +483,7 @@ static int clock_management_set(struct clock *c, struct port *p,
tlv = (struct management_tlv *) req->management.suffix;

switch (id) {
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
gsn = (struct grandmaster_settings_np *) tlv->data;
c->dds.clockQuality = gsn->clockQuality;
c->utc_offset = gsn->utc_offset;
Expand All @@ -492,7 +492,7 @@ static int clock_management_set(struct clock *c, struct port *p,
*changed = 1;
respond = 1;
break;
case SUBSCRIBE_EVENTS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
sen = (struct subscribe_events_np *)tlv->data;
clock_update_subscription(c, req, sen->bitmask,
sen->duration);
Expand Down Expand Up @@ -1017,13 +1017,13 @@ int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
return changed;
break;
case SET:
if (mgt->length == 2 && mgt->id != NULL_MANAGEMENT) {
clock_management_send_error(p, msg, WRONG_LENGTH);
if (mgt->length == 2 && mgt->id != TLV_NULL_MANAGEMENT) {
clock_management_send_error(p, msg, TLV_WRONG_LENGTH);
return changed;
}
if (p != c->port[c->nports]) {
/* Sorry, only allowed on the UDS port. */
clock_management_send_error(p, msg, NOT_SUPPORTED);
clock_management_send_error(p, msg, TLV_NOT_SUPPORTED);
return changed;
}
if (clock_management_set(c, p, mgt->id, msg, &changed))
Expand All @@ -1036,49 +1036,49 @@ int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
}

switch (mgt->id) {
case PORT_PROPERTIES_NP:
case TLV_PORT_PROPERTIES_NP:
if (p != c->port[c->nports]) {
/* Only the UDS port allowed. */
clock_management_send_error(p, msg, NOT_SUPPORTED);
clock_management_send_error(p, msg, TLV_NOT_SUPPORTED);
return 0;
}
}

switch (mgt->id) {
case USER_DESCRIPTION:
case SAVE_IN_NON_VOLATILE_STORAGE:
case RESET_NON_VOLATILE_STORAGE:
case INITIALIZE:
case FAULT_LOG:
case FAULT_LOG_RESET:
case DEFAULT_DATA_SET:
case CURRENT_DATA_SET:
case PARENT_DATA_SET:
case TIME_PROPERTIES_DATA_SET:
case PRIORITY1:
case PRIORITY2:
case DOMAIN:
case SLAVE_ONLY:
case TIME:
case CLOCK_ACCURACY:
case UTC_PROPERTIES:
case TRACEABILITY_PROPERTIES:
case TIMESCALE_PROPERTIES:
case PATH_TRACE_LIST:
case PATH_TRACE_ENABLE:
case GRANDMASTER_CLUSTER_TABLE:
case ACCEPTABLE_MASTER_TABLE:
case ACCEPTABLE_MASTER_MAX_TABLE_SIZE:
case ALTERNATE_TIME_OFFSET_ENABLE:
case ALTERNATE_TIME_OFFSET_NAME:
case ALTERNATE_TIME_OFFSET_MAX_KEY:
case ALTERNATE_TIME_OFFSET_PROPERTIES:
case TRANSPARENT_CLOCK_DEFAULT_DATA_SET:
case PRIMARY_DOMAIN:
case TIME_STATUS_NP:
case GRANDMASTER_SETTINGS_NP:
case SUBSCRIBE_EVENTS_NP:
clock_management_send_error(p, msg, NOT_SUPPORTED);
case TLV_USER_DESCRIPTION:
case TLV_SAVE_IN_NON_VOLATILE_STORAGE:
case TLV_RESET_NON_VOLATILE_STORAGE:
case TLV_INITIALIZE:
case TLV_FAULT_LOG:
case TLV_FAULT_LOG_RESET:
case TLV_DEFAULT_DATA_SET:
case TLV_CURRENT_DATA_SET:
case TLV_PARENT_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
case TLV_PRIORITY1:
case TLV_PRIORITY2:
case TLV_DOMAIN:
case TLV_SLAVE_ONLY:
case TLV_TIME:
case TLV_CLOCK_ACCURACY:
case TLV_UTC_PROPERTIES:
case TLV_TRACEABILITY_PROPERTIES:
case TLV_TIMESCALE_PROPERTIES:
case TLV_PATH_TRACE_LIST:
case TLV_PATH_TRACE_ENABLE:
case TLV_GRANDMASTER_CLUSTER_TABLE:
case TLV_ACCEPTABLE_MASTER_TABLE:
case TLV_ACCEPTABLE_MASTER_MAX_TABLE_SIZE:
case TLV_ALTERNATE_TIME_OFFSET_ENABLE:
case TLV_ALTERNATE_TIME_OFFSET_NAME:
case TLV_ALTERNATE_TIME_OFFSET_MAX_KEY:
case TLV_ALTERNATE_TIME_OFFSET_PROPERTIES:
case TLV_TRANSPARENT_CLOCK_DEFAULT_DATA_SET:
case TLV_PRIMARY_DOMAIN:
case TLV_TIME_STATUS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
clock_management_send_error(p, msg, TLV_NOT_SUPPORTED);
break;
default:
answers = 0;
Expand All @@ -1091,8 +1091,8 @@ int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
}
if (!answers) {
/* IEEE 1588 Interpretation #21 suggests to use
* WRONG_VALUE for ports that do not exist */
clock_management_send_error(p, msg, WRONG_VALUE);
* TLV_WRONG_VALUE for ports that do not exist */
clock_management_send_error(p, msg, TLV_WRONG_VALUE);
}
break;
}
Expand Down
18 changes: 9 additions & 9 deletions phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static int recv_subscribed(struct node *node, struct ptp_message *msg,
if (mgt_id == excluded)
return 0;
switch (mgt_id) {
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
pds = get_mgt_data(msg);
port = port_get(node, pds->portIdentity.portNumber);
if (!port) {
Expand Down Expand Up @@ -732,7 +732,7 @@ static void send_subscription(struct node *node)
memset(&sen, 0, sizeof(sen));
sen.duration = PMC_SUBSCRIBE_DURATION;
sen.bitmask[0] = 1 << NOTIFY_PORT_STATE;
pmc_send_set_action(node->pmc, SUBSCRIBE_EVENTS_NP, &sen, sizeof(sen));
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, sizeof(sen));
}

static int init_pmc(struct node *node, int domain_number)
Expand Down Expand Up @@ -781,7 +781,7 @@ static int run_pmc(struct node *node, int timeout, int ds_id,
if ((pollfd[0].revents & POLLOUT) &&
!(pollfd[0].revents & (POLLIN|POLLPRI))) {
switch (ds_id) {
case SUBSCRIBE_EVENTS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
send_subscription(node);
break;
default:
Expand Down Expand Up @@ -829,7 +829,7 @@ static int run_pmc_wait_sync(struct node *node, int timeout)
Enumeration8 portState;

while (1) {
res = run_pmc(node, timeout, PORT_DATA_SET, &msg);
res = run_pmc(node, timeout, TLV_PORT_DATA_SET, &msg);
if (res <= 0)
return res;

Expand All @@ -853,7 +853,7 @@ static int run_pmc_get_utc_offset(struct node *node, int timeout)
int res;
struct timePropertiesDS *tds;

res = run_pmc(node, timeout, TIME_PROPERTIES_DATA_SET, &msg);
res = run_pmc(node, timeout, TLV_TIME_PROPERTIES_DATA_SET, &msg);
if (res <= 0)
return res;

Expand Down Expand Up @@ -883,7 +883,7 @@ static int run_pmc_get_number_ports(struct node *node, int timeout)
int res;
struct defaultDS *dds;

res = run_pmc(node, timeout, DEFAULT_DATA_SET, &msg);
res = run_pmc(node, timeout, TLV_DEFAULT_DATA_SET, &msg);
if (res <= 0)
return res;

Expand All @@ -898,7 +898,7 @@ static int run_pmc_subscribe(struct node *node, int timeout)
struct ptp_message *msg;
int res;

res = run_pmc(node, timeout, SUBSCRIBE_EVENTS_NP, &msg);
res = run_pmc(node, timeout, TLV_SUBSCRIBE_EVENTS_NP, &msg);
if (res <= 0)
return res;
msg_put(msg);
Expand All @@ -922,7 +922,7 @@ static int run_pmc_port_properties(struct node *node, int timeout,

pmc_target_port(node->pmc, port);
while (1) {
res = run_pmc(node, timeout, PORT_PROPERTIES_NP, &msg);
res = run_pmc(node, timeout, TLV_PORT_PROPERTIES_NP, &msg);
if (res <= 0)
goto out;

Expand Down Expand Up @@ -955,7 +955,7 @@ static int run_pmc_clock_identity(struct node *node, int timeout)
struct defaultDS *dds;
int res;

res = run_pmc(node, timeout, DEFAULT_DATA_SET, &msg);
res = run_pmc(node, timeout, TLV_DEFAULT_DATA_SET, &msg);
if (res <= 0)
return res;

Expand Down
Loading

0 comments on commit 70dd682

Please sign in to comment.