l2_packet: Add support for NDISC packet filter in l2_packet_linux

Signed-off-by: Kyeyoon Park <kyeyoonp@qca.qualcomm.com>
This commit is contained in:
Kyeyoon Park 2014-11-05 16:14:24 -08:00 committed by Jouni Malinen
parent 1d783762cf
commit 7e4d893978
2 changed files with 22 additions and 0 deletions

View file

@ -41,6 +41,7 @@ struct l2_ethhdr {
enum l2_packet_filter_type {
L2_PACKET_FILTER_DHCP,
L2_PACKET_FILTER_NDISC,
};
/**

View file

@ -56,6 +56,24 @@ static const struct sock_fprog dhcp_sock_filter = {
};
/* Generated by 'sudo tcpdump -dd -s 150 multicast and ip6[6]=58' */
static struct sock_filter ndisc_sock_filter_insns[] = {
{ 0x30, 0, 0, 0x00000000 },
{ 0x45, 0, 5, 0x00000001 },
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 3, 0x000086dd },
{ 0x30, 0, 0, 0x00000014 },
{ 0x15, 0, 1, 0x0000003a },
{ 0x6, 0, 0, 0x00000096 },
{ 0x6, 0, 0, 0x00000000 },
};
static const struct sock_fprog ndisc_sock_filter = {
.len = ARRAY_SIZE(ndisc_sock_filter_insns),
.filter = ndisc_sock_filter_insns,
};
int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
{
os_memcpy(addr, l2->own_addr, ETH_ALEN);
@ -240,6 +258,9 @@ int l2_packet_set_packet_filter(struct l2_packet_data *l2,
case L2_PACKET_FILTER_DHCP:
sock_filter = &dhcp_sock_filter;
break;
case L2_PACKET_FILTER_NDISC:
sock_filter = &ndisc_sock_filter;
break;
default:
return -1;
}