X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/546558eabd81cfc36a81a4df728fdfea0d83b41a..0f24a43a7e9fbdcff2baae3990939b2bc25d9fd1:/print-radius.c diff --git a/print-radius.c b/print-radius.c index 62f61f0c..c723fd5a 100644 --- a/print-radius.c +++ b/print-radius.c @@ -65,9 +65,15 @@ * RFC 5176: * "Dynamic Authorization Extensions to RADIUS" * + * RFC 5447: + * "Diameter Mobile IPv6" + * * RFC 5580: * "Carrying Location Objects in RADIUS and Diameter" * + * RFC 6572: + * "RADIUS Support for Proxy Mobile IPv6" + * * RFC 7155: * "Diameter Network Access Server Application" * @@ -89,7 +95,6 @@ #include "extract.h" #include "oui.h" -static const char tstr[] = " [|radius]"; #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) ) @@ -197,7 +202,9 @@ static void print_vendor_attr(netdissect_options *, const u_char *, u_int, u_sho static void print_attr_address(netdissect_options *, const u_char *, u_int, u_short); static void print_attr_address6(netdissect_options *, const u_char *, u_int, u_short); static void print_attr_netmask6(netdissect_options *, const u_char *, u_int, u_short); +static void print_attr_mip6_home_link_prefix(netdissect_options *, const u_char *, u_int, u_short); static void print_attr_time(netdissect_options *, const u_char *, u_int, u_short); +static void print_attr_vector64(netdissect_options *, register const u_char *, u_int, u_short); static void print_attr_strange(netdissect_options *, const u_char *, u_int, u_short); @@ -437,8 +444,40 @@ static const struct tok errorcausetype[] = { { 0, NULL } }; +/* MIP6-Feature-Vector standard values */ +/* https://www.iana.org/assignments/aaa-parameters/aaa-parameters.xhtml */ +#define MIP6_INTEGRATED 0x0000000000000001 +#define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002 +#define PMIP6_SUPPORTED 0x0000010000000000 +#define IP4_HOA_SUPPORTED 0x0000020000000000 +#define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000 +#define ASSIGN_LOCAL_IP 0x0000080000000000 +#define MIP4_SUPPORTED 0x0000100000000000 +#define OPTIMIZED_IDLE_MODE_MOBILITY 0x0000200000000000 +#define GTPv2_SUPPORTED 0x0000400000000000 +#define IP4_TRANSPORT_SUPPORTED 0x0000800000000000 +#define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000 +#define INTER_MAG_ROUTING_SUPPORTED 0x0002000000000000 +static const struct mip6_feature_vector { + uint64_t v; + const char *s; + } mip6_feature_vector[] = { + { MIP6_INTEGRATED, "MIP6_INTEGRATED" }, + { LOCAL_HOME_AGENT_ASSIGNMENT, "LOCAL_HOME_AGENT_ASSIGNMENT" }, + { PMIP6_SUPPORTED, "PMIP6_SUPPORTED" }, + { IP4_HOA_SUPPORTED, "IP4_HOA_SUPPORTED" }, + { LOCAL_MAG_ROUTING_SUPPORTED, "LOCAL_MAG_ROUTING_SUPPORTED" }, + { ASSIGN_LOCAL_IP, "ASSIGN_LOCAL_IP" }, + { MIP4_SUPPORTED, "MIP4_SUPPORTED" }, + { OPTIMIZED_IDLE_MODE_MOBILITY, "OPTIMIZED_IDLE_MODE_MOBILITY" }, + { GTPv2_SUPPORTED, "GTPv2_SUPPORTED" }, + { IP4_TRANSPORT_SUPPORTED, "IP4_TRANSPORT_SUPPORTED" }, + { IP4_HOA_ONLY_SUPPORTED, "IP4_HOA_ONLY_SUPPORTED" }, + { INTER_MAG_ROUTING_SUPPORTED, "INTER_MAG_ROUTING_SUPPORTED" }, + }; + -static struct attrtype { +static const struct attrtype { const char *name; /* Attribute name */ const char **subtypes; /* Standard Values (if any) */ u_char siz_subtypes; /* Size of total standard values */ @@ -570,6 +609,8 @@ static struct attrtype { { "Digest-HA1", NULL, 0, 0, print_attr_string }, { "SIP-AOR", NULL, 0, 0, print_attr_string }, { "Delegated-IPv6-Prefix", NULL, 0, 0, print_attr_netmask6 }, + { "MIP6-Feature-Vector", NULL, 0, 0, print_attr_vector64 }, + { "MIP6-Home-Link-Prefix", NULL, 0, 0, print_attr_mip6_home_link_prefix }, }; @@ -638,7 +679,7 @@ print_attr_string(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } /* @@ -699,7 +740,7 @@ print_vendor_attr(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } /******************************/ @@ -822,7 +863,7 @@ print_attr_num(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } /*****************************/ @@ -865,7 +906,7 @@ print_attr_address(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } /*****************************/ @@ -892,7 +933,7 @@ print_attr_address6(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -925,7 +966,31 @@ print_attr_netmask6(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); +} + +static void +print_attr_mip6_home_link_prefix(netdissect_options *ndo, + const u_char *data, u_int length, u_short attr_code _U_) +{ + if (length != 17) + { + ND_PRINT("ERROR: length %u != 17", length); + return; + } + ND_TCHECK_LEN(data, length); + if (EXTRACT_U_1(data) > 128) + { + ND_PRINT("ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data)); + return; + } + + ND_PRINT("%s/%u", ip6addr_string(ndo, data + 1), EXTRACT_U_1(data)); + + return; + + trunc: + nd_print_trunc(ndo); } /*************************************/ @@ -959,7 +1024,43 @@ print_attr_time(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); +} + +static void +print_attr_vector64(netdissect_options *ndo, + register const u_char *data, u_int length, u_short attr_code _U_) +{ + uint64_t data_value, i; + const char *sep = ""; + + if (length != 8) + { + ND_PRINT("ERROR: length %u != 8", length); + return; + } + + ND_PRINT("["); + ND_TCHECK_8(data[0]); + + data_value = EXTRACT_BE_U_8(data); + /* Print the 64-bit field in a format similar to bittok2str(), less + * flagging any unknown bits. This way it should be easier to replace + * the custom code with a library function later. + */ + for (i = 0; i < TAM_SIZE(mip6_feature_vector); i++) { + if (data_value & mip6_feature_vector[i].v) { + ND_PRINT("%s%s", sep, mip6_feature_vector[i].s); + sep = ", "; + } + } + + ND_PRINT("]"); + + return; + + trunc: + nd_print_trunc(ndo); } /***********************************/ @@ -1050,7 +1151,7 @@ print_attr_strange(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -1073,26 +1174,22 @@ radius_attrs_print(netdissect_options *ndo, attr_string = attr_type[type].name; else attr_string = "Unknown"; - if (len < 2) - { - ND_PRINT("\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)", + + ND_PRINT("\n\t %s Attribute (%u), length: %u", attr_string, type, len); - return; + if (len < 2) + { + ND_PRINT(" (bogus, must be >= 2)"); + return; } if (len > length) { - ND_PRINT("\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)", - attr_string, - type, - len); + ND_PRINT(" (bogus, goes past end of packet)"); return; } - ND_PRINT("\n\t %s Attribute (%u), length: %u, Value: ", - attr_string, - type, - len); + ND_PRINT(", Value: "); if (type < TAM_SIZE(attr_type)) { @@ -1114,7 +1211,7 @@ radius_attrs_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } void @@ -1131,7 +1228,7 @@ radius_print(netdissect_options *ndo, if (len < MIN_RADIUS_LEN) { - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); return; } @@ -1162,5 +1259,5 @@ radius_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); }