Prefix TLV IDs.

To avoid conflicts in generic names add TLV_ prefix to all TLV IDs
defined in tlv.h.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-06-25 12:45:23 +02:00 committed by Richard Cochran
parent 93b7807aad
commit 70dd682349
7 changed files with 288 additions and 288 deletions

116
clock.c
View File

@ -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);
@ -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;
@ -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;
@ -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;
@ -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);
@ -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))
@ -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;
@ -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;
}

View File

@ -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) {
@ -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)
@ -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:
@ -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;
@ -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;
@ -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;
@ -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);
@ -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;
@ -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;

152
pmc.c
View File

@ -56,57 +56,57 @@ struct management_id {
struct management_id idtab[] = {
/* Clock management ID values */
{ "USER_DESCRIPTION", USER_DESCRIPTION, do_get_action },
{ "SAVE_IN_NON_VOLATILE_STORAGE", SAVE_IN_NON_VOLATILE_STORAGE, not_supported },
{ "RESET_NON_VOLATILE_STORAGE", RESET_NON_VOLATILE_STORAGE, not_supported },
{ "INITIALIZE", INITIALIZE, not_supported },
{ "FAULT_LOG", FAULT_LOG, not_supported },
{ "FAULT_LOG_RESET", FAULT_LOG_RESET, not_supported },
{ "DEFAULT_DATA_SET", DEFAULT_DATA_SET, do_get_action },
{ "CURRENT_DATA_SET", CURRENT_DATA_SET, do_get_action },
{ "PARENT_DATA_SET", PARENT_DATA_SET, do_get_action },
{ "TIME_PROPERTIES_DATA_SET", TIME_PROPERTIES_DATA_SET, do_get_action },
{ "PRIORITY1", PRIORITY1, do_get_action },
{ "PRIORITY2", PRIORITY2, do_get_action },
{ "DOMAIN", DOMAIN, do_get_action },
{ "SLAVE_ONLY", SLAVE_ONLY, do_get_action },
{ "TIME", TIME, not_supported },
{ "CLOCK_ACCURACY", CLOCK_ACCURACY, do_get_action },
{ "UTC_PROPERTIES", UTC_PROPERTIES, not_supported },
{ "TRACEABILITY_PROPERTIES", TRACEABILITY_PROPERTIES, do_get_action },
{ "TIMESCALE_PROPERTIES", TIMESCALE_PROPERTIES, do_get_action },
{ "PATH_TRACE_LIST", PATH_TRACE_LIST, not_supported },
{ "PATH_TRACE_ENABLE", PATH_TRACE_ENABLE, not_supported },
{ "GRANDMASTER_CLUSTER_TABLE", GRANDMASTER_CLUSTER_TABLE, not_supported },
{ "ACCEPTABLE_MASTER_TABLE", ACCEPTABLE_MASTER_TABLE, not_supported },
{ "ACCEPTABLE_MASTER_MAX_TABLE_SIZE", ACCEPTABLE_MASTER_MAX_TABLE_SIZE, not_supported },
{ "ALTERNATE_TIME_OFFSET_ENABLE", ALTERNATE_TIME_OFFSET_ENABLE, not_supported },
{ "ALTERNATE_TIME_OFFSET_NAME", ALTERNATE_TIME_OFFSET_NAME, not_supported },
{ "ALTERNATE_TIME_OFFSET_MAX_KEY", ALTERNATE_TIME_OFFSET_MAX_KEY, not_supported },
{ "ALTERNATE_TIME_OFFSET_PROPERTIES", ALTERNATE_TIME_OFFSET_PROPERTIES, not_supported },
{ "TRANSPARENT_CLOCK_DEFAULT_DATA_SET", TRANSPARENT_CLOCK_DEFAULT_DATA_SET, not_supported },
{ "PRIMARY_DOMAIN", PRIMARY_DOMAIN, not_supported },
{ "TIME_STATUS_NP", TIME_STATUS_NP, do_get_action },
{ "GRANDMASTER_SETTINGS_NP", GRANDMASTER_SETTINGS_NP, do_set_action },
{ "USER_DESCRIPTION", TLV_USER_DESCRIPTION, do_get_action },
{ "SAVE_IN_NON_VOLATILE_STORAGE", TLV_SAVE_IN_NON_VOLATILE_STORAGE, not_supported },
{ "RESET_NON_VOLATILE_STORAGE", TLV_RESET_NON_VOLATILE_STORAGE, not_supported },
{ "INITIALIZE", TLV_INITIALIZE, not_supported },
{ "FAULT_LOG", TLV_FAULT_LOG, not_supported },
{ "FAULT_LOG_RESET", TLV_FAULT_LOG_RESET, not_supported },
{ "DEFAULT_DATA_SET", TLV_DEFAULT_DATA_SET, do_get_action },
{ "CURRENT_DATA_SET", TLV_CURRENT_DATA_SET, do_get_action },
{ "PARENT_DATA_SET", TLV_PARENT_DATA_SET, do_get_action },
{ "TIME_PROPERTIES_DATA_SET", TLV_TIME_PROPERTIES_DATA_SET, do_get_action },
{ "PRIORITY1", TLV_PRIORITY1, do_get_action },
{ "PRIORITY2", TLV_PRIORITY2, do_get_action },
{ "DOMAIN", TLV_DOMAIN, do_get_action },
{ "SLAVE_ONLY", TLV_SLAVE_ONLY, do_get_action },
{ "TIME", TLV_TIME, not_supported },
{ "CLOCK_ACCURACY", TLV_CLOCK_ACCURACY, do_get_action },
{ "UTC_PROPERTIES", TLV_UTC_PROPERTIES, not_supported },
{ "TRACEABILITY_PROPERTIES", TLV_TRACEABILITY_PROPERTIES, do_get_action },
{ "TIMESCALE_PROPERTIES", TLV_TIMESCALE_PROPERTIES, do_get_action },
{ "PATH_TRACE_LIST", TLV_PATH_TRACE_LIST, not_supported },
{ "PATH_TRACE_ENABLE", TLV_PATH_TRACE_ENABLE, not_supported },
{ "GRANDMASTER_CLUSTER_TABLE", TLV_GRANDMASTER_CLUSTER_TABLE, not_supported },
{ "ACCEPTABLE_MASTER_TABLE", TLV_ACCEPTABLE_MASTER_TABLE, not_supported },
{ "ACCEPTABLE_MASTER_MAX_TABLE_SIZE", TLV_ACCEPTABLE_MASTER_MAX_TABLE_SIZE, not_supported },
{ "ALTERNATE_TIME_OFFSET_ENABLE", TLV_ALTERNATE_TIME_OFFSET_ENABLE, not_supported },
{ "ALTERNATE_TIME_OFFSET_NAME", TLV_ALTERNATE_TIME_OFFSET_NAME, not_supported },
{ "ALTERNATE_TIME_OFFSET_MAX_KEY", TLV_ALTERNATE_TIME_OFFSET_MAX_KEY, not_supported },
{ "ALTERNATE_TIME_OFFSET_PROPERTIES", TLV_ALTERNATE_TIME_OFFSET_PROPERTIES, not_supported },
{ "TRANSPARENT_CLOCK_DEFAULT_DATA_SET", TLV_TRANSPARENT_CLOCK_DEFAULT_DATA_SET, not_supported },
{ "PRIMARY_DOMAIN", TLV_PRIMARY_DOMAIN, not_supported },
{ "TIME_STATUS_NP", TLV_TIME_STATUS_NP, do_get_action },
{ "GRANDMASTER_SETTINGS_NP", TLV_GRANDMASTER_SETTINGS_NP, do_set_action },
/* Port management ID values */
{ "NULL_MANAGEMENT", NULL_MANAGEMENT, null_management },
{ "CLOCK_DESCRIPTION", CLOCK_DESCRIPTION, do_get_action },
{ "PORT_DATA_SET", PORT_DATA_SET, do_get_action },
{ "LOG_ANNOUNCE_INTERVAL", LOG_ANNOUNCE_INTERVAL, do_get_action },
{ "ANNOUNCE_RECEIPT_TIMEOUT", ANNOUNCE_RECEIPT_TIMEOUT, do_get_action },
{ "LOG_SYNC_INTERVAL", LOG_SYNC_INTERVAL, do_get_action },
{ "VERSION_NUMBER", VERSION_NUMBER, do_get_action },
{ "ENABLE_PORT", ENABLE_PORT, not_supported },
{ "DISABLE_PORT", DISABLE_PORT, not_supported },
{ "UNICAST_NEGOTIATION_ENABLE", UNICAST_NEGOTIATION_ENABLE, not_supported },
{ "UNICAST_MASTER_TABLE", UNICAST_MASTER_TABLE, not_supported },
{ "UNICAST_MASTER_MAX_TABLE_SIZE", UNICAST_MASTER_MAX_TABLE_SIZE, not_supported },
{ "ACCEPTABLE_MASTER_TABLE_ENABLED", ACCEPTABLE_MASTER_TABLE_ENABLED, not_supported },
{ "ALTERNATE_MASTER", ALTERNATE_MASTER, not_supported },
{ "TRANSPARENT_CLOCK_PORT_DATA_SET", TRANSPARENT_CLOCK_PORT_DATA_SET, not_supported },
{ "DELAY_MECHANISM", DELAY_MECHANISM, do_get_action },
{ "LOG_MIN_PDELAY_REQ_INTERVAL", LOG_MIN_PDELAY_REQ_INTERVAL, do_get_action },
{ "PORT_DATA_SET_NP", PORT_DATA_SET_NP, do_set_action },
{ "NULL_MANAGEMENT", TLV_NULL_MANAGEMENT, null_management },
{ "CLOCK_DESCRIPTION", TLV_CLOCK_DESCRIPTION, do_get_action },
{ "PORT_DATA_SET", TLV_PORT_DATA_SET, do_get_action },
{ "LOG_ANNOUNCE_INTERVAL", TLV_LOG_ANNOUNCE_INTERVAL, do_get_action },
{ "ANNOUNCE_RECEIPT_TIMEOUT", TLV_ANNOUNCE_RECEIPT_TIMEOUT, do_get_action },
{ "LOG_SYNC_INTERVAL", TLV_LOG_SYNC_INTERVAL, do_get_action },
{ "VERSION_NUMBER", TLV_VERSION_NUMBER, do_get_action },
{ "ENABLE_PORT", TLV_ENABLE_PORT, not_supported },
{ "DISABLE_PORT", TLV_DISABLE_PORT, not_supported },
{ "UNICAST_NEGOTIATION_ENABLE", TLV_UNICAST_NEGOTIATION_ENABLE, not_supported },
{ "UNICAST_MASTER_TABLE", TLV_UNICAST_MASTER_TABLE, not_supported },
{ "UNICAST_MASTER_MAX_TABLE_SIZE", TLV_UNICAST_MASTER_MAX_TABLE_SIZE, not_supported },
{ "ACCEPTABLE_MASTER_TABLE_ENABLED", TLV_ACCEPTABLE_MASTER_TABLE_ENABLED, not_supported },
{ "ALTERNATE_MASTER", TLV_ALTERNATE_MASTER, not_supported },
{ "TRANSPARENT_CLOCK_PORT_DATA_SET", TLV_TRANSPARENT_CLOCK_PORT_DATA_SET, not_supported },
{ "DELAY_MECHANISM", TLV_DELAY_MECHANISM, do_get_action },
{ "LOG_MIN_PDELAY_REQ_INTERVAL", TLV_LOG_MIN_PDELAY_REQ_INTERVAL, do_get_action },
{ "PORT_DATA_SET_NP", TLV_PORT_DATA_SET_NP, do_set_action },
};
static const char *action_string[] = {
@ -219,12 +219,12 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
fprintf(fp, "unknown-tlv ");
}
mgt = (struct management_tlv *) msg->management.suffix;
if (mgt->length == 2 && mgt->id != NULL_MANAGEMENT) {
if (mgt->length == 2 && mgt->id != TLV_NULL_MANAGEMENT) {
fprintf(fp, "empty-tlv ");
goto out;
}
switch (mgt->id) {
case CLOCK_DESCRIPTION:
case TLV_CLOCK_DESCRIPTION:
cd = &msg->last_tlv.cd;
fprintf(fp, "CLOCK_DESCRIPTION "
IFMT "clockType 0x%hx"
@ -248,12 +248,12 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
text2str(cd->userDescription),
bin2str(cd->profileIdentity, PROFILE_ID_LEN));
break;
case USER_DESCRIPTION:
case TLV_USER_DESCRIPTION:
fprintf(fp, "USER_DESCRIPTION "
IFMT "userDescription %s",
text2str(msg->last_tlv.cd.userDescription));
break;
case DEFAULT_DATA_SET:
case TLV_DEFAULT_DATA_SET:
dds = (struct defaultDS *) mgt->data;
fprintf(fp, "DEFAULT_DATA_SET "
IFMT "twoStepFlag %d"
@ -277,7 +277,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
cid2str(&dds->clockIdentity),
dds->domainNumber);
break;
case CURRENT_DATA_SET:
case TLV_CURRENT_DATA_SET:
cds = (struct currentDS *) mgt->data;
fprintf(fp, "CURRENT_DATA_SET "
IFMT "stepsRemoved %hd"
@ -286,7 +286,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
cds->stepsRemoved, cds->offsetFromMaster / 65536.0,
cds->meanPathDelay / 65536.0);
break;
case PARENT_DATA_SET:
case TLV_PARENT_DATA_SET:
pds = (struct parentDS *) mgt->data;
fprintf(fp, "PARENT_DATA_SET "
IFMT "parentPortIdentity %s"
@ -310,7 +310,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
pds->grandmasterPriority2,
cid2str(&pds->grandmasterIdentity));
break;
case TIME_PROPERTIES_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
tp = (struct timePropertiesDS *) mgt->data;
fprintf(fp, "TIME_PROPERTIES_DATA_SET "
IFMT "currentUtcOffset %hd"
@ -330,32 +330,32 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
tp->flags & FREQ_TRACEABLE ? 1 : 0,
tp->timeSource);
break;
case PRIORITY1:
case TLV_PRIORITY1:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "PRIORITY1 "
IFMT "priority1 %hhu", mtd->val);
break;
case PRIORITY2:
case TLV_PRIORITY2:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "PRIORITY2 "
IFMT "priority2 %hhu", mtd->val);
break;
case DOMAIN:
case TLV_DOMAIN:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "DOMAIN "
IFMT "domainNumber %hhu", mtd->val);
break;
case SLAVE_ONLY:
case TLV_SLAVE_ONLY:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "SLAVE_ONLY "
IFMT "slaveOnly %d", mtd->val & DDS_SLAVE_ONLY ? 1 : 0);
break;
case CLOCK_ACCURACY:
case TLV_CLOCK_ACCURACY:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "CLOCK_ACCURACY "
IFMT "clockAccuracy 0x%02hhx", mtd->val);
break;
case TRACEABILITY_PROPERTIES:
case TLV_TRACEABILITY_PROPERTIES:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "TRACEABILITY_PROPERTIES "
IFMT "timeTraceable %d"
@ -363,12 +363,12 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
mtd->val & TIME_TRACEABLE ? 1 : 0,
mtd->val & FREQ_TRACEABLE ? 1 : 0);
break;
case TIMESCALE_PROPERTIES:
case TLV_TIMESCALE_PROPERTIES:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "TIMESCALE_PROPERTIES "
IFMT "ptpTimescale %d", mtd->val & PTP_TIMESCALE ? 1 : 0);
break;
case TIME_STATUS_NP:
case TLV_TIME_STATUS_NP:
tsn = (struct time_status_np *) mgt->data;
fprintf(fp, "TIME_STATUS_NP "
IFMT "master_offset %" PRId64
@ -390,7 +390,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
tsn->gmPresent ? "true" : "false",
cid2str(&tsn->gmIdentity));
break;
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
gsn = (struct grandmaster_settings_np *) mgt->data;
fprintf(fp, "GRANDMASTER_SETTINGS_NP "
IFMT "clockClass %hhu"
@ -416,7 +416,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
gsn->time_flags & FREQ_TRACEABLE ? 1 : 0,
gsn->time_source);
break;
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
p = (struct portDS *) mgt->data;
if (p->portState > PS_SLAVE) {
p->portState = 0;
@ -438,7 +438,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
p->logSyncInterval, p->delayMechanism,
p->logMinPdelayReqInterval, p->versionNumber);
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
pnp = (struct port_ds_np *) mgt->data;
fprintf(fp, "PORT_DATA_SET_NP "
IFMT "neighborPropDelayThresh %u"
@ -446,32 +446,32 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
pnp->neighborPropDelayThresh,
pnp->asCapable ? 1 : 0);
break;
case LOG_ANNOUNCE_INTERVAL:
case TLV_LOG_ANNOUNCE_INTERVAL:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "LOG_ANNOUNCE_INTERVAL "
IFMT "logAnnounceInterval %hhd", mtd->val);
break;
case ANNOUNCE_RECEIPT_TIMEOUT:
case TLV_ANNOUNCE_RECEIPT_TIMEOUT:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "ANNOUNCE_RECEIPT_TIMEOUT "
IFMT "announceReceiptTimeout %hhu", mtd->val);
break;
case LOG_SYNC_INTERVAL:
case TLV_LOG_SYNC_INTERVAL:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "ANNOUNCE_RECEIPT_TIMEOUT "
IFMT "logSyncInterval %hhd", mtd->val);
break;
case VERSION_NUMBER:
case TLV_VERSION_NUMBER:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "VERSION_NUMBER "
IFMT "versionNumber %hhu", mtd->val);
break;
case DELAY_MECHANISM:
case TLV_DELAY_MECHANISM:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "DELAY_MECHANISM "
IFMT "delayMechanism %hhu", mtd->val);
break;
case LOG_MIN_PDELAY_REQ_INTERVAL:
case TLV_LOG_MIN_PDELAY_REQ_INTERVAL:
mtd = (struct management_tlv_datum *) mgt->data;
fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL "
IFMT "logMinPdelayReqInterval %hhd", mtd->val);
@ -513,7 +513,7 @@ static void do_set_action(int action, int index, char *str)
return;
}
switch (code) {
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
cnt = sscanf(str, " %*s %*s "
"clockClass %hhu "
"clockAccuracy %hhx "
@ -557,7 +557,7 @@ static void do_set_action(int action, int index, char *str)
gsn.time_flags |= FREQ_TRACEABLE;
pmc_send_set_action(pmc, code, &gsn, sizeof(gsn));
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
cnt = sscanf(str, " %*s %*s "
"neighborPropDelayThresh %u "
"asCapable %d ",

View File

@ -161,53 +161,53 @@ static int pmc_tlv_datalen(struct pmc *pmc, int id)
return len;
switch (id) {
case USER_DESCRIPTION:
case TLV_USER_DESCRIPTION:
len += EMPTY_PTP_TEXT;
break;
case DEFAULT_DATA_SET:
case TLV_DEFAULT_DATA_SET:
len += sizeof(struct defaultDS);
break;
case CURRENT_DATA_SET:
case TLV_CURRENT_DATA_SET:
len += sizeof(struct currentDS);
break;
case PARENT_DATA_SET:
case TLV_PARENT_DATA_SET:
len += sizeof(struct parentDS);
break;
case TIME_PROPERTIES_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
len += sizeof(struct timePropertiesDS);
break;
case PRIORITY1:
case PRIORITY2:
case DOMAIN:
case SLAVE_ONLY:
case CLOCK_ACCURACY:
case TRACEABILITY_PROPERTIES:
case TIMESCALE_PROPERTIES:
case TLV_PRIORITY1:
case TLV_PRIORITY2:
case TLV_DOMAIN:
case TLV_SLAVE_ONLY:
case TLV_CLOCK_ACCURACY:
case TLV_TRACEABILITY_PROPERTIES:
case TLV_TIMESCALE_PROPERTIES:
len += sizeof(struct management_tlv_datum);
break;
case TIME_STATUS_NP:
case TLV_TIME_STATUS_NP:
len += sizeof(struct time_status_np);
break;
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
len += sizeof(struct grandmaster_settings_np);
break;
case NULL_MANAGEMENT:
case TLV_NULL_MANAGEMENT:
break;
case CLOCK_DESCRIPTION:
case TLV_CLOCK_DESCRIPTION:
len += EMPTY_CLOCK_DESCRIPTION;
break;
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
len += sizeof(struct portDS);
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
len += sizeof(struct port_ds_np);
break;
case LOG_ANNOUNCE_INTERVAL:
case ANNOUNCE_RECEIPT_TIMEOUT:
case LOG_SYNC_INTERVAL:
case VERSION_NUMBER:
case DELAY_MECHANISM:
case LOG_MIN_PDELAY_REQ_INTERVAL:
case TLV_LOG_ANNOUNCE_INTERVAL:
case TLV_ANNOUNCE_RECEIPT_TIMEOUT:
case TLV_LOG_SYNC_INTERVAL:
case TLV_VERSION_NUMBER:
case TLV_DELAY_MECHANISM:
case TLV_LOG_MIN_PDELAY_REQ_INTERVAL:
len += sizeof(struct management_tlv_datum);
break;
}
@ -237,7 +237,7 @@ int pmc_send_get_action(struct pmc *pmc, int id)
msg->header.messageLength = pdulen;
msg->tlv_count = 1;
if (id == CLOCK_DESCRIPTION && !pmc->zero_length_gets) {
if (id == TLV_CLOCK_DESCRIPTION && !pmc->zero_length_gets) {
/*
* Make sure the tlv_extra pointers dereferenced in
* mgt_pre_send() do point to something.

64
port.c
View File

@ -622,11 +622,11 @@ static int port_management_fill_response(struct port *target,
tlv->id = id;
switch (id) {
case NULL_MANAGEMENT:
case TLV_NULL_MANAGEMENT:
datalen = 0;
respond = 1;
break;
case CLOCK_DESCRIPTION:
case TLV_CLOCK_DESCRIPTION:
cd = &rsp->last_tlv.cd;
buf = tlv->data;
cd->clockType = (UInteger16 *) buf;
@ -692,7 +692,7 @@ static int port_management_fill_response(struct port *target,
datalen = buf - tlv->data;
respond = 1;
break;
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
pds = (struct portDS *) tlv->data;
pds->portIdentity = target->portIdentity;
if (target->state == PS_GRAND_MASTER) {
@ -715,31 +715,31 @@ static int port_management_fill_response(struct port *target,
datalen = sizeof(*pds);
respond = 1;
break;
case LOG_ANNOUNCE_INTERVAL:
case TLV_LOG_ANNOUNCE_INTERVAL:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = target->logAnnounceInterval;
datalen = sizeof(*mtd);
respond = 1;
break;
case ANNOUNCE_RECEIPT_TIMEOUT:
case TLV_ANNOUNCE_RECEIPT_TIMEOUT:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = target->announceReceiptTimeout;
datalen = sizeof(*mtd);
respond = 1;
break;
case LOG_SYNC_INTERVAL:
case TLV_LOG_SYNC_INTERVAL:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = target->logSyncInterval;
datalen = sizeof(*mtd);
respond = 1;
break;
case VERSION_NUMBER:
case TLV_VERSION_NUMBER:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = target->versionNumber;
datalen = sizeof(*mtd);
respond = 1;
break;
case DELAY_MECHANISM:
case TLV_DELAY_MECHANISM:
mtd = (struct management_tlv_datum *) tlv->data;
if (target->delayMechanism)
mtd->val = target->delayMechanism;
@ -748,20 +748,20 @@ static int port_management_fill_response(struct port *target,
datalen = sizeof(*mtd);
respond = 1;
break;
case LOG_MIN_PDELAY_REQ_INTERVAL:
case TLV_LOG_MIN_PDELAY_REQ_INTERVAL:
mtd = (struct management_tlv_datum *) tlv->data;
mtd->val = target->logMinPdelayReqInterval;
datalen = sizeof(*mtd);
respond = 1;
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
pdsnp = (struct port_ds_np *) tlv->data;
pdsnp->neighborPropDelayThresh = target->neighborPropDelayThresh;
pdsnp->asCapable = target->asCapable;
datalen = sizeof(*pdsnp);
respond = 1;
break;
case PORT_PROPERTIES_NP:
case TLV_PORT_PROPERTIES_NP:
ppn = (struct port_properties_np *)tlv->data;
ppn->portIdentity = target->portIdentity;
if (target->state == PS_GRAND_MASTER)
@ -816,7 +816,7 @@ static int port_management_set(struct port *target,
tlv = (struct management_tlv *) req->management.suffix;
switch (id) {
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
pdsnp = (struct port_ds_np *) tlv->data;
target->neighborPropDelayThresh = pdsnp->neighborPropDelayThresh;
respond = 1;
@ -2243,27 +2243,27 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
}
switch (mgt->id) {
case NULL_MANAGEMENT:
case CLOCK_DESCRIPTION:
case PORT_DATA_SET:
case LOG_ANNOUNCE_INTERVAL:
case ANNOUNCE_RECEIPT_TIMEOUT:
case LOG_SYNC_INTERVAL:
case VERSION_NUMBER:
case ENABLE_PORT:
case DISABLE_PORT:
case UNICAST_NEGOTIATION_ENABLE:
case UNICAST_MASTER_TABLE:
case UNICAST_MASTER_MAX_TABLE_SIZE:
case ACCEPTABLE_MASTER_TABLE_ENABLED:
case ALTERNATE_MASTER:
case TRANSPARENT_CLOCK_PORT_DATA_SET:
case DELAY_MECHANISM:
case LOG_MIN_PDELAY_REQ_INTERVAL:
port_management_send_error(p, ingress, msg, NOT_SUPPORTED);
case TLV_NULL_MANAGEMENT:
case TLV_CLOCK_DESCRIPTION:
case TLV_PORT_DATA_SET:
case TLV_LOG_ANNOUNCE_INTERVAL:
case TLV_ANNOUNCE_RECEIPT_TIMEOUT:
case TLV_LOG_SYNC_INTERVAL:
case TLV_VERSION_NUMBER:
case TLV_ENABLE_PORT:
case TLV_DISABLE_PORT:
case TLV_UNICAST_NEGOTIATION_ENABLE:
case TLV_UNICAST_MASTER_TABLE:
case TLV_UNICAST_MASTER_MAX_TABLE_SIZE:
case TLV_ACCEPTABLE_MASTER_TABLE_ENABLED:
case TLV_ALTERNATE_MASTER:
case TLV_TRANSPARENT_CLOCK_PORT_DATA_SET:
case TLV_DELAY_MECHANISM:
case TLV_LOG_MIN_PDELAY_REQ_INTERVAL:
port_management_send_error(p, ingress, msg, TLV_NOT_SUPPORTED);
break;
default:
port_management_send_error(p, ingress, msg, NO_SUCH_ID);
port_management_send_error(p, ingress, msg, TLV_NO_SUCH_ID);
return -1;
}
return 1;
@ -2367,7 +2367,7 @@ void port_notify_event(struct port *p, enum notification event)
switch (event) {
case NOTIFY_PORT_STATE:
id = PORT_DATA_SET;
id = TLV_PORT_DATA_SET;
break;
default:
return;

58
tlv.c
View File

@ -69,7 +69,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
uint8_t *buf;
uint16_t u16;
switch (m->id) {
case CLOCK_DESCRIPTION:
case TLV_CLOCK_DESCRIPTION:
cd = &extra->cd;
buf = m->data;
len = data_len;
@ -168,14 +168,14 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
extra_len = buf - m->data;
break;
case USER_DESCRIPTION:
case TLV_USER_DESCRIPTION:
if (data_len < sizeof(struct PTPText))
goto bad_length;
extra->cd.userDescription = (struct PTPText *) m->data;
extra_len = sizeof(struct PTPText);
extra_len += extra->cd.userDescription->length;
break;
case DEFAULT_DATA_SET:
case TLV_DEFAULT_DATA_SET:
if (data_len != sizeof(struct defaultDS))
goto bad_length;
dds = (struct defaultDS *) m->data;
@ -183,7 +183,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
dds->clockQuality.offsetScaledLogVariance =
ntohs(dds->clockQuality.offsetScaledLogVariance);
break;
case CURRENT_DATA_SET:
case TLV_CURRENT_DATA_SET:
if (data_len != sizeof(struct currentDS))
goto bad_length;
cds = (struct currentDS *) m->data;
@ -191,7 +191,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
cds->offsetFromMaster = net2host64(cds->offsetFromMaster);
cds->meanPathDelay = net2host64(cds->meanPathDelay);
break;
case PARENT_DATA_SET:
case TLV_PARENT_DATA_SET:
if (data_len != sizeof(struct parentDS))
goto bad_length;
pds = (struct parentDS *) m->data;
@ -204,20 +204,20 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
pds->grandmasterClockQuality.offsetScaledLogVariance =
ntohs(pds->grandmasterClockQuality.offsetScaledLogVariance);
break;
case TIME_PROPERTIES_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
if (data_len != sizeof(struct timePropertiesDS))
goto bad_length;
tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = ntohs(tp->currentUtcOffset);
break;
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
if (data_len != sizeof(struct portDS))
goto bad_length;
p = (struct portDS *) m->data;
p->portIdentity.portNumber = ntohs(p->portIdentity.portNumber);
p->peerMeanPathDelay = net2host64(p->peerMeanPathDelay);
break;
case TIME_STATUS_NP:
case TLV_TIME_STATUS_NP:
if (data_len != sizeof(struct time_status_np))
goto bad_length;
tsn = (struct time_status_np *) m->data;
@ -229,7 +229,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
scaled_ns_n2h(&tsn->lastGmPhaseChange);
tsn->gmPresent = ntohl(tsn->gmPresent);
break;
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
if (data_len != sizeof(struct grandmaster_settings_np))
goto bad_length;
gsn = (struct grandmaster_settings_np *) m->data;
@ -237,20 +237,20 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
ntohs(gsn->clockQuality.offsetScaledLogVariance);
gsn->utc_offset = ntohs(gsn->utc_offset);
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
if (data_len != sizeof(struct port_ds_np))
goto bad_length;
pdsnp = (struct port_ds_np *) m->data;
pdsnp->neighborPropDelayThresh = ntohl(pdsnp->neighborPropDelayThresh);
pdsnp->asCapable = ntohl(pdsnp->asCapable);
break;
case SUBSCRIBE_EVENTS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
if (data_len != sizeof(struct subscribe_events_np))
goto bad_length;
sen = (struct subscribe_events_np *)m->data;
sen->duration = ntohs(sen->duration);
break;
case PORT_PROPERTIES_NP:
case TLV_PORT_PROPERTIES_NP:
if (data_len < sizeof(struct port_properties_np))
goto bad_length;
ppn = (struct port_properties_np *)m->data;
@ -258,12 +258,12 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
extra_len = sizeof(struct port_properties_np);
extra_len += ppn->interface.length;
break;
case SAVE_IN_NON_VOLATILE_STORAGE:
case RESET_NON_VOLATILE_STORAGE:
case INITIALIZE:
case FAULT_LOG_RESET:
case ENABLE_PORT:
case DISABLE_PORT:
case TLV_SAVE_IN_NON_VOLATILE_STORAGE:
case TLV_RESET_NON_VOLATILE_STORAGE:
case TLV_INITIALIZE:
case TLV_FAULT_LOG_RESET:
case TLV_ENABLE_PORT:
case TLV_DISABLE_PORT:
if (data_len != 0)
goto bad_length;
break;
@ -293,7 +293,7 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
struct port_properties_np *ppn;
struct mgmt_clock_description *cd;
switch (m->id) {
case CLOCK_DESCRIPTION:
case TLV_CLOCK_DESCRIPTION:
if (extra) {
cd = &extra->cd;
flip16(cd->clockType);
@ -302,19 +302,19 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
flip16(&cd->protocolAddress->addressLength);
}
break;
case DEFAULT_DATA_SET:
case TLV_DEFAULT_DATA_SET:
dds = (struct defaultDS *) m->data;
dds->numberPorts = htons(dds->numberPorts);
dds->clockQuality.offsetScaledLogVariance =
htons(dds->clockQuality.offsetScaledLogVariance);
break;
case CURRENT_DATA_SET:
case TLV_CURRENT_DATA_SET:
cds = (struct currentDS *) m->data;
cds->stepsRemoved = htons(cds->stepsRemoved);
cds->offsetFromMaster = host2net64(cds->offsetFromMaster);
cds->meanPathDelay = host2net64(cds->meanPathDelay);
break;
case PARENT_DATA_SET:
case TLV_PARENT_DATA_SET:
pds = (struct parentDS *) m->data;
pds->parentPortIdentity.portNumber =
htons(pds->parentPortIdentity.portNumber);
@ -325,16 +325,16 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
pds->grandmasterClockQuality.offsetScaledLogVariance =
htons(pds->grandmasterClockQuality.offsetScaledLogVariance);
break;
case TIME_PROPERTIES_DATA_SET:
case TLV_TIME_PROPERTIES_DATA_SET:
tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = htons(tp->currentUtcOffset);
break;
case PORT_DATA_SET:
case TLV_PORT_DATA_SET:
p = (struct portDS *) m->data;
p->portIdentity.portNumber = htons(p->portIdentity.portNumber);
p->peerMeanPathDelay = host2net64(p->peerMeanPathDelay);
break;
case TIME_STATUS_NP:
case TLV_TIME_STATUS_NP:
tsn = (struct time_status_np *) m->data;
tsn->master_offset = host2net64(tsn->master_offset);
tsn->ingress_time = host2net64(tsn->ingress_time);
@ -344,22 +344,22 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
scaled_ns_h2n(&tsn->lastGmPhaseChange);
tsn->gmPresent = htonl(tsn->gmPresent);
break;
case GRANDMASTER_SETTINGS_NP:
case TLV_GRANDMASTER_SETTINGS_NP:
gsn = (struct grandmaster_settings_np *) m->data;
gsn->clockQuality.offsetScaledLogVariance =
htons(gsn->clockQuality.offsetScaledLogVariance);
gsn->utc_offset = htons(gsn->utc_offset);
break;
case PORT_DATA_SET_NP:
case TLV_PORT_DATA_SET_NP:
pdsnp = (struct port_ds_np *) m->data;
pdsnp->neighborPropDelayThresh = htonl(pdsnp->neighborPropDelayThresh);
pdsnp->asCapable = htonl(pdsnp->asCapable);
break;
case SUBSCRIBE_EVENTS_NP:
case TLV_SUBSCRIBE_EVENTS_NP:
sen = (struct subscribe_events_np *)m->data;
sen->duration = htons(sen->duration);
break;
case PORT_PROPERTIES_NP:
case TLV_PORT_PROPERTIES_NP:
ppn = (struct port_properties_np *)m->data;
ppn->portIdentity.portNumber = htons(ppn->portIdentity.portNumber);
break;

118
tlv.h
View File

@ -47,69 +47,69 @@ enum management_action {
};
/* Clock management ID values */
#define USER_DESCRIPTION 0x0002
#define SAVE_IN_NON_VOLATILE_STORAGE 0x0003
#define RESET_NON_VOLATILE_STORAGE 0x0004
#define INITIALIZE 0x0005
#define FAULT_LOG 0x0006
#define FAULT_LOG_RESET 0x0007
#define DEFAULT_DATA_SET 0x2000
#define CURRENT_DATA_SET 0x2001
#define PARENT_DATA_SET 0x2002
#define TIME_PROPERTIES_DATA_SET 0x2003
#define PRIORITY1 0x2005
#define PRIORITY2 0x2006
#define DOMAIN 0x2007
#define SLAVE_ONLY 0x2008
#define TIME 0x200F
#define CLOCK_ACCURACY 0x2010
#define UTC_PROPERTIES 0x2011
#define TRACEABILITY_PROPERTIES 0x2012
#define TIMESCALE_PROPERTIES 0x2013
#define PATH_TRACE_LIST 0x2015
#define PATH_TRACE_ENABLE 0x2016
#define GRANDMASTER_CLUSTER_TABLE 0x2017
#define ACCEPTABLE_MASTER_TABLE 0x201A
#define ACCEPTABLE_MASTER_MAX_TABLE_SIZE 0x201C
#define ALTERNATE_TIME_OFFSET_ENABLE 0x201E
#define ALTERNATE_TIME_OFFSET_NAME 0x201F
#define ALTERNATE_TIME_OFFSET_MAX_KEY 0x2020
#define ALTERNATE_TIME_OFFSET_PROPERTIES 0x2021
#define TRANSPARENT_CLOCK_DEFAULT_DATA_SET 0x4000
#define PRIMARY_DOMAIN 0x4002
#define TIME_STATUS_NP 0xC000
#define GRANDMASTER_SETTINGS_NP 0xC001
#define SUBSCRIBE_EVENTS_NP 0xC003
#define TLV_USER_DESCRIPTION 0x0002
#define TLV_SAVE_IN_NON_VOLATILE_STORAGE 0x0003
#define TLV_RESET_NON_VOLATILE_STORAGE 0x0004
#define TLV_INITIALIZE 0x0005
#define TLV_FAULT_LOG 0x0006
#define TLV_FAULT_LOG_RESET 0x0007
#define TLV_DEFAULT_DATA_SET 0x2000
#define TLV_CURRENT_DATA_SET 0x2001
#define TLV_PARENT_DATA_SET 0x2002
#define TLV_TIME_PROPERTIES_DATA_SET 0x2003
#define TLV_PRIORITY1 0x2005
#define TLV_PRIORITY2 0x2006
#define TLV_DOMAIN 0x2007
#define TLV_SLAVE_ONLY 0x2008
#define TLV_TIME 0x200F
#define TLV_CLOCK_ACCURACY 0x2010
#define TLV_UTC_PROPERTIES 0x2011
#define TLV_TRACEABILITY_PROPERTIES 0x2012
#define TLV_TIMESCALE_PROPERTIES 0x2013
#define TLV_PATH_TRACE_LIST 0x2015
#define TLV_PATH_TRACE_ENABLE 0x2016
#define TLV_GRANDMASTER_CLUSTER_TABLE 0x2017
#define TLV_ACCEPTABLE_MASTER_TABLE 0x201A
#define TLV_ACCEPTABLE_MASTER_MAX_TABLE_SIZE 0x201C
#define TLV_ALTERNATE_TIME_OFFSET_ENABLE 0x201E
#define TLV_ALTERNATE_TIME_OFFSET_NAME 0x201F
#define TLV_ALTERNATE_TIME_OFFSET_MAX_KEY 0x2020
#define TLV_ALTERNATE_TIME_OFFSET_PROPERTIES 0x2021
#define TLV_TRANSPARENT_CLOCK_DEFAULT_DATA_SET 0x4000
#define TLV_PRIMARY_DOMAIN 0x4002
#define TLV_TIME_STATUS_NP 0xC000
#define TLV_GRANDMASTER_SETTINGS_NP 0xC001
#define TLV_SUBSCRIBE_EVENTS_NP 0xC003
/* Port management ID values */
#define NULL_MANAGEMENT 0x0000
#define CLOCK_DESCRIPTION 0x0001
#define PORT_DATA_SET 0x2004
#define LOG_ANNOUNCE_INTERVAL 0x2009
#define ANNOUNCE_RECEIPT_TIMEOUT 0x200A
#define LOG_SYNC_INTERVAL 0x200B
#define VERSION_NUMBER 0x200C
#define ENABLE_PORT 0x200D
#define DISABLE_PORT 0x200E
#define UNICAST_NEGOTIATION_ENABLE 0x2014
#define UNICAST_MASTER_TABLE 0x2018
#define UNICAST_MASTER_MAX_TABLE_SIZE 0x2019
#define ACCEPTABLE_MASTER_TABLE_ENABLED 0x201B
#define ALTERNATE_MASTER 0x201D
#define TRANSPARENT_CLOCK_PORT_DATA_SET 0x4001
#define DELAY_MECHANISM 0x6000
#define LOG_MIN_PDELAY_REQ_INTERVAL 0x6001
#define PORT_DATA_SET_NP 0xC002
#define PORT_PROPERTIES_NP 0xC004
#define TLV_NULL_MANAGEMENT 0x0000
#define TLV_CLOCK_DESCRIPTION 0x0001
#define TLV_PORT_DATA_SET 0x2004
#define TLV_LOG_ANNOUNCE_INTERVAL 0x2009
#define TLV_ANNOUNCE_RECEIPT_TIMEOUT 0x200A
#define TLV_LOG_SYNC_INTERVAL 0x200B
#define TLV_VERSION_NUMBER 0x200C
#define TLV_ENABLE_PORT 0x200D
#define TLV_DISABLE_PORT 0x200E
#define TLV_UNICAST_NEGOTIATION_ENABLE 0x2014
#define TLV_UNICAST_MASTER_TABLE 0x2018
#define TLV_UNICAST_MASTER_MAX_TABLE_SIZE 0x2019
#define TLV_ACCEPTABLE_MASTER_TABLE_ENABLED 0x201B
#define TLV_ALTERNATE_MASTER 0x201D
#define TLV_TRANSPARENT_CLOCK_PORT_DATA_SET 0x4001
#define TLV_DELAY_MECHANISM 0x6000
#define TLV_LOG_MIN_PDELAY_REQ_INTERVAL 0x6001
#define TLV_PORT_DATA_SET_NP 0xC002
#define TLV_PORT_PROPERTIES_NP 0xC004
/* Management error ID values */
#define RESPONSE_TOO_BIG 0x0001
#define NO_SUCH_ID 0x0002
#define WRONG_LENGTH 0x0003
#define WRONG_VALUE 0x0004
#define NOT_SETABLE 0x0005
#define NOT_SUPPORTED 0x0006
#define GENERAL_ERROR 0xFFFE
#define TLV_RESPONSE_TOO_BIG 0x0001
#define TLV_NO_SUCH_ID 0x0002
#define TLV_WRONG_LENGTH 0x0003
#define TLV_WRONG_VALUE 0x0004
#define TLV_NOT_SETABLE 0x0005
#define TLV_NOT_SUPPORTED 0x0006
#define TLV_GENERAL_ERROR 0xFFFE
struct management_tlv {
Enumeration16 type;