Re: recvfrom

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the help. 
I decided to use the netlink socket to receive message
that the firewall (iptables) have queued for the user.
But i still have the problem that i can read anything
from the netlink socket i've opened. 
Following configuration was performed:
  - I have loaded the modules ip_queue.o,
iptable_filter.o and ip_tables.o.
  - iptables -I INPUT 1 -p icmp -j QUEUE ( At the
command line, for queueing all incoming ICMP packet).

A sample code:
int main(int argc, char** argv)
{
   int sockfd;
   unsigned char *buffer;
   struct cmsghdr cmsg;
   struct iovec iov;
   struct sockaddr_nl nladdr={
          nl_family:AF_NETLINK
   };
   struct msghdr msg = {
      (void *)&nladdr, sizeof(nladdr),
      &iov, 1, NULL, 1024, 0};

   if ((sockfd = socket(PF_NETLINK,
SOCK_DGRAM,NETLINK_FIREWALL)) < 0) {
      perror("netlink socket");
      return -1;
   }

   if (recvmsg(sockfd, &msg, 0) < 0) {
      perror("recvmsg");
      return -1;
   }

   close(sockfd);
   return 0;
}

I receive nothing in the netlink socket. Why ?

Best Regards.
 
--- Andi Kleen <ak@suse.de> schrieb: > On Wed, Apr 11,
2001 at 12:27:01PM -0400, Jason Lunz
> wrote:
> > ak@suse.de said:
> > >It's not possible using raw sockets, but you can
> do it via appropiate
> > >netfilter rules and the netfilter user queue
> target. Then all packets
> > >not reinjected by the user queue daemon will get
> lost. This is a 2.4
> > >solution.
> > 
> > True, but netfilter is IP-only AFAIK. I've hacked
> in a way to do this
> > for *all* protocols, but as far as I can tell, you
> can't do it without
> > dropping the skb before handing it off to the
> registered packet_types in
> > net_rx_action().
> 
> If you don't need receiving on the local box you
> could also do it via 
> ethertap device or packet socket on dummy device,
> and then reinject into the
> network. It'll not work for local packets though,
> because the routing
> code does not allow to route locally destined
> packets somewhere else.
> 
> 
> -Andi
> -
> : send the line
> "unsubscribe linux-net" in
> the body of a message to majordomo@vger.kernel.org


__________________________________________________________________
Do You Yahoo!?
Gesendet von Yahoo! Mail - http://mail.yahoo.de
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux