Question about IPIP + SOCK_PACKET

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

 



Hello, Sam And Linux-Net-izens....
I have a question about IPIP + SOCK_PACKET....
I want to process all of IP-in-IP Encapsulated packet
    outgoing as well as incoming ....
I used SOCK_PACKET and recvfrom() ....
partial source codes are below ....
 
I succeeded in getting all of outgoing IP-in-IP packet ....
But I could not get any incoming IP-in-IP packet ....
Does IPIP module decapsulate incoming IP-in-IP packet
    before recvfrom() by SOCK_PACKET ?
If IPIP does act as above, how can I get incoming IP-in-IP packet ?
   
Any comments are really appreciated ....  
Thanks in advance ....
 
================================================================
cf. data->buf[12] = 8;
     data->buf[13] = 0;   /* 0x80         IP Packet type (Ethernet Frame) */
     data->buf[23] = 4;   /* IPPROTO_IPIP */
 
================================================================
/* Partial Source Code */ 
    unsigned char buf[MAXDLBUF];
    struct strbuf data;    
        /* struct strbuf {
                int len;
                char *buf;
                int maxlen;
         } */
    int flags;
    int i, fd, maxfd;
    fd_set fdvec;
    struct timeval tv;
    struct sockaddr from;
    int fromlen, len;
 
if ((fd = socket(AF_INET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) {
        printf("Error_in_opening_SOCK_PACKET_socket_for_agent_adv_..\n");
        exit(-1);
    }
 
    data.buf = (char *) buf;
    data.maxlen = MAXDLBUF;
 
    /* Read packets.*/
    while (1) {
        tv.tv_sec = 0;
        tv.tv_usec = 0;
 
        FD_ZERO(&fdvec);
        FD_SET(fd, &fdvec);
        maxfd = fd+1;
 
        if ((i = select(maxfd, &fdvec, NULL, NULL, &tv)) < 0) {
            if ((errno != EINTR) && (errno != ERESTART)) {
                printf("select_failed_but_not_due_to_EINTR_or_ERESTART_\n"); 
         } else {
                printf("select_failed_due_to_EINTR_or_ERESTART\n");
            }
        } else if (FD_ISSET(fd, &fdvec)) {
            data.len = MAXDLBUF;
            fromlen = sizeof(struct sockaddr);
            do {
                len = recvfrom(fd, buf, data.len, 0, &from, &fromlen);
            } while ((len < 0) && (errno == EINTR));
 
            if (len < 0) {
                printf("Recvfrom_failed_in_monitor()\n");
            } else {
                data.len = len;
               
                blah~ blah~ blah~ 
                               
-------------------------------------
Park, Hyun Seo
Graduate Student
Department of Computer Engineering, Chungnam National University
220 Gung-dong,YuSeong-Gu, Taejon, 305764, Korea
E-mail:
hspark@ce.cnu.ac.kr
ICQ # : 28055093  
Phone : +82-42-823-6049

[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