<[EMAIL PROTECTED]> said:
> I just want add some packet filter code,but can't work ,It always said
> "Unable to compile the packet filter. Check the syntax"
>
> My added code is in the below:
>
> u_int netmask;
> char packet_filter[] = "tcp dst port 25";
> struct bpf_program fcode;
>
> //compile the filter
> netmask=0xffffff;
> if(pcap_compile((pcap_t *)lpAdapter, &fcode, packet_filter, 1, netmask) <0 ){
> fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n");
> PacketFreePacket(lpPacket);
> return -1;
> }
>
> //set the filter
> if(PacketSetBpf(lpAdapter, &fcode)<0){
> fprintf(stderr,"\nError setting the filter.\n");
> PacketFreePacket(lpPacket);
> return -1;
> }
>
> I think the error is that in the pcap_compile function ,the type of 1st param
> can't match
>
> how can I compile the filter in packet.dll mode,not in the wpcap.dll mode
The 1st parameter to pcap_compile is a "handle" returned from pcap_open_live()
or pcap_open_offline(). Not the raw adapter handle.
If all you want to is compile and not use the filter live, then
consider using pcap_open_nopcap().
--gv
==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe use
mailto: [EMAIL PROTECTED]
==================================================================