From a6476847049e8cb1c988189f827b892d2b3cc84a Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Tue, 28 Nov 2023 17:24:57 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B0=86parse=5Fl4=E7=9A=84next=5Fprot?= =?UTF-8?q?o=E4=BB=8Euint16=5Ft=E8=B0=83=E6=95=B4=E4=B8=BAuint8=5Ft,=20?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=9A=90=E5=BC=8F=E7=B1=BB=E5=9E=8B=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/packet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/packet.cpp b/common/src/packet.cpp index 2784ac5..d93543e 100644 --- a/common/src/packet.cpp +++ b/common/src/packet.cpp @@ -64,7 +64,7 @@ static inline const char *parse_vxlan(struct packet *handler, const char *data, static inline const char *parse_gtpv1_u(struct packet *handler, const char *data, uint16_t len); // L3/L4 static inline const char *parse_l3(struct packet *handler, uint16_t next_proto, const char *data, uint16_t len); -static inline const char *parse_l4(struct packet *handler, uint16_t next_proto, const char *data, uint16_t len); +static inline const char *parse_l4(struct packet *handler, uint8_t next_proto, const char *data, uint16_t len); /****************************************************************************** * Private API -- Utils @@ -785,7 +785,7 @@ static inline const char *parse_ipv4(struct packet *handler, const char *data, u return data; } struct ip *hdr = (struct ip *)data; - uint16_t next_proto = hdr->ip_p; + uint8_t next_proto = hdr->ip_p; uint16_t hdr_len = (hdr->ip_hl & 0xf) * 4u; SET_LAYER(handler, layer, LAYER_TYPE_IPV4, hdr_len, data, len); @@ -805,7 +805,7 @@ static inline const char *parse_ipv6(struct packet *handler, const char *data, u { return data; } - uint16_t next_proto = ((struct ip6_hdr *)data)->ip6_nxt; + uint8_t next_proto = ((struct ip6_hdr *)data)->ip6_nxt; SET_LAYER(handler, layer, LAYER_TYPE_IPV6, sizeof(struct ip6_hdr), data, len); return parse_l4(handler, next_proto, layer->pld_ptr, layer->pld_len); @@ -971,7 +971,7 @@ static inline const char *parse_l3(struct packet *handler, uint16_t next_proto, } } -static inline const char *parse_l4(struct packet *handler, uint16_t next_proto, const char *data, uint16_t len) +static inline const char *parse_l4(struct packet *handler, uint8_t next_proto, const char *data, uint16_t len) { switch (next_proto) {