Hello,

Am intercepting v4 packets from a sol m/c and building a v6 equivalent of it 
and re-injecting the packet. Am using pfil to intercept packets and developing 
the rest of the code on top of pfil itself.

I have crafted and re-injected the v6 packet from my sol box and i snooped 
through the box to see that the packets are sent out from the sol box. However, 
none of these packets reach my destination sol box. Both the sol m/cs are in 
the same subnet.

Brief on what was done: 
stripped the MAC header from the original mbuf and moved the rptr ( of original 
mbuf ) to point to the TCP header. Created a v6 header. Then linked MAC<->v6 
header <->original mbuf with rptr poiting to TCP header.

Snippet :
                 /* Allocate mem for v6 header */
                if ((v6blk = (mblk_t *)allocb(40, BPRI_HI)) == NULL)
                        cmn_err(CE_NOTE, "OOM - can't create v6 pkt");
                
                /* Memory for MAC header */
                if ((e_blk = (mblk_t *)allocb(14, BPRI_HI)) == NULL)
                        cmn_err(CE_NOTE, "OOM - can't create ETHERNET pkt");

                MTYPE(e_blk) = M_DATA;
                e_hdr = (struct ether_header *)e_blk->b_rptr;
                e_blk->b_wptr = e_blk->b_rptr + 14;

                /* Create the MAC header with ETHER TYPE as 0x86dd */
                /* off points to the length of the MAC header */
                if ( off > 0 ){
                        e_hdr_src = (struct ether_header *)mt->b_rptr;
                        e_hdr->ether_shost = e_hdr_src->ether_shost;
                        e_hdr->ether_dhost = e_hdr_src->ether_dhost;
                        e_hdr->ether_type = htons(ETHERTYPE_IPV6);
                }
                mt->b_rptr +=off;               /* mt is the original mbuf */
                mt->b_rptr +=iphlen;           /* b_rptr moved to point to TCP 
header */
                if ( mt->b_rptr > mt->b_wptr )
                        cmn_err(CE_NOTE, "JUST CHECKING - POINTER IS WRONG");

                MTYPE(v6blk) = M_DATA;
                v6 = (ip6_t *)v6blk->b_rptr;
                lenin->b_wptr = v6blk->b_rptr + 40;
                v6->ip6_flow = 0x0;
                v6->ip6_plen = htons(ip->ip_len - iphlen);
                if ( ip->ip_p == 1 )
                        v6->ip6_nxt = IPPROTO_ICMPV6;
                else
                        v6->ip6_nxt = ip->ip_p;
                v6->ip6_hlim = 127;
                v6->ip6_vfc = 0x60;

                /* Set the source & destination addresss */
                result = inet_pton(AF_INET6,source,&src6);
                if ( result != 1 )
                        cmn_err(CE_NOTE, "DIDNT SET PROPERLY SOURCE ADDRESS\n");
                result = inet_pton(AF_INET6,dest, &dst6);

                if ( result != 1 )
                        cmn_err(CE_NOTE, "DIDNT SET PROPERLY DEST ADDRESS\n");
                v6->ip6_src = src6;
                v6->ip6_dst = dst6;

                linkb(e_blk,v6blk);
                linkb(v6blk,mt);
                tcp->th_sum = 0;
                tcp->th_sum = tcp6_cksum(v6,tcp,(ip->ip_len - iphlen));
                *mp = e_blk;
        }

Packet that's sent out of the source sol machine is completely fine as far as 
the snoop is concerned. I ensured through Ethereal that the packet doesn't have 
any checksum errors or so. What else could be wrong that the packets are not 
seen on the destination ? Is there anything wrong in the way that the packet is 
constructed above ? If the packets are sent out from the source sol box, is 
there still a possibility that the packet is not constructed properly on the 
source box ? 

A sample output from snoop:
ETHER:  ----- Ether Header -----
ETHER:
ETHER:  Packet 1 arrived at 22:11:58.41633
ETHER:  Packet size = 86 bytes
ETHER:  Destination = 0:d:ed:8a:a8:0,
ETHER:  Source      = 0:3:ba:c0:8e:95,
ETHER:  Ethertype = 86DD (IPv6)
ETHER:
IPv6:   ----- IPv6 Header -----
IPv6:
IPv6:   Version = 6
IPv6:   Traffic Class = 0
IPv6:   Flow label = 0x0
IPv6:   Payload length = 32
IPv6:   Next Header = 6 (TCP)
IPv6:   Hop Limit = 127
IPv6:   Source address = 2001:410:0:1:203:baff:fec0:8e95
IPv6:   Destination address = 2001:410:0:1:214:4fff:fe3c:4ac0
IPv6:
TCP:  ----- TCP Header -----
TCP:
TCP:  Source port = 32855
TCP:  Destination port = 23 (TELNET)
TCP:  Sequence number = 4083205977
TCP:  Acknowledgement number = 0
TCP:  Data offset = 32 bytes
TCP:  Flags = 0x02
TCP:        0... .... = No ECN congestion window reduced
TCP:        .0.. .... = No ECN echo
TCP:        ..0. .... = No urgent pointer
TCP:        ...0 .... = No acknowledgement
TCP:        .... 0... = No push
TCP:        .... .0.. = No reset
TCP:        .... ..1. = Syn
TCP:        .... ...0 = No Fin
TCP:  Window = 49640
TCP:  Checksum = 0x4479
TCP:  Urgent pointer = 0
TCP:  Options: (12 bytes)
TCP:    - Maximum segment size = 1460 bytes
TCP:    - No operation
TCP:    - Window scale = 0
TCP:    - No operation
TCP:    - No operation
TCP:    - SACK permitted option
TCP:
TELNET:  ----- TELNET:   -----
TELNET:
TELNET:  ""
TELNET:

Can you give me some pointers  ?

Thanks !
 
 
This message posted from opensolaris.org
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to