bpf filter to prevent echo reply and request messages



I am struggling to come up with a bpf filter (or lsf I guess because I
am using Linux) that will allow me to receive only the 5 necessary
messages for ipv6 neighbor discovery on my raw socket. These would
include neighbor solicitations, neighbor advertisements, router
solicitations, router advertisements, and redirects. The socket I am
creating in my C++ code is:

sock=socket(PF_PACKET, SOCK_RAW,htons(ETH_P_IPV6));

I have used tcpdump to make a filter to limit packets on this socket to
only icmp6 messages. However, I need to limit it further so my
application cannot be bombarded with echo requests and replies.
Tcpdump does not have support for the necessary type of expression
(i.e. icmp6[x]), so I cannot utilize it to create the bpf and must
instead come up with it on my own. Being a novice at bpf, this is
proving difficult.

Can anyone help or at least point me in the right direction?

My current filter (limiting to all icmp6 traffic) is:

struct sock_filter bpf[] = {
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 3, 0x000086dd },
{ 0x30, 0, 0, 0x00000014 },
{ 0x15, 0, 1, 0x0000003a },
{ 0x6, 0, 0, 0x00000060 },
{ 0x6, 0, 0, 0x00000000 }
};

Thanks in advance for the help.

.



Relevant Pages

  • Re: Help re noisy Bt line
    ... Plug the filter into the test socket and bodily plug ... but in this case try the phones with and without additional ...
    (uk.telecom.broadband)
  • Re: BT Faceplates and ADSL
    ... provide an *unfiltered* ADSL output on the RJ11 socket. ... cable from the unfiltered IDC on the back of the faceplate filter. ... Don't forget that the ADSL ...
    (uk.comp.homebuilt)
  • Re: Awful upload speed
    ... >physically able to crawl under the desk and mess with the socket. ... >By "faceplate filter", do you mean like the one shown on the clarity ... But you can only use that on the appropriate NTE5 linebox master ... >extension lead from the bedroom phone and ran the test again, ...
    (uk.telecom.broadband)
  • Re: DSL light flashing
    ... The DSL light flashes and when it flashes there is no way I can get ... terminal from the socket with no problem. ... Do you think I would benifit from a stronger filter and if so is there such ... BT are cautious over credit card terminals sharing the same line as an ...
    (uk.people.silversurfers)
  • Re: Newbie Query
    ... > computers, ... ADSL equipment *doesn't* need to be filtered, ... but it is often convenient to use the unfiltered ADSL socket on a plug-in ... filter, simply as a way of providing a BT to RJ11 adapter. ...
    (uk.telecom.broadband)

Loading