lkml.org 
[lkml]   [1999]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectLinux Socket Filter help/example code?
Does anyone have any examples of how to use the Linux Socket Filter?  Yes,
I have read the documentation, and it doesn't really address my questions.
I'm trying to port a program that uses BPF, and it's somewhat frustrating,
because all the structs and fields have different names for no readily
apparent reason, and some of the structs don't seem to exist.

I started by doing this:

#ifndef __linux__
/* the original includes */
#include <net/pfilt.h>
#include <net/bpf.h>
#else
/* the linux includes */
#include <linux/types.h>
#undef __KERNEL__
#include <linux/filter.h>
/* Linux has different names for everything, sigh. */
#define bpf_insn sock_filter
#define bpf_program sock_fprog
#define bf_len len
#define bf_insns filter
#endif

Between that, and changing the way the filter is installed, that got me
part way there. But at the moment I'm stuck because the program has
references to a struct bpf_hdr that the filter is supposed to put at the
start of captured packets. I've looked through the system includes, and I
can't seem to find any equivalent, but surely it must be defined somewhere?

Thanks for any suggestions or advice!

Eric

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.045 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site