/* * netsniff-ng - the packet sniffing beast * Copyright 2012 Markus Amend , Deutsche Flugsicherung GmbH * Subject to the GPL, version 2. * * IPv6 Mobility Header described in RFC6275 */ #include #include #include #include /* for ntohs() */ #include #include "proto.h" #include "dissector_eth.h" #include "built_in.h" #include "pkt_buff.h" #define BINDING_REFRESH_REQUEST_MESSAGE 0x00 #define HOME_TEST_INIT_MESSAGE 0x01 #define CARE_OF_TEST_INIT_MESSAGE 0x02 #define HOME_TEST_MESSAGE 0x03 #define CARE_OF_TEST_MESSAGE 0x04 #define BINDING_UPDATE_MESSAGE 0x05 #define BINDING_ACKNOWLEDGEMENT_MESSAGE 0x06 #define BINDING_ERROR_MESSAGE 0x07 struct mobilityhdr { uint8_t payload_proto; uint8_t hdr_len; uint8_t MH_type; uint8_t reserved; uint16_t chksum; uint8_t msgdata[0]; } __packed; struct bin_refr_req_msg { uint16_t reserved; uint8_t mobility_opt[0]; } __packed; /* for 0x01 and 0x02 */ struct tst_init_msg { uint16_t reserved; uint64_t init_cookie; uint8_t mobility_opt[0]; } __packed; /* for 0x03 and 0x04 */ struct tst_msg { uint16_t nonce_index; uint64_t init_cookie; uint64_t keygen_token; uint8_t mobility_opt[0]; } __packed; struct bind_upd_msg { uint16_t sequence; uint16_t ahlk_res; uint16_t lifetime; uint8_t mobility_opt[0]; } __packed; struct bind_ack_msg { uint8_t status; uint8_t k_res; uint16_t sequence; uint16_t lifetime; uint8_t mobility_opt[0]; } __packed; struct bind_err_msg { uint8_t status; uint8_t res; uint64_t home_addr; uint8_t mobility_opt[0]; } __packed; static void dissect_mobility_options(struct pkt_buff *pkt __maybe_unused, ssize_t *message_data_len) { /* Have to been upgraded. * http://tools.ietf.org/html/rfc6275#section-6.2.1 */ if (*message_data_len) tprintf("MH Option(s) recognized "); /* If adding dissector reduce message_data_len for each using of * pkt_pull to the same size. */ } static void dissect_mobilityhdr_type_0(struct pkt_buff *pkt, ssize_t *message_data_len) { struct bin_refr_req_msg *type_0; type_0 = (struct bin_refr_req_msg *) pkt_pull(pkt, sizeof(*type_0)); *message_data_len -= sizeof(*type_0); if (type_0 == NULL || *message_data_len > pkt_len(pkt) || *message_data_len < 0) return; dissect_mobility_options(pkt, message_data_len); } static void dissect_mobilityhdr_type_1_2(struct pkt_buff *pkt, ssize_t *message_data_len) { struct tst_init_msg *type_1_2; type_1_2 = (struct tst_init_msg *) pkt_pull(pkt, sizeof(*type_1_2)); *message_data_len -= sizeof(*type_1_2); if (type_1_2 == NULL || *message_data_len > pkt_len(pkt) || *message_data_len < 0) return; tprintf("Init Cookie (0x%"PRIx64")", ntohll(type_1_2->init_cookie)); dissect_mobility_options(pkt, message_data_len); } static void dissect_mobilityhdr_type_3_4(struct pkt_buff *pkt, ssize_t *message_data_len) { struct tst_msg *type_3_4; type_3_4 = (struct tst_msg *) pkt_pull(pkt, sizeof(*type_3_4)); *message_data_len -= sizeof(*type_3_4); if (type_3_4 == NULL || *message_data_len > pkt_len(pkt) || *message_data_len < 0) return; tprintf("HN Index (%u) ", ntohs(type_3_4->nonce_index)); tprintf("Init Cookie (0x%"PRIx64") ", ntohll(type_3_4->init_cookie)); tprintf("Keygen Token (0x%"PRIx64")", ntohll(type_3_4->keygen_token)); dissect_mobility_options(pkt, message_data_len); } static void dissect_mobilityhdr_type_5(struct pkt_buff *pkt, ssize_t *message_data_len) { struct bind_upd_msg *type_5; type_5 = (struct bind_upd_msg *) pkt_pull(pkt, sizeof(*type_5)); *message_data_len -= sizeof(*type_5); if (type_5 == NULL || *message_data_len > pkt_len(pkt) || *message_data_len < 0) return; tprintf("Sequence (0x%x) ", ntohs(type_5->sequence)); tprintf("A|H|L|K (0x%x) ", ntohs(type_5->ahlk_res) >> 12); tprintf("Lifetime (%us)", ntohs(type_5->lifetime) * 4); dissect_mobility_options(pkt, message_data_len); } static void dissect_mobilityhdr_type_6(struct pkt_buff *pkt, ssize_t *message_data_len) { struct bind_ack_msg *type_6; type_6 = (struct bind_ack_msg *) pkt_pull(pkt, sizeof(*type_6)); if (type_6 == NULL) return; *message_data_len -= sizeof(*type_6); if (*message_data_len > pkt_len(pkt) || *message_data_len < 0) return; tprintf("Status (0x%x) ", type_6->status); tprintf("K (%u) ", type_6->k_res >> 7); tprintf("Sequence (0x%x)", ntohs(type_6->sequence)); tprintf("Lifetime (%us)", ntohs(type_6->lifetime) * 4); dissect_mobility_options(pkt, message_data_len); } static void dissect_mobilityhdr_type_7(struct pkt_buff *pkt, ssize_t *message_data_len) { char address[INET6_ADDRSTRLEN]; uint64_t addr; struct bind_err_msg *type_7; type_7 = (struct bind_err_msg *) pkt_pull(pkt, sizeof(*type_7)); if (type_7 == NULL) return; *message_data_len -= sizeof(*type_7); addr = ntohll(type_7->home_addr); if (*message_data_len > pkt_len(pkt) || *message_data_len < 0) return; tprintf("Status (0x%x) ", type_7->status); tprintf("Home Addr (%s)", inet_ntop(AF_INET6, &addr, address, sizeof(address))); dissect_mobility_options(pkt, message_data_len); } static void get_mh_type(struct pkt_buff *pkt, ssize_t *message_data_len, uint8_t *mh_type) { switch (*mh_type) { case BINDING_REFRESH_REQUEST_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_0(pkt, message_data_len); break; case HOME_TEST_INIT_MESSAGE: tprintf("Home Test Init Message "); dissect_mobilityhdr_type_1_2(pkt, message_data_len); break; case CARE_OF_TEST_INIT_MESSAGE: tprintf("Care-of Test Init Message "); dissect_mobilityhdr_type_1_2(pkt, message_data_len); break; case HOME_TEST_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_3_4(pkt, message_data_len); break; case CARE_OF_TEST_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_3_4(pkt, message_data_len); break; case BINDING_UPDATE_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_5(pkt, message_data_len); break; case BINDING_ACKNOWLEDGEMENT_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_6(pkt, message_data_len); break; case BINDING_ERROR_MESSAGE: tprintf("Binding Refresh Request Message "); dissect_mobilityhdr_type_7(pkt, message_data_len); break; default: tprintf("Type %u is unknown. Error", *mh_type); } } static void mobility(struct pkt_buff *pkt) { uint16_t hdr_ext_len; ssize_t message_data_len; struct mobilityhdr *mobility; mobility = (struct mobilityhdr *) pkt_pull(pkt, sizeof(*mobility)); if (mobility == NULL) return; /* Total Header Length in Bytes */ hdr_ext_len = (mobility->hdr_len + 1) * 8; /* Total Message Data length in Bytes*/ message_data_len = (hdr_ext_len - sizeof(*mobility)); tprintf("\t [ Mobility "); tprintf("NextHdr (%u), ", mobility->payload_proto); if (message_data_len > pkt_len(pkt) || message_data_len < 0){ tprintf("HdrExtLen (%u, %u Bytes %s), ", mobility->hdr_len, hdr_ext_len, colorize_start_full(black, red) "invalid" colorize_end()); return; } tprintf("HdrExtLen (%u, %u Bytes), ", mobility->hdr_len, hdr_ext_len); tprintf("MH Type (%u), ", mobility->MH_type); tprintf("Res (0x%x), ", mobility->reserved); tprintf("Chks (0x%x), ", ntohs(mobility->chksum)); tprintf("MH Data "); get_mh_type(pkt, &message_data_len, &mobility->MH_type); tprintf(" ]\n"); if (message_data_len > pkt_len(pkt) || message_data_len < 0) return; pkt_pull(pkt, message_data_len); pkt_set_dissector(pkt, ð_lay3, mobility->payload_proto); } static void mobility_less(struct pkt_buff *pkt) { uint16_t hdr_ext_len; ssize_t message_data_len; struct mobilityhdr *mobility; mobility = (struct mobilityhdr *) pkt_pull(pkt, sizeof(*mobility)); if (mobility == NULL) return; /* Total Header Length in Bytes */ hdr_ext_len = (mobility->hdr_len + 1) * 8; /* Total Message Data length in Bytes*/ message_data_len = (hdr_ext_len - sizeof(*mobility)); if (message_data_len > pkt_len(pkt) || message_data_len < 0) return; tprintf(" Mobility Type (%u), ", mobility->MH_type); pkt_pull(pkt, message_data_len); pkt_set_dissector(pkt, ð_lay3, mobility->payload_proto); } struct protocol ipv6_mobility_ops = { .key = 0x87, .print_full = mobility, .print_less = mobility_less, }; on' href='/cgit.cgi/linux/net-next.git/plain/include/dt-bindings/clock/bcm21664.h?h=nds-private-remove&id=e8fe4f4b2b7b93048729538321c681c0cff33b39'>plain -rw-r--r--bcm281xx.h2456logplain -rw-r--r--bcm2835-aux.h635logplain -rw-r--r--bcm2835.h1962logplain -rw-r--r--berlin2.h1034logplain -rw-r--r--berlin2q.h695logplain -rw-r--r--clps711x-clock.h718logplain -rw-r--r--efm32-cmu.h1112logplain -rw-r--r--exynos-audss-clk.h597logplain -rw-r--r--exynos3250.h9083logplain -rw-r--r--exynos4.h8284logplain -rw-r--r--exynos4415.h9828logplain -rw-r--r--exynos5250.h4616logplain -rw-r--r--exynos5260-clk.h14876logplain -rw-r--r--exynos5410.h1689logplain -rw-r--r--exynos5420.h6857logplain -rw-r--r--exynos5433.h45372logplain -rw-r--r--exynos5440.h1141logplain -rw-r--r--exynos7-clk.h5281logplain -rw-r--r--gxbb-aoclkc.h2866logplain -rw-r--r--gxbb-clkc.h592logplain -rw-r--r--hi3516cv300-clock.h1668logplain -rw-r--r--hi3519-clock.h1328logplain -rw-r--r--hi3620-clock.h4496logplain -rw-r--r--hi6220-clock.h4508logplain -rw-r--r--hip04-clock.h1137logplain -rw-r--r--histb-clock.h2012logplain -rw-r--r--hix5hd2-clock.h2415logplain -rw-r--r--imx1-clock.h1055logplain -rw-r--r--imx21-clock.h2461logplain -rw-r--r--imx27-clock.h3494logplain -rw-r--r--imx5-clock.h7212logplain -rw-r--r--imx6qdl-clock.h9593logplain -rw-r--r--imx6sl-clock.h5849logplain -rw-r--r--imx6sx-clock.h9099logplain -rw-r--r--imx6ul-clock.h8203logplain -rw-r--r--imx7d-clock.h15974logplain -rw-r--r--jz4740-cgu.h1028logplain -rw-r--r--jz4780-cgu.h2470logplain -rw-r--r--lpc18xx-ccu.h2134logplain -rw-r--r--lpc18xx-cgu.h1142logplain -rw-r--r--lpc32xx-clock.h1633logplain -rw-r--r--lsi,axm5516-clks.h974logplain -rw-r--r--marvell,mmp2.h2022logplain -rw-r--r--marvell,pxa168.h1654logplain -rw-r--r--marvell,pxa1928.h1535logplain -rw-r--r--marvell,pxa910.h1598logplain -rw-r--r--maxim,max77620.h632logplain -rw-r--r--maxim,max77686.h648logplain -rw-r--r--maxim,max77802.h630logplain -rw-r--r--meson8b-clkc.h523logplain -rw-r--r--microchip,pic32-clock.h1150logplain -rw-r--r--mpc512x-clock.h2236logplain -rw-r--r--mt2701-clk.h13832logplain -rw-r--r--mt8135-clk.h5641logplain -rw-r--r--mt8173-clk.h9293logplain -rw-r--r--oxsemi,ox810se.h1002logplain -rw-r--r--oxsemi,ox820.h1203logplain -rw-r--r--pistachio-clk.h4863logplain -rw-r--r--pxa-clock.h1715logplain -rw-r--r--qcom,gcc-apq8084.h12872logplain -rw-r--r--qcom,gcc-ipq4019.h5423logplain -rw-r--r--qcom,gcc-ipq806x.h8574logplain -rw-r--r--qcom,gcc-mdm9615.h9497logplain -rw-r--r--qcom,gcc-msm8660.h7932logplain -rw-r--r--qcom,gcc-msm8916.h6190logplain -rw-r--r--qcom,gcc-msm8960.h9342logplain -rw-r--r--qcom,gcc-msm8974.h12340logplain -rw-r--r--qcom,gcc-msm8994.h4858logplain -rw-r--r--qcom,gcc-msm8996.h12575logplain -rw-r--r--qcom,lcc-ipq806x.h899logplain -rw-r--r--qcom,lcc-mdm9615.h1701logplain -rw-r--r--qcom,lcc-msm8960.h1616logplain -rw-r--r--qcom,mmcc-apq8084.h5722logplain -rw-r--r--qcom,mmcc-msm8960.h4109logplain -rw-r--r--qcom,mmcc-msm8974.h5223logplain -rw-r--r--qcom,mmcc-msm8996.h9403logplain -rw-r--r--qcom,rpmcc.h2101logplain -rw-r--r--r7s72100-clock.h1218logplain -rw-r--r--r8a73a4-clock.h1596logplain -rw-r--r--r8a7740-clock.h1992logplain -rw-r--r--r8a7743-cpg-mssr.h1269logplain -rw-r--r--r8a7745-cpg-mssr.h1298logplain -rw-r--r--r8a7778-clock.h1855logplain -rw-r--r--r8a7779-clock.h1647logplain -rw-r--r--r8a7790-clock.h4367logplain -rw-r--r--r8a7791-clock.h4388logplain -rw-r--r--r8a7792-clock.h2562logplain -rw-r--r--r8a7793-clock.h4561logplain -rw-r--r--r8a7794-clock.h3679logplain -rw-r--r--r8a7795-cpg-mssr.h1890logplain -rw-r--r--r8a7796-cpg-mssr.h2066logplain -rw-r--r--renesas-cpg-mssr.h542logplain -rw-r--r--rk1108-cru.h6605logplain -rw-r--r--rk3036-cru.h4584logplain -rw-r--r--rk3066a-cru.h1068logplain -rw-r--r--rk3188-cru-common.h6105logplain -rw-r--r--rk3188-cru.h1435logplain