bugfix: http_decoder and glimpse_detector use new API get packet layer
This commit is contained in:
@@ -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))
|
if(pkt && (flow_dir==FLOW_DIRECTION_C2S || flow_dir==FLOW_DIRECTION_S2C))
|
||||||
{
|
{
|
||||||
int layer_cnt=packet_get_layer_count(pkt);
|
int layer_cnt=packet_get_layer_count(pkt);
|
||||||
struct layer l={};
|
const struct layer *layer = packet_get_layer_by_idx(pkt, layer_cnt - 1);
|
||||||
packet_get_layer_by_idx(pkt, layer_cnt-1, &l);
|
if (layer && layer->proto == LAYER_PROTO_TCP)
|
||||||
switch((int)l.proto)
|
|
||||||
{
|
{
|
||||||
case LAYER_PROTO_TCP:
|
*sport = ntohs(layer->hdr.tcp->th_sport);
|
||||||
*sport = ntohs(l.hdr.tcp->th_sport);
|
*dport = ntohs(layer->hdr.tcp->th_dport);
|
||||||
*dport = ntohs(l.hdr.tcp->th_dport);
|
}
|
||||||
break;
|
if (layer && layer->proto == LAYER_PROTO_UDP)
|
||||||
case LAYER_PROTO_UDP:
|
{
|
||||||
*sport = ntohs(l.hdr.udp->uh_sport);
|
*sport = ntohs(layer->hdr.udp->uh_sport);
|
||||||
*dport = ntohs(l.hdr.udp->uh_dport);
|
*dport = ntohs(layer->hdr.udp->uh_dport);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
//S2C, swap sport and dport
|
//S2C, swap sport and dport
|
||||||
if(flow_dir == FLOW_DIRECTION_S2C)
|
if(flow_dir == FLOW_DIRECTION_S2C)
|
||||||
|
|||||||
@@ -287,24 +287,23 @@ void httpd_session_get_addr(const struct session *sess, struct httpd_session_add
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct layer pkt_layer = {};
|
int count = packet_get_layer_count(raw_pkt);
|
||||||
PACKET_FOREACH_LAYER_REVERSE(raw_pkt, pkt_layer)
|
for (int i = count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (pkt_layer.proto == LAYER_PROTO_TCP)
|
const struct layer *layer = packet_get_layer_by_idx(raw_pkt, i);
|
||||||
|
if (layer->proto == LAYER_PROTO_TCP)
|
||||||
{
|
{
|
||||||
httpd_set_tcp_addr(pkt_layer.hdr.tcp, addr, fdir);
|
httpd_set_tcp_addr(layer->hdr.tcp, addr, fdir);
|
||||||
}
|
}
|
||||||
else if (pkt_layer.proto == LAYER_PROTO_IPV4)
|
else if (layer->proto == LAYER_PROTO_IPV4)
|
||||||
{
|
{
|
||||||
httpd_set_ipv4_addr(pkt_layer.hdr.ip4, addr, fdir);
|
httpd_set_ipv4_addr(layer->hdr.ip4, addr, fdir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (pkt_layer.proto == LAYER_PROTO_IPV6)
|
else if (layer->proto == LAYER_PROTO_IPV6)
|
||||||
{
|
{
|
||||||
httpd_set_ipv6_addr(pkt_layer.hdr.ip6, addr, fdir);
|
httpd_set_ipv6_addr(layer->hdr.ip6, addr, fdir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user