diff options
-rw-r--r-- | asn1/snmp/packet-snmp-template.c | 94 | ||||
-rw-r--r-- | epan/dissectors/packet-snmp.c | 100 | ||||
-rw-r--r-- | epan/oids.c | 3 | ||||
-rw-r--r-- | epan/oids.h | 3 |
4 files changed, 191 insertions, 9 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index 240c63bdc2..e7a2fa6976 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -365,6 +365,91 @@ dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * } /* +DateAndTime ::= TEXTUAL-CONVENTION + DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d" + STATUS current + DESCRIPTION + "A date-time specification. + + field octets contents range + ----- ------ -------- ----- + 1 1-2 year* 0..65536 + 2 3 month 1..12 + 3 4 day 1..31 + 4 5 hour 0..23 + 5 6 minutes 0..59 + 6 7 seconds 0..60 + (use 60 for leap-second) + 7 8 deci-seconds 0..9 + 8 9 direction from UTC '+' / '-' + 9 10 hours from UTC* 0..13 + 10 11 minutes from UTC 0..59 + + * Notes: + - the value of year is in network-byte order + - daylight saving time in New Zealand is +13 + + For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be + displayed as: + + 1992-5-26,13:30:15.0,-4:0 + + Note that if only local time is known, then timezone + information (fields 8-10) is not present." + SYNTAX OCTET STRING (SIZE (8 | 11)) + */ +static proto_item * +dissect_snmp_variable_date_and_time(proto_tree *tree,int hfid, tvbuff_t *tvb, int offset, int length) +{ + guint16 year; + guint8 month; + guint8 day; + guint8 hour; + guint8 minutes; + guint8 seconds; + guint8 deci_seconds; + guint8 hour_from_utc; + guint8 min_from_utc; + gchar *str; + + year = tvb_get_ntohs(tvb,offset); + month = tvb_get_guint8(tvb,offset+2); + day = tvb_get_guint8(tvb,offset+3); + hour = tvb_get_guint8(tvb,offset+4); + minutes = tvb_get_guint8(tvb,offset+5); + seconds = tvb_get_guint8(tvb,offset+6); + deci_seconds = tvb_get_guint8(tvb,offset+7); + if(length > 8){ + hour_from_utc = tvb_get_guint8(tvb,offset+9); + min_from_utc = tvb_get_guint8(tvb,offset+10); + + str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds, + tvb_get_ephemeral_string(tvb,offset+8,1), + hour_from_utc, + min_from_utc); + }else{ + str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds); + } + + return proto_tree_add_string(tree, hfid, tvb, offset, length, str); + +} + +/* * dissect_snmp_VarBind * this routine dissects variable bindings, looking for the oid information in our oid reporsitory * to format and add the value adequatelly. @@ -835,7 +920,7 @@ indexing_done: goto already_added; } case BER_CLASS_UNI|(BER_UNI_TAG_OCTETSTRING<<4): - if((oid_info->value_hfid> -1)&& (oid_info->value_type->keytype == OID_KEY_TYPE_STRING)){ + if(oid_info->value_hfid> -1){ hfid = oid_info->value_hfid; }else{ hfid = hf_snmp_octetstring_value; @@ -926,7 +1011,12 @@ indexing_done: goto already_added; } } - pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); + /* Special case DATE AND TIME */ + if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){ + pi_value = dissect_snmp_variable_date_and_time(pt_varbind, hfid, tvb, value_offset, value_len); + }else{ + pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); + } if (format_error != BER_NO_ERROR) { expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib); } diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index d7546bbcd1..ff659d9bfd 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -467,6 +467,91 @@ dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * } /* +DateAndTime ::= TEXTUAL-CONVENTION + DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d" + STATUS current + DESCRIPTION + "A date-time specification. + + field octets contents range + ----- ------ -------- ----- + 1 1-2 year* 0..65536 + 2 3 month 1..12 + 3 4 day 1..31 + 4 5 hour 0..23 + 5 6 minutes 0..59 + 6 7 seconds 0..60 + (use 60 for leap-second) + 7 8 deci-seconds 0..9 + 8 9 direction from UTC '+' / '-' + 9 10 hours from UTC* 0..13 + 10 11 minutes from UTC 0..59 + + * Notes: + - the value of year is in network-byte order + - daylight saving time in New Zealand is +13 + + For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be + displayed as: + + 1992-5-26,13:30:15.0,-4:0 + + Note that if only local time is known, then timezone + information (fields 8-10) is not present." + SYNTAX OCTET STRING (SIZE (8 | 11)) + */ +static proto_item * +dissect_snmp_variable_date_and_time(proto_tree *tree,int hfid, tvbuff_t *tvb, int offset, int length) +{ + guint16 year; + guint8 month; + guint8 day; + guint8 hour; + guint8 minutes; + guint8 seconds; + guint8 deci_seconds; + guint8 hour_from_utc; + guint8 min_from_utc; + gchar *str; + + year = tvb_get_ntohs(tvb,offset); + month = tvb_get_guint8(tvb,offset+2); + day = tvb_get_guint8(tvb,offset+3); + hour = tvb_get_guint8(tvb,offset+4); + minutes = tvb_get_guint8(tvb,offset+5); + seconds = tvb_get_guint8(tvb,offset+6); + deci_seconds = tvb_get_guint8(tvb,offset+7); + if(length > 8){ + hour_from_utc = tvb_get_guint8(tvb,offset+9); + min_from_utc = tvb_get_guint8(tvb,offset+10); + + str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds, + tvb_get_ephemeral_string(tvb,offset+8,1), + hour_from_utc, + min_from_utc); + }else{ + str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u", + year, + month, + day, + hour, + minutes, + seconds, + deci_seconds); + } + + return proto_tree_add_string(tree, hfid, tvb, offset, length, str); + +} + +/* * dissect_snmp_VarBind * this routine dissects variable bindings, looking for the oid information in our oid reporsitory * to format and add the value adequatelly. @@ -937,7 +1022,7 @@ indexing_done: goto already_added; } case BER_CLASS_UNI|(BER_UNI_TAG_OCTETSTRING<<4): - if((oid_info->value_hfid> -1)&& (oid_info->value_type->keytype == OID_KEY_TYPE_STRING)){ + if(oid_info->value_hfid> -1){ hfid = oid_info->value_hfid; }else{ hfid = hf_snmp_octetstring_value; @@ -1028,7 +1113,12 @@ indexing_done: goto already_added; } } - pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); + /* Special case DATE AND TIME */ + if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){ + pi_value = dissect_snmp_variable_date_and_time(pt_varbind, hfid, tvb, value_offset, value_len); + }else{ + pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN); + } if (format_error != BER_NO_ERROR) { expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib); } @@ -2894,7 +2984,7 @@ static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pro /*--- End of included file: packet-snmp-fn.c ---*/ -#line 1678 "../../asn1/snmp/packet-snmp-template.c" +#line 1768 "../../asn1/snmp/packet-snmp-template.c" guint @@ -3820,7 +3910,7 @@ void proto_register_snmp(void) { NULL, HFILL }}, /*--- End of included file: packet-snmp-hfarr.c ---*/ -#line 2339 "../../asn1/snmp/packet-snmp-template.c" +#line 2429 "../../asn1/snmp/packet-snmp-template.c" }; /* List of subtrees */ @@ -3860,7 +3950,7 @@ void proto_register_snmp(void) { &ett_snmp_RReqPDU_U, /*--- End of included file: packet-snmp-ettarr.c ---*/ -#line 2355 "../../asn1/snmp/packet-snmp-template.c" +#line 2445 "../../asn1/snmp/packet-snmp-template.c" }; static ei_register_info ei[] = { { &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED, PI_WARN, "Failed to decrypt encryptedPDU", EXPFILL }}, diff --git a/epan/oids.c b/epan/oids.c index a65fe6ad6b..c93370e884 100644 --- a/epan/oids.c +++ b/epan/oids.c @@ -81,6 +81,7 @@ static const oid_value_type_t float_type = { FT_FLOAT, BASE_DEC, BER_CLAS static const oid_value_type_t double_type = { FT_DOUBLE, BASE_DEC, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, 8, 8, OID_KEY_TYPE_WRONG, 0}; static const oid_value_type_t ether_type = { FT_ETHER, BASE_NONE, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, 6, 6, OID_KEY_TYPE_ETHER, 6}; static const oid_value_type_t string_type = { FT_STRING, BASE_NONE, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, 0, -1, OID_KEY_TYPE_STRING, 0}; +static const oid_value_type_t date_and_time_type = { FT_STRING, BASE_NONE, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, 8, 11, OID_KEY_TYPE_DATE_AND_TIME, 0}; static const oid_value_type_t unknown_type = { FT_BYTES, BASE_NONE, BER_CLASS_ANY, BER_TAG_ANY, 0, -1, OID_KEY_TYPE_WRONG, 0}; static oid_info_t oid_root = { 0, NULL, OID_KIND_UNKNOWN, NULL, &unknown_type, -2, NULL, NULL, NULL}; @@ -304,7 +305,7 @@ static const oid_value_type_t* get_typedata(SmiType* smiType) { {"TimeStamp",SMI_BASETYPE_UNKNOWN,&timeticks_type}, {"DisplayString",SMI_BASETYPE_UNKNOWN,&string_type}, {"SnmpAdminString",SMI_BASETYPE_UNKNOWN,&string_type}, - {"DateAndTime",SMI_BASETYPE_UNKNOWN,&bytes_type}, + {"DateAndTime",SMI_BASETYPE_UNKNOWN,&date_and_time_type}, {"Counter",SMI_BASETYPE_UNKNOWN,&counter32_type}, {"Counter32",SMI_BASETYPE_UNKNOWN,&counter32_type}, {"Unsigned32",SMI_BASETYPE_UNKNOWN,&unsigned32_type}, diff --git a/epan/oids.h b/epan/oids.h index 7d802ce8cd..34a4f543cb 100644 --- a/epan/oids.h +++ b/epan/oids.h @@ -58,7 +58,8 @@ typedef enum _oid_key_type_t { OID_KEY_TYPE_IMPLIED_OID, OID_KEY_TYPE_IMPLIED_STRING, OID_KEY_TYPE_IMPLIED_BYTES, - OID_KEY_TYPE_ETHER + OID_KEY_TYPE_ETHER, + OID_KEY_TYPE_DATE_AND_TIME } oid_key_type_t; typedef struct _oid_value_type_t { |