Vitezslav Samel <vitezslav(a)samel.cz> writes:
On Fri, Jul 13, 2012 at 03:19:18PM +0200, Nikola Pajkovsky wrote:
> not everything is possible converth right now
>
> Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
> ---
> src/detstats.c | 6 ++---
> src/itrafmon.c | 70 +++++++++++++++++++++++++-------------------------------
> src/packet.c | 6 +++++
> src/packet.h | 4 ++++
> src/serv.c | 13 +++++------
> 5 files changed, 49 insertions(+), 50 deletions(-)
>
> diff --git a/src/packet.c b/src/packet.c
> index fbd94f1..2a22dbc 100644
> --- a/src/packet.c
> +++ b/src/packet.c
> @@ -47,6 +47,12 @@ static int packet_adjust(struct pkt_hdr *pkt)
> case ARPHRD_ETHER:
> case ARPHRD_LOOPBACK:
> pkt_cast_hdrp(ethhdr, pkt, 0);
> + if (pkt->pkt_protocol == ETH_P_IP)
> + pkt_cast_hdrp(iphdr, pkt, ETH_HLEN);
> +
> + if (pkt->pkt_protocol == ETH_P_IPV6)
> + pkt_cast_hdrp(ip6_hdr, pkt, ETH_HLEN);
> +
> pkt->pkt_payload = pkt->pkt_buf;
> pkt->pkt_payload += ETH_HLEN;
> pkt->pkt_len -= ETH_HLEN;
NAK.
Tests for upper layer protocol should be moved after this switch and
pkt_cast_hdrp() (better some new function) should use pkt->pkt_payload
pointer. (You are mixing two protocol layers together - don't do this!)
I'm not sure if I'm on the same page.
#define pkt_cast_hdrp(hdr, pkt, off) \
do { \
pkt->hdr = (struct hdr *) pkt->pkt_buf + off; \
} while (0)
intent to be generic macro, which can cast any type of net header
with offset to raw packet. I think, it pretty neat. _pkt_cast_hdrp()
also should be moved to packet.c, it's pretty dangerous and we should
never us it outside of packet.c. I agree, that I miss extra VLAN_LEN
(pitty, that define is under __KERNEL__ guards).
--
Nikola