On Mon, Mar 24, 2014 at 09:53:29AM +0100, Jiri Benc wrote:
> Will be used by phc2sys to find out interfaces corresponding to ports.

This looks okay to me. Same nits as before...
 
> Signed-off-by: Jiri Benc <jb...@redhat.com>
> ---
>  clock.c |    9 +++++++++
>  port.c  |   16 ++++++++++++++++
>  tlv.c   |   20 ++++++++++++++++++++
>  tlv.h   |    8 ++++++++
>  4 files changed, 53 insertions(+), 0 deletions(-)
> 
> diff --git a/clock.c b/clock.c
> index 20fea847ef68..c893a58391ce 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -1012,6 +1012,15 @@ int clock_manage(struct clock *c, struct port *p, 
> struct ptp_message *msg)
>       }
>  
>       switch (mgt->id) {
> +     case PORT_PROPERTIES_NP:
> +             if (p != c->port[c->nports]) {
> +                     /* Only the UDS port allowed. */
> +                     clock_management_send_error(p, msg, NOT_SUPPORTED);
> +                     return 0;
> +             }
> +     }
> +
> +     switch (mgt->id) {
>       case USER_DESCRIPTION:
>       case SAVE_IN_NON_VOLATILE_STORAGE:
>       case RESET_NON_VOLATILE_STORAGE:
> diff --git a/port.c b/port.c
> index fa70571678b6..261237654828 100644
> --- a/port.c
> +++ b/port.c
> @@ -760,6 +760,22 @@ static int port_management_fill_response(struct port 
> *target,
>               datalen = sizeof(*pdsnp);
>               respond = 1;
>               break;
> +     case PORT_PROPERTIES_NP:
> +             {

No braces, here or below, please.

> +                     struct port_properties_np *ppn;
> +
> +                     ppn = (struct port_properties_np *)tlv->data;
> +                     ppn->portIdentity = target->portIdentity;
> +                     if (target->state == PS_GRAND_MASTER)
> +                             ppn->portState = PS_MASTER;
> +                     else
> +                             ppn->portState = target->state;
> +                     ppn->timestamping = target->timestamping;
> +                     ptp_text_set(&ppn->interface, target->name);
> +                     datalen = sizeof(*ppn) + ppn->interface.length;
> +                     respond = 1;
> +             }
> +             break;
>       }
>       if (respond) {
>               if (datalen % 2) {
> diff --git a/tlv.c b/tlv.c
> index 8d635c452905..35c9773498be 100644
> --- a/tlv.c
> +++ b/tlv.c
> @@ -270,6 +270,18 @@ static int mgt_post_recv(struct management_tlv *m, 
> uint16_t data_len,
>                               pen->portNumber[i] = ntohs(pen->portNumber[i]);
>               }
>               break;
> +     case PORT_PROPERTIES_NP:
> +             {
> +                     struct port_properties_np *ppn;
> +
> +                     if (data_len < sizeof(struct port_properties_np))
> +                             goto bad_length;
> +                     ppn = (struct port_properties_np *)m->data;
> +                     ppn->portIdentity.portNumber = 
> ntohs(ppn->portIdentity.portNumber);
> +                     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:
> @@ -384,6 +396,14 @@ static void mgt_pre_send(struct management_tlv *m, 
> struct tlv_extra *extra)
>                       pen->numberPorts = htons(pen->numberPorts);
>               }
>               break;
> +     case PORT_PROPERTIES_NP:
> +             {
> +                     struct port_properties_np *ppn;
> +
> +                     ppn = (struct port_properties_np *)m->data;
> +                     ppn->portIdentity.portNumber = 
> htons(ppn->portIdentity.portNumber);
> +             }
> +             break;
>       }
>  }
>  
> diff --git a/tlv.h b/tlv.h
> index dffdabda7d09..4d2f3f41562a 100644
> --- a/tlv.h
> +++ b/tlv.h
> @@ -101,6 +101,7 @@ enum management_action {
>  #define DELAY_MECHANISM                                      0x6000
>  #define LOG_MIN_PDELAY_REQ_INTERVAL                  0x6001
>  #define PORT_DATA_SET_NP                                     0xC002
> +#define PORT_PROPERTIES_NP                           0xC005
>  
>  /* Management error ID values */
>  #define RESPONSE_TOO_BIG                             0x0001
> @@ -207,6 +208,13 @@ struct port_enumeration_np {
>       UInteger16 portNumber[0];
>  } PACKED;
>  
> +struct port_properties_np {
> +     struct PortIdentity portIdentity;
> +     Enumeration8 portState;
> +     Enumeration8 timestamping;

Use stdint type please.

> +     struct PTPText interface;
> +} PACKED;
> +

Thanks,
Richard

------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to