Getting packets MAC source address in if_ethersubr.c

View: New views
4 Messages — Rating Filter:   Alert me  

Getting packets MAC source address in if_ethersubr.c

by Ryan French-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

For my implementation of MPLS I have just about run out of time for my
dissertation so at the moment I am trying to create fake routing table
entries e.t.c. rather than doing this properly (I will be doing this once uni
is finished and I have more free time to work on it). I now have receiving,
decoding and sending of packets working, except for one small problem. When I
send a packet back out the MAC address is wrong. I am looking for a way in
the ether_output function in if_ethersubr.c that I can get the MAC address of
the source of the packet and then just send it back to that source. If anyone
knows how to do this without having to use arpresolve or anything like that
(the IP address of the destination is not going to be the same as the IP
destination in the packet) or without having to setup a proper routing table
then it would be much appreciated.

Thanks,
-Ryan
_______________________________________________
freebsd-net@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@..."

Re: Getting packets MAC source address in if_ethersubr.c

by Eygene Ryabinkin-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ryan, good day.

Mon, Oct 06, 2008 at 05:30:23PM +1300, Ryan French wrote:
> I now have receiving,
> decoding and sending of packets working, except for one small problem. When I
> send a packet back out the MAC address is wrong. I am looking for a way in
> the ether_output function in if_ethersubr.c that I can get the MAC address of
> the source of the packet and then just send it back to that source.

Do you mean by 'the source of the packet' the MAC address of the
incoming packet to what you're sending a reply packet?  If you can
somehow "remember" the MAC address of the packet you're replying to
(don't know about internals of your application, so can't judge if it is
feasible), you can try to look at the sys/net/if_bridge.c
(bridge_enqueue at the first place and bridge_input as the example on
how to manipulate the Ethernet header).  These might help you, unless
you're not using Ethernet as the transport.
--
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual  
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #


attachment0 (202 bytes) Download Attachment

Re: Getting packets MAC source address in if_ethersubr.c

by Julian Elischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ryan French wrote:

> Hi All,
>
> For my implementation of MPLS I have just about run out of time for my
> dissertation so at the moment I am trying to create fake routing table
> entries e.t.c. rather than doing this properly (I will be doing this once uni
> is finished and I have more free time to work on it). I now have receiving,
> decoding and sending of packets working, except for one small problem. When I
> send a packet back out the MAC address is wrong. I am looking for a way in
> the ether_output function in if_ethersubr.c that I can get the MAC address of
> the source of the packet and then just send it back to that source. If anyone
> knows how to do this without having to use arpresolve or anything like that
> (the IP address of the destination is not going to be the same as the IP
> destination in the packet) or without having to setup a proper routing table
> then it would be much appreciated.
>
> Thanks,
> -Ryan
> _______________________________________________
> freebsd-net@... mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@..."


You could create a tag type that holds a layer 2 address, and attach
it to the packet on ingresss,

it should stay with the packet as long as it's not destroyed..
then on egress you could find it and use it..

_______________________________________________
freebsd-net@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@..."

Re: Getting packets MAC source address in if_ethersubr.c

by Gleb Kurtsou-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On (06/10/2008 14:04), Julian Elischer wrote:

> Ryan French wrote:
> > Hi All,
> >
> > For my implementation of MPLS I have just about run out of time for my
> > dissertation so at the moment I am trying to create fake routing table
> > entries e.t.c. rather than doing this properly (I will be doing this once uni
> > is finished and I have more free time to work on it). I now have receiving,
> > decoding and sending of packets working, except for one small problem. When I
> > send a packet back out the MAC address is wrong. I am looking for a way in
> > the ether_output function in if_ethersubr.c that I can get the MAC address of
> > the source of the packet and then just send it back to that source. If anyone
> > knows how to do this without having to use arpresolve or anything like that
> > (the IP address of the destination is not going to be the same as the IP
> > destination in the packet) or without having to setup a proper routing table
> > then it would be much appreciated.
> >
> > Thanks,
> > -Ryan
> > _______________________________________________
> > freebsd-net@... mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-net
> > To unsubscribe, send any mail to "freebsd-net-unsubscribe@..."
>
>
> You could create a tag type that holds a layer 2 address, and attach
> it to the packet on ingresss,
>
> it should stay with the packet as long as it's not destroyed..
> then on egress you could find it and use it..
That's exactly what I did for Google Summer Of Code project this year
http://wiki.freebsd.org/GlebKurtsov/Improving_layer2_filtering

Ryan, you can have a look at first changesets in perforce and extract
only functionality you need.

_______________________________________________
freebsd-net@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@..."
LightInTheBox - Buy quality products at wholesale price!