bugfix: http_decoder and glimpse_detector use new API get packet layer

This commit is contained in:
luwenpeng
2024-08-21 18:40:19 +08:00
parent 3636406c91
commit 7f96ae196a
2 changed files with 18 additions and 23 deletions

View File

@@ -191,20 +191,16 @@ static void get_host_order_port(struct session *sess __unused, unsigned short *s
if(pkt && (flow_dir==FLOW_DIRECTION_C2S || flow_dir==FLOW_DIRECTION_S2C))
{
int layer_cnt=packet_get_layer_count(pkt);
struct layer l={};
packet_get_layer_by_idx(pkt, layer_cnt-1, &l);
switch((int)l.proto)
const struct layer *layer = packet_get_layer_by_idx(pkt, layer_cnt - 1);
if (layer && layer->proto == LAYER_PROTO_TCP)
{
case LAYER_PROTO_TCP:
*sport = ntohs(l.hdr.tcp->th_sport);
*dport = ntohs(l.hdr.tcp->th_dport);
break;
case LAYER_PROTO_UDP:
*sport = ntohs(l.hdr.udp->uh_sport);
*dport = ntohs(l.hdr.udp->uh_dport);
break;
default:
break;
*sport = ntohs(layer->hdr.tcp->th_sport);
*dport = ntohs(layer->hdr.tcp->th_dport);
}
if (layer && layer->proto == LAYER_PROTO_UDP)
{
*sport = ntohs(layer->hdr.udp->uh_sport);
*dport = ntohs(layer->hdr.udp->uh_dport);
}
//S2C, swap sport and dport
if(flow_dir == FLOW_DIRECTION_S2C)