* Cannot get the correct IP version from packet
@ 2024-03-16 18:11 Alessandro Vesely
2024-03-16 18:50 ` Alessandro Vesely
0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Vesely @ 2024-03-16 18:11 UTC (permalink / raw)
To: netfilter
Help me please,
In the queue callback (const struct nlmsghdr *nlh, void *data), I do:
struct nlattr *attr[NFQA_MAX+1] = {};
if (nfq_nlmsg_parse(nlh, attr) < 0)
return MNL_CB_ERROR;
char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
if (payload)
{
int const af = (payload[0] & 0xf);
And here I get af == 5. It should be 4 or 6.
That's using libmnl0:amd64 1.0.4-3. What's happening?
TIA for any hint
Best
Ale
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot get the correct IP version from packet
2024-03-16 18:11 Cannot get the correct IP version from packet Alessandro Vesely
@ 2024-03-16 18:50 ` Alessandro Vesely
2024-03-16 22:21 ` Meiyong Yu
0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Vesely @ 2024-03-16 18:50 UTC (permalink / raw)
To: netfilter
On Sat 16/Mar/2024 19:11:58 +0100 Alessandro Vesely wrote:
>
> char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
> if (payload)
> {
> int const af = (payload[0] & 0xf);
Heck, should be af = (payload[0] &0xf0)>>4 = 0x6
third time I change it...
Best
Ale
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot get the correct IP version from packet
2024-03-16 18:50 ` Alessandro Vesely
@ 2024-03-16 22:21 ` Meiyong Yu
2024-03-17 9:08 ` Alessandro Vesely
0 siblings, 1 reply; 4+ messages in thread
From: Meiyong Yu @ 2024-03-16 22:21 UTC (permalink / raw)
To: Alessandro Vesely; +Cc: netfilter
> 在 2024年3月17日,02:51,Alessandro Vesely <vesely@tana.it> 写道:
>
> On Sat 16/Mar/2024 19:11:58 +0100 Alessandro Vesely wrote:
>> char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
>> if (payload)
>> {
>> int const af = (payload[0] & 0xf);
>
> Heck, should be af = (payload[0] &0xf0)>>4 = 0x6
>
> third time I change it...
>
>
> Best
> Ale
>
char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
before this line, you must check if attr[NFQA_PAYLOAD] is NULL pointer,may be it is NULL pointer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot get the correct IP version from packet
2024-03-16 22:21 ` Meiyong Yu
@ 2024-03-17 9:08 ` Alessandro Vesely
0 siblings, 0 replies; 4+ messages in thread
From: Alessandro Vesely @ 2024-03-17 9:08 UTC (permalink / raw)
To: Meiyong Yu; +Cc: netfilter
On Sat 16/Mar/2024 23:21:31 +0100 Meiyong Yu wrote:
>> 在 2024年3月17日,02:51,Alessandro Vesely <vesely@tana.it> 写道:
>> On Sat 16/Mar/2024 19:11:58 +0100 Alessandro Vesely wrote:
>>> char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
>>> if (payload)
>>> {
>>> int const af = (payload[0] & 0xf);
>>
>> Heck, should be af = (payload[0] &0xf0)>>4 = 0x6
>>
>> third time I change it...
>
> char *payload = mnl_attr_get_payload(attr[NFQA_PAYLOAD]);
>
> before this line, you must check if attr[NFQA_PAYLOAD] is NULL pointer,may be it is NULL pointer
Good point, I'll add that check. Thank you.
Best
Ale
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-17 9:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-16 18:11 Cannot get the correct IP version from packet Alessandro Vesely
2024-03-16 18:50 ` Alessandro Vesely
2024-03-16 22:21 ` Meiyong Yu
2024-03-17 9:08 ` Alessandro Vesely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).