前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IP Header in FWPM_LAYER_INBOUND_IPPACKET_V4

IP Header in FWPM_LAYER_INBOUND_IPPACKET_V4

作者头像
战神伽罗
发布2021-03-08 11:49:56
7170
发布2021-03-08 11:49:56
举报
文章被收录于专栏:Eureka的技术时光轴
Question
Question
Sign in to vote
Sign in to vote

2 Sign in to vote Hi, this problem I have seems to be closely related to another mine here: http://social.msdn.microsoft.com/Forums/en-US/wfp/thread/65c34860-6d8d-4475-9b9b-b06541158875 Anyway, I have a callout registered in the INBOUND_IPPACKET layer and I'd like to access to the IP Header. I'm able to access to the TCP Header just reading from the current pointer: ---------------------------- tcp_header = (TCP_HEADER*)NdisGetDataBuffer( nb, sizeof(TCP_HEADER), NULL, sizeof(UINT16), 0); ---------------------------- but trying to read the ip header with this code: ---------------------------- status2 = NdisRetreatNetBufferDataStart( nb, inMetaValues->ipHeaderSize, 0, NULL); if (status2 != NDIS_STATUS_SUCCESS) { ...; goto Exit; } ip_header = (IP_HEADER*)NdisGetDataBuffer( nb, sizeof(IP_HEADER), NULL, sizeof(UINT16), 0); if (ip_header == NULL) { ...; goto Exit; } ---------------------------- I found dirty data in the IP_HEADER structure... I'm sure there is something wrong but I totally don't understand or imagine where!! Anyone have an idea? Thanks, Marco Wednesday, August 4, 2010 7:09 PM

Marco Mura 2,280 Points

Answers

Question
Question
Sign in to vote
Sign in to vote

1 Sign in to vote Found it! My mistake was retreating the cloned buffer... and the buffer was cloned from the pointer after the IP header. So I was reading dirty stuff because I was already at the beginning of the cloned buffer. So, for the records, the correct way is to call NdisRetreatNetBufferListDataStart to (NET_BUFFER_LIST*)layerData and not to nb ! For the records: ---------------------------- status2 = NdisRetreatNetBufferListDataStart( (NET_BUFFER_LIST*)layerData, inMetaValues->ipHeaderSize, 0, NULL, NULL); if (status2 != NDIS_STATUS_SUCCESS) { ...; goto Exit; } status = FwpsAllocateCloneNetBufferList0( (NET_BUFFER_LIST*)layerData, NULL, NULL, 0, &nbl); if (!NT_SUCCESS(status)) { ...; goto Exit; } nb = NET_BUFFER_LIST_FIRST_NB(nbl); ip_header = (IP_HEADER*)NdisGetDataBuffer( nb, sizeof(IP_HEADER), NULL, sizeof(UINT16), 0); if (ip_header == NULL) { ...; goto Exit; } protocol = ip_header->Protocol; ...; NdisAdvanceNetBufferListDataStart( (NET_BUFFER_LIST*)layerData, inMetaValues->ipHeaderSize, FALSE, NULL); ---------------------------- Thanks, Marco

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Answers
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档