bugfix: PACKET_GETALL_TUNNELS
This commit is contained in:
@@ -47,13 +47,16 @@ int packet_get_tunnel_by_idx(const struct packet *pkt, int idx, struct tunnel *o
|
|||||||
#define PACKET_FOREACH_TUNNEL_REVERSE(pkt, tunnel) \
|
#define PACKET_FOREACH_TUNNEL_REVERSE(pkt, tunnel) \
|
||||||
for (int i = packet_get_tunnel_count(pkt) - 1; i >= 0 && packet_get_tunnel_by_idx(pkt, i, &tunnel) == 0; i--)
|
for (int i = packet_get_tunnel_count(pkt) - 1; i >= 0 && packet_get_tunnel_by_idx(pkt, i, &tunnel) == 0; i--)
|
||||||
|
|
||||||
#define PACKET_GETALL_TUNNELS(pkt, tunnels) \
|
#define PACKET_GETALL_TUNNELS(pkt, tunnels) \
|
||||||
{ \
|
({ \
|
||||||
int num = MIN(packet_get_tunnel_count(pkt), (sizeof(tunnels) / sizeof(tunnels[0]))); \
|
memset(tunnels, 0, sizeof(tunnels)); \
|
||||||
for (int i = 0; i < num && packet_get_tunnel_by_idx(pkt, i, &tunnels[i]) == 0; i++) \
|
int size = sizeof(tunnels) / sizeof(tunnels[0]); \
|
||||||
/* void */; \
|
int count = packet_get_tunnel_count(pkt); \
|
||||||
return num; \
|
int num = count > size ? size : count; \
|
||||||
}
|
for (int i = 0; i < num && packet_get_tunnel_by_idx(pkt, i, &tunnels[i]) == 0; i++) \
|
||||||
|
/* void */; \
|
||||||
|
num; \
|
||||||
|
})
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user