From f2828acdd708eea5ac95542c2258c894ef1cda9b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 4 May 2015 09:51:57 +0200 Subject: netsniff-ng: Rename protocol dissector member of struct pkt_buff In commit d312a25879d5 ("netsniff-ng nlmsg: Print netlink protocol name"), the struct protocol member of struct pkt_buff was renamed to handler to account for the newly added proto field. However, the corresponding function pkt_set_proto wasn't renamed which is a bit counter-intuitive. Fix this by renaming the member again, this time to dissector (as I don't consider handler a particulary meaningful name) and adjust the set function's name accordingly. Signed-off-by: Tobias Klauser --- dissector.c | 12 ++++++------ pkt_buff.h | 14 +++++++------- proto_80211_mac_hdr.c | 2 +- proto_ethernet.c | 4 ++-- proto_ip_authentication_hdr.c | 4 ++-- proto_ipv4.c | 4 ++-- proto_ipv6.c | 4 ++-- proto_ipv6_dest_opts.c | 4 ++-- proto_ipv6_fragm.c | 4 ++-- proto_ipv6_hop_by_hop.c | 4 ++-- proto_ipv6_mobility_hdr.c | 4 ++-- proto_ipv6_routing.c | 4 ++-- proto_mpls_unicast.c | 4 ++-- proto_vlan.c | 4 ++-- proto_vlan_q_in_q.c | 4 ++-- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dissector.c b/dissector.c index ca98386..4cad588 100644 --- a/dissector.c +++ b/dissector.c @@ -42,18 +42,18 @@ int dissector_set_print_type(void *ptr, int type) static void dissector_main(struct pkt_buff *pkt, struct protocol *start, struct protocol *end) { - struct protocol *handler; + struct protocol *dissector; if (!start) return; - for (pkt->handler = start; pkt->handler; ) { - if (unlikely(!pkt->handler->process)) + for (pkt->dissector = start; pkt->dissector; ) { + if (unlikely(!pkt->dissector->process)) break; - handler = pkt->handler; - pkt->handler = NULL; - handler->process(pkt); + dissector = pkt->dissector; + pkt->dissector = NULL; + dissector->process(pkt); } if (end && likely(end->process)) diff --git a/pkt_buff.h b/pkt_buff.h index e044f66..28872ef 100644 --- a/pkt_buff.h +++ b/pkt_buff.h @@ -19,7 +19,7 @@ struct pkt_buff { uint8_t *tail; unsigned int size; - struct protocol *handler; + struct protocol *dissector; uint32_t link_type; uint16_t proto; }; @@ -32,7 +32,7 @@ static inline struct pkt_buff *pkt_alloc(uint8_t *packet, unsigned int len) pkt->data = packet; pkt->tail = packet + len; pkt->size = len; - pkt->handler = NULL; + pkt->dissector = NULL; return pkt; } @@ -101,14 +101,14 @@ static inline uint8_t *pkt_pull_tail(struct pkt_buff *pkt, unsigned int len) return tail; } -static inline void pkt_set_proto(struct pkt_buff *pkt, struct hash_table *table, - unsigned int key) +static inline void pkt_set_dissector(struct pkt_buff *pkt, struct hash_table *table, + unsigned int key) { bug_on(!pkt || !table); - pkt->handler = lookup_hash(key, table); - while (pkt->handler && key != pkt->handler->key) - pkt->handler = pkt->handler->next; + pkt->dissector = lookup_hash(key, table); + while (pkt->dissector && key != pkt->dissector->key) + pkt->dissector = pkt->dissector->next; } #endif /* PKT_BUFF_H */ diff --git a/proto_80211_mac_hdr.c b/proto_80211_mac_hdr.c index 1a4f7cc..5fdfa97 100644 --- a/proto_80211_mac_hdr.c +++ b/proto_80211_mac_hdr.c @@ -3257,7 +3257,7 @@ static void ieee80211(struct pkt_buff *pkt) tprintf("\n"); -// pkt_set_proto(pkt, &ieee802_lay2, ntohs(eth->h_proto)); +// pkt_set_dissector(pkt, &ieee802_lay2, ntohs(eth->h_proto)); } static void ieee80211_less(struct pkt_buff *pkt __maybe_unused) diff --git a/proto_ethernet.c b/proto_ethernet.c index 98d40e5..5a257f0 100644 --- a/proto_ethernet.c +++ b/proto_ethernet.c @@ -69,7 +69,7 @@ static void ethernet(struct pkt_buff *pkt) tprintf("(%s => %s)", ether_lookup_addr(src_mac), ether_lookup_addr(dst_mac)); tprintf(" ]\n"); - pkt_set_proto(pkt, ð_lay2, ntohs(eth->h_proto)); + pkt_set_dissector(pkt, ð_lay2, ntohs(eth->h_proto)); } static void ethernet_less(struct pkt_buff *pkt) @@ -90,7 +90,7 @@ static void ethernet_less(struct pkt_buff *pkt) tprintf("%s%s%s", colorize_start(bold), lookup_ether_type(ntohs(eth->h_proto)), colorize_end()); - pkt_set_proto(pkt, ð_lay2, ntohs(eth->h_proto)); + pkt_set_dissector(pkt, ð_lay2, ntohs(eth->h_proto)); } struct protocol ethernet_ops = { diff --git a/proto_ip_authentication_hdr.c b/proto_ip_authentication_hdr.c index d8b352f..b2b7a26 100644 --- a/proto_ip_authentication_hdr.c +++ b/proto_ip_authentication_hdr.c @@ -65,7 +65,7 @@ static void auth_hdr(struct pkt_buff *pkt) } tprintf(" ]\n"); - pkt_set_proto(pkt, ð_lay3, auth_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, auth_ops->h_next_header); } static void auth_hdr_less(struct pkt_buff *pkt) @@ -84,7 +84,7 @@ static void auth_hdr_less(struct pkt_buff *pkt) tprintf(" AH"); pkt_pull(pkt, hdr_len - sizeof(*auth_ops)); - pkt_set_proto(pkt, ð_lay3, auth_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, auth_ops->h_next_header); } struct protocol ip_auth_ops = { diff --git a/proto_ipv4.c b/proto_ipv4.c index 47eca29..799040f 100644 --- a/proto_ipv4.c +++ b/proto_ipv4.c @@ -164,7 +164,7 @@ out: pkt_trim(pkt, pkt_len(pkt) - min(pkt_len(pkt), (ntohs(ip->h_tot_len) - ip->h_ihl * sizeof(uint32_t)))); - pkt_set_proto(pkt, ð_lay3, ip->h_protocol); + pkt_set_dissector(pkt, ð_lay3, ip->h_protocol); } static void ipv4_less(struct pkt_buff *pkt) @@ -190,7 +190,7 @@ static void ipv4_less(struct pkt_buff *pkt) pkt_trim(pkt, pkt_len(pkt) - min(pkt_len(pkt), (ntohs(ip->h_tot_len) - ip->h_ihl * sizeof(uint32_t)))); #endif - pkt_set_proto(pkt, ð_lay3, ip->h_protocol); + pkt_set_dissector(pkt, ð_lay3, ip->h_protocol); } struct protocol ipv4_ops = { diff --git a/proto_ipv6.c b/proto_ipv6.c index 1cc93ba..ba3f6c8 100644 --- a/proto_ipv6.c +++ b/proto_ipv6.c @@ -82,7 +82,7 @@ void ipv6(struct pkt_buff *pkt) tprintf(") ]\n"); } - pkt_set_proto(pkt, ð_lay3, ip->nexthdr); + pkt_set_dissector(pkt, ð_lay3, ip->nexthdr); } void ipv6_less(struct pkt_buff *pkt) @@ -100,7 +100,7 @@ void ipv6_less(struct pkt_buff *pkt) tprintf(" %s/%s Len %u", src_ip, dst_ip, ntohs(ip->payload_len)); - pkt_set_proto(pkt, ð_lay3, ip->nexthdr); + pkt_set_dissector(pkt, ð_lay3, ip->nexthdr); } struct protocol ipv6_ops = { diff --git a/proto_ipv6_dest_opts.c b/proto_ipv6_dest_opts.c index 04d02fa..68670ba 100644 --- a/proto_ipv6_dest_opts.c +++ b/proto_ipv6_dest_opts.c @@ -68,7 +68,7 @@ static void dest_opts(struct pkt_buff *pkt) tprintf(" ]\n"); pkt_pull(pkt, opt_len); - pkt_set_proto(pkt, ð_lay3, dest_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, dest_ops->h_next_header); } static void dest_opts_less(struct pkt_buff *pkt) @@ -91,7 +91,7 @@ static void dest_opts_less(struct pkt_buff *pkt) tprintf(" Dest Ops"); pkt_pull(pkt, opt_len); - pkt_set_proto(pkt, ð_lay3, dest_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, dest_ops->h_next_header); } struct protocol ipv6_dest_opts_ops = { diff --git a/proto_ipv6_fragm.c b/proto_ipv6_fragm.c index 4e4af50..43c0f20 100644 --- a/proto_ipv6_fragm.c +++ b/proto_ipv6_fragm.c @@ -43,7 +43,7 @@ static void fragm(struct pkt_buff *pkt) ntohl(fragm_ops->h_fragm_identification)); tprintf(" ]\n"); - pkt_set_proto(pkt, ð_lay3, fragm_ops->h_fragm_next_header); + pkt_set_dissector(pkt, ð_lay3, fragm_ops->h_fragm_next_header); } static void fragm_less(struct pkt_buff *pkt) @@ -59,7 +59,7 @@ static void fragm_less(struct pkt_buff *pkt) tprintf(" FragmOffs %u", off_res_M >> 3); - pkt_set_proto(pkt, ð_lay3, fragm_ops->h_fragm_next_header); + pkt_set_dissector(pkt, ð_lay3, fragm_ops->h_fragm_next_header); } struct protocol ipv6_fragm_ops = { diff --git a/proto_ipv6_hop_by_hop.c b/proto_ipv6_hop_by_hop.c index a03bbfa..ffcaa61 100644 --- a/proto_ipv6_hop_by_hop.c +++ b/proto_ipv6_hop_by_hop.c @@ -67,7 +67,7 @@ static void hop_by_hop(struct pkt_buff *pkt) tprintf(" ]\n"); pkt_pull(pkt, opt_len); - pkt_set_proto(pkt, ð_lay3, hop_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, hop_ops->h_next_header); } static void hop_by_hop_less(struct pkt_buff *pkt) @@ -90,7 +90,7 @@ static void hop_by_hop_less(struct pkt_buff *pkt) tprintf(" Hop Ops"); pkt_pull(pkt, opt_len); - pkt_set_proto(pkt, ð_lay3, hop_ops->h_next_header); + pkt_set_dissector(pkt, ð_lay3, hop_ops->h_next_header); } struct protocol ipv6_hop_by_hop_ops = { diff --git a/proto_ipv6_mobility_hdr.c b/proto_ipv6_mobility_hdr.c index 357dfb9..90f0678 100644 --- a/proto_ipv6_mobility_hdr.c +++ b/proto_ipv6_mobility_hdr.c @@ -282,7 +282,7 @@ static void mobility(struct pkt_buff *pkt) return; pkt_pull(pkt, message_data_len); - pkt_set_proto(pkt, ð_lay3, mobility->payload_proto); + pkt_set_dissector(pkt, ð_lay3, mobility->payload_proto); } static void mobility_less(struct pkt_buff *pkt) @@ -305,7 +305,7 @@ static void mobility_less(struct pkt_buff *pkt) tprintf(" Mobility Type (%u), ", mobility->MH_type); pkt_pull(pkt, message_data_len); - pkt_set_proto(pkt, ð_lay3, mobility->payload_proto); + pkt_set_dissector(pkt, ð_lay3, mobility->payload_proto); } struct protocol ipv6_mobility_ops = { diff --git a/proto_ipv6_routing.c b/proto_ipv6_routing.c index f70f73a..f56f32f 100644 --- a/proto_ipv6_routing.c +++ b/proto_ipv6_routing.c @@ -118,7 +118,7 @@ static void routing(struct pkt_buff *pkt) return; pkt_pull(pkt, data_len); - pkt_set_proto(pkt, ð_lay3, routing->h_next_header); + pkt_set_dissector(pkt, ð_lay3, routing->h_next_header); } static void routing_less(struct pkt_buff *pkt) @@ -152,7 +152,7 @@ static void routing_less(struct pkt_buff *pkt) return; pkt_pull(pkt, data_len); - pkt_set_proto(pkt, ð_lay3, routing->h_next_header); + pkt_set_dissector(pkt, ð_lay3, routing->h_next_header); } struct protocol ipv6_routing_ops = { diff --git a/proto_mpls_unicast.c b/proto_mpls_unicast.c index e01672a..69c01f3 100644 --- a/proto_mpls_unicast.c +++ b/proto_mpls_unicast.c @@ -73,7 +73,7 @@ static void mpls_uc_full(struct pkt_buff *pkt) if (next < 0) return; - pkt_set_proto(pkt, ð_lay2, (uint16_t) next); + pkt_set_dissector(pkt, ð_lay2, (uint16_t) next); } static void mpls_uc_less(struct pkt_buff *pkt) @@ -98,7 +98,7 @@ static void mpls_uc_less(struct pkt_buff *pkt) if (next < 0) return; - pkt_set_proto(pkt, ð_lay2, (uint16_t) next); + pkt_set_dissector(pkt, ð_lay2, (uint16_t) next); } struct protocol mpls_uc_ops = { diff --git a/proto_vlan.c b/proto_vlan.c index 9ba66a9..a175dde 100644 --- a/proto_vlan.c +++ b/proto_vlan.c @@ -35,7 +35,7 @@ static void vlan(struct pkt_buff *pkt) tprintf("Proto (0x%.4x)", ntohs(vlan->h_vlan_encapsulated_proto)); tprintf(" ]\n"); - pkt_set_proto(pkt, ð_lay2, ntohs(vlan->h_vlan_encapsulated_proto)); + pkt_set_dissector(pkt, ð_lay2, ntohs(vlan->h_vlan_encapsulated_proto)); } static void vlan_less(struct pkt_buff *pkt) @@ -50,7 +50,7 @@ static void vlan_less(struct pkt_buff *pkt) tprintf(" VLAN%d", (tci & 0x0FFF)); - pkt_set_proto(pkt, ð_lay2, ntohs(vlan->h_vlan_encapsulated_proto)); + pkt_set_dissector(pkt, ð_lay2, ntohs(vlan->h_vlan_encapsulated_proto)); } struct protocol vlan_ops = { diff --git a/proto_vlan_q_in_q.c b/proto_vlan_q_in_q.c index 20b4bc1..8bc2325 100644 --- a/proto_vlan_q_in_q.c +++ b/proto_vlan_q_in_q.c @@ -37,7 +37,7 @@ static void QinQ_full(struct pkt_buff *pkt) tprintf("Proto (0x%.4x)", ntohs(QinQ->TPID)); tprintf(" ]\n"); - pkt_set_proto(pkt, ð_lay2, ntohs(QinQ->TPID)); + pkt_set_dissector(pkt, ð_lay2, ntohs(QinQ->TPID)); } static void QinQ_less(struct pkt_buff *pkt) @@ -52,7 +52,7 @@ static void QinQ_less(struct pkt_buff *pkt) tprintf(" VLAN%d", (tci & 0x0FFF)); - pkt_set_proto(pkt, ð_lay2, ntohs(QinQ->TPID)); + pkt_set_dissector(pkt, ð_lay2, ntohs(QinQ->TPID)); } struct protocol QinQ_ops = { -- cgit v1.2.3-54-g00ecf