#include "addrtoname.h"
#include "extract.h"
#include "oui.h"
+#include "ntp.h"
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
{ 0, NULL }
};
+static const struct tok blpr_bm[] = {
+ { 0x0001, "MBZ-15" },
+ { 0x0002, "MBZ-14" },
+ { 0x0004, "MBZ-13" },
+ { 0x0008, "MBZ-12" },
+ { 0x0010, "MBZ-11" },
+ { 0x0020, "MBZ-10" },
+ { 0x0040, "MBZ-9" },
+ { 0x0080, "MBZ-8" },
+ { 0x0100, "MBZ-7" },
+ { 0x0200, "MBZ-6" },
+ { 0x0400, "MBZ-5" },
+ { 0x0800, "MBZ-4" },
+ { 0x1000, "MBZ-3" },
+ { 0x2000, "MBZ-2" },
+ { 0x4000, "MBZ-1" },
+ { 0x8000, "Retransmission Allowed" },
+ { 0, NULL }
+ };
+
static const struct attrtype {
const char *name; /* Attribute name */
const char **subtypes; /* Standard Values (if any) */
print_attr_operator_name(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
- u_int i;
u_int namespace_value;
ND_TCHECK_LEN(data, length);
ND_PRINT("ERROR: length %u < 2", length);
return;
}
- namespace_value = EXTRACT_U_1(data);
+ namespace_value = GET_U_1(data);
data++;
- ND_PRINT("[%s] ", tok2str(operator_name_vector, "Namespace %u not known", namespace_value));
+ ND_PRINT("[%s] ", tok2str(operator_name_vector, "unknown namespace %u", namespace_value));
- for (i=0; i < length-1 && EXTRACT_U_1(data); i++, data++)
- ND_PRINT("%c", ND_ASCII_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
+ nd_printn(ndo, data, length - 1, NULL);
return;
print_attr_location_information(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
- u_int i;
- u_int16_t index;
- u_int8_t code, entity;
- u_int64_t sighting_time, time_to_live;
+ uint16_t index;
+ uint8_t code, entity;
ND_TCHECK_LEN(data, length);
if (length < 21)
return;
}
- index = EXTRACT_BE_U_2(data);
+ index = GET_BE_U_2(data);
data += 2;
- code = EXTRACT_U_1(data);
+ code = GET_U_1(data);
data++;
- entity = EXTRACT_U_1(data);
+ entity = GET_U_1(data);
data++;
- sighting_time = EXTRACT_BE_U_8(data);
- data += 8;
+ ND_PRINT("index %u, code %s, entity %s, ",
+ index,
+ tok2str(location_information_code_vector, "Unknown (%u)", code),
+ tok2str(location_information_entity_vector, "Unknown (%u)", entity)
+ );
- time_to_live = EXTRACT_BE_U_8(data);
+ ND_PRINT("sighting time ");
+ p_ntp_time(ndo, (const struct l_fixedpt *)data);
+ ND_PRINT(", ");
data += 8;
- ND_PRINT("Index %u, code %s, entity %s, sighting time %llu, time to live %llu: ",
- index,
- tok2str(location_information_code_vector, "Code %u not known", code),
- tok2str(location_information_entity_vector, "Entity %u not known", entity),
- sighting_time, // FIXME: NTP format, should share code from print-ntp.c?
- time_to_live // FIXME: NTP format, should share code from print-ntp.c?
- );
+ ND_PRINT("time to live ");
+ p_ntp_time(ndo, (const struct l_fixedpt *)data);
+ ND_PRINT(", ");
+ data += 8;
- for (i=0; i < length-20 && EXTRACT_U_1(data); i++, data++)
- ND_PRINT("%c", ND_ASCII_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
+ ND_PRINT("method \"");
+ nd_printn(ndo, data, length - 20, NULL);
+ ND_PRINT("\"");
return;
print_attr_location_data(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
- u_int i;
- u_int16_t index;
+ uint16_t index;
ND_TCHECK_LEN(data, length);
if (length < 3)
return;
}
- index = EXTRACT_BE_U_2(data);
+ index = GET_BE_U_2(data);
data += 2;
- ND_PRINT("Index %u: ", index);
-
- for (i=0; i < length-2 && EXTRACT_U_1(data); i++, data++)
- ND_PRINT("%c", ND_ASCII_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
+ ND_PRINT("index %u, location", index);
+
+ /* The Location field of the String field of the Location-Data attribute
+ * can have two completely different structures depending on the value of
+ * the Code field of a Location-Info attribute, which supposedly precedes
+ * the current attribute. Unfortunately, this choice of encoding makes it
+ * non-trivial to decode the Location field without preserving some state
+ * between the attributes.
+ */
+ hex_and_ascii_print(ndo, "\n\t ", data, length - 2);
return;
print_basic_location_policy_rules(netdissect_options *ndo,
const u_char *data, u_int length, u_short attr_code _U_)
{
- u_int i;
- u_int16_t flags;
- u_int64_t retention_expires;
+ uint16_t flags;
ND_TCHECK_LEN(data, length);
if (length < 10)
return;
}
- flags = EXTRACT_BE_U_2(data);
+ flags = GET_BE_U_2(data);
data += 2;
+ ND_PRINT("flags [%s], ", bittok2str(blpr_bm, "none", flags));
- retention_expires = EXTRACT_BE_U_8(data);
+ ND_PRINT("retention expires ");
+ p_ntp_time(ndo, (const struct l_fixedpt *)data);
data += 8;
- ND_PRINT("Flags: %s, retention expires %llu: ",
- flags & 0x8000 ? "Retransmission Allowed" : "none",
- retention_expires
- );
-
- for (i=0; i < length-10 && EXTRACT_U_1(data); i++, data++)
- ND_PRINT("%c", ND_ASCII_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
+ if (length > 10) {
+ ND_PRINT(", note well \"");
+ nd_printn(ndo, data, length - 10, NULL);
+ ND_PRINT("\"");
+ }
return;
Operator-Name Attribute (126), length: 18, Value: [REALM] namespace REALM
Operator-Name Attribute (126), length: 17, Value: [E212] namespace E212
Operator-Name Attribute (126), length: 16, Value: [ICC] namespace ICC
- Operator-Name Attribute (126), length: 20, Value: [Namespace 52 not known] namespace INVALID
- Location-Information Attribute (127), length: 25, Value: Index 1, code Civic, entity User, sighting time 81985529216486895, time to live 81985529216486895: GPS
- Location-Data Attribute (128), length: 15, Value: Index 1: my location
- Basic-Location-Policy-Rules Attribute (129), length: 17, Value: Flags: none, retention expires 81985529216486895: test1
- Basic-Location-Policy-Rules Attribute (129), length: 17, Value: Flags: Retransmission Allowed, retention expires 81985529216486895: test2
+ Operator-Name Attribute (126), length: 20, Value: [unknown namespace 52] namespace INVALID
+ Location-Information Attribute (127), length: 25, Value: index 1, code Civic, entity User, sighting time 19088743.537777777 (1900-08-09T22:25:43Z), time to live 19088743.537777777 (1900-08-09T22:25:43Z), method "GPS"
+ Location-Data Attribute (128), length: 15, Value: index 1, location
+ 0x0000: 6d79 206c 6f63 6174 696f 6e my.location
+ Basic-Location-Policy-Rules Attribute (129), length: 17, Value: flags [none], retention expires 19088743.537777777 (1900-08-09T22:25:43Z), note well "test1"
+ Basic-Location-Policy-Rules Attribute (129), length: 17, Value: flags [Retransmission Allowed], retention expires 19088743.537777777 (1900-08-09T22:25:43Z), note well "test2"