perf: 将parse_l4的next_proto从uint16_t调整为uint8_t, 避免隐式类型转换
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user