hello,
Am filtering the v4 packets and rewriting them as v6 pkts and vice versa when i
get a response from the v6 target. I have a problem when i reconstruct my v4
pkt from the received v6 pkts.
It's pretty difficult to debug at the ip layer. Tried some dtrace scripts as
well to check out the ip_rput* entries and return but no help.
Guess my reconstructed v4 packet is not formed correctly. But there's no way to
ensure that this is infact the reason. Here's the code that recreates v4 pkt
from the received mblk_t.
/* create a v4 header and replace the v6 header */
if ((v4mblk = (mblk_t *)allocb(20, BPRI_HI)) == NULL)
cmn_err(CE_NOTE, "NO MEMORY TO CREATE V4 HDR\n");
/* Set the data type and arrange the pointers appropriately */
MTYPE(v4mblk) = M_DATA;
v4mblk->b_wptr = v4mblk->b_rptr + 20;
v4hdr = (struct ip *)v4mblk->b_rptr;
m->b_rptr = m->b_rptr + 40; /* Shift to tcp header, m is orig
mblk_t */
tcp = (struct tcphdr *)m->b_rptr;
/* Now create the header values for the v4 */
/* Set the source address which is destination IP*/
/* Test for a single source / destination first */
v4hdr->ip_src.s_net = 1;
v4hdr->ip_src.s_host = 1;
v4hdr->ip_src.s_lh = 1;
v4hdr->ip_src.s_impno = 104;
/* Set the destination ip address which is the current adds */
v4hdr->ip_dst.s_net = 10;
v4hdr->ip_dst.s_host = 77;
v4hdr->ip_dst.s_lh = 209;
v4hdr->ip_dst.s_impno = 78;
/* Set the header length of IPv4 */
v4hdr->ip_hl = sizeof(*v4hdr)>>2;
cmn_err(CE_NOTE, "IP header lenght is: %d\n", v4hdr->ip_hl);
/* Protocol in the ip datagram */
v4hdr->ip_p = IPPROTO_TCP;
/* Total length of the packet. Includes TCP hdr + data too */
v4hdr->ip_len = sizeof(*v4hdr) + sizeof(*tcp);
cmn_err(CE_NOTE, "IP length is: %d\n", v4hdr->ip_len);
v4hdr->ip_tos = 0;
v4hdr->ip_id = 0;
v4hdr->ip_ttl = 15;
/* Set the version */
v4hdr->ip_v = 4;
cmn_err(CE_NOTE, "IP Version is: %d\n", v4hdr->ip_v);
/* No fragmentation */
v4hdr->ip_off = 0x04;
/* Calculate the checksum */
v4hdr->ip_sum = 0;
v4hdr->ip_sum = ipf_cksum((u_short *)v4hdr, sizeof(*v4hdr));
cmn_err(CE_NOTE, "IP Checksum is: %x\n", v4hdr->ip_sum);
linkb(v4mblk,m); /* Link the newly const v4 and tcp */
if (tcp != NULL){
cmn_err(CE_NOTE, "Source port is: %d\n", tcp->th_sport);
cmn_err(CE_NOTE, "Dest port is: %d\n", tcp->th_dport);
tcp->th_sum = fr_cksum(v4mblk,v4hdr,IPPROTO_TCP,
tcp,
v4hdr->ip_len
);
cmn_err(CE_NOTE,"TCP CKsum is: %x\n", tcp->th_sum);
}
*mp = v4mblk; /* mp has a pointer to the original mbuf that's
putnext */
Any pointers will really be helpful.
Thanks!
This message posted from opensolaris.org
_______________________________________________
networking-discuss mailing list
[email protected]