From d308df8e27ab32a422ef5950914b3b50ff9a8d45 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 29 Jul 2012 09:13:37 +0200 Subject: [PATCH] Convert the management error status TLV to and from host byte order. Signed-off-by: Richard Cochran --- tlv.c | 10 ++++++++++ tlv.h | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tlv.c b/tlv.c index 34a124b..0cf9764 100644 --- a/tlv.c +++ b/tlv.c @@ -23,6 +23,7 @@ void tlv_post_recv(struct TLV *tlv) { struct management_tlv *mgt; + struct management_error_status *mes; switch (tlv->type) { case TLV_MANAGEMENT: @@ -30,6 +31,10 @@ void tlv_post_recv(struct TLV *tlv) mgt->id = ntohs(mgt->id); break; case TLV_MANAGEMENT_ERROR_STATUS: + mes = (struct management_error_status *) tlv; + mes->error = ntohs(mes->error); + mes->id = ntohs(mes->id); + break; case TLV_ORGANIZATION_EXTENSION: case TLV_REQUEST_UNICAST_TRANSMISSION: case TLV_GRANT_UNICAST_TRANSMISSION: @@ -49,6 +54,7 @@ void tlv_post_recv(struct TLV *tlv) void tlv_pre_send(struct TLV *tlv) { struct management_tlv *mgt; + struct management_error_status *mes; switch (tlv->type) { case TLV_MANAGEMENT: @@ -56,6 +62,10 @@ void tlv_pre_send(struct TLV *tlv) mgt->id = htons(mgt->id); break; case TLV_MANAGEMENT_ERROR_STATUS: + mes = (struct management_error_status *) tlv; + mes->error = htons(mes->error); + mes->id = htons(mes->id); + break; case TLV_ORGANIZATION_EXTENSION: case TLV_REQUEST_UNICAST_TRANSMISSION: case TLV_GRANT_UNICAST_TRANSMISSION: diff --git a/tlv.h b/tlv.h index b8d0c09..b34679a 100644 --- a/tlv.h +++ b/tlv.h @@ -96,6 +96,15 @@ enum management_action { #define DELAY_MECHANISM 0x6000 #define LOG_MIN_PDELAY_REQ_INTERVAL 0x6001 +/* 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 + struct management_tlv { Enumeration16 type; UInteger16 length; @@ -103,6 +112,15 @@ struct management_tlv { Octet data[0]; } PACKED; +struct management_error_status { + Enumeration16 type; + UInteger16 length; + Enumeration16 error; + Enumeration16 id; + Octet reserved[4]; + Octet data[0]; +} PACKED; + /** * Converts recognized value sub-fields into host byte order. * @param tlv Pointer to a Type Length Value field.