Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get TCP options #5197

Closed
neo-hu opened this issue Jan 19, 2025 · 1 comment
Closed

How to get TCP options #5197

neo-hu opened this issue Jan 19, 2025 · 1 comment

Comments

@neo-hu
Copy link

neo-hu commented Jan 19, 2025

How to get client IP (toa) in TCP option

@chenhengqi
Copy link
Collaborator

This is not related to BCC itself. Please check the following code on how to parse TCP header:

tcp = (void *)ip + sizeof(*ip);
if (tcp_header_bound_check(tcp, data_end))
{
return TC_ACT_OK;
}
u8 tcpflags = ((u_int8_t *)tcp)[13];
u16 src_port = bpf_ntohs(tcp->source);
u16 dst_port = bpf_ntohs(tcp->dest);
key.src_ip = ip->saddr;
key.src_port = src_port;
key.dst_ip = ip->daddr;
key.dst_port = dst_port;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants