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) \
|
||||
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) \
|
||||
{ \
|
||||
int num = MIN(packet_get_tunnel_count(pkt), (sizeof(tunnels) / sizeof(tunnels[0]))); \
|
||||
for (int i = 0; i < num && packet_get_tunnel_by_idx(pkt, i, &tunnels[i]) == 0; i++) \
|
||||
/* void */; \
|
||||
return num; \
|
||||
}
|
||||
#define PACKET_GETALL_TUNNELS(pkt, tunnels) \
|
||||
({ \
|
||||
memset(tunnels, 0, sizeof(tunnels)); \
|
||||
int size = sizeof(tunnels) / sizeof(tunnels[0]); \
|
||||
int count = packet_get_tunnel_count(pkt); \
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user