site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com char * httpresponse = (*)_MALLOC(0000,0000,FFF7">180,M_FREE,M_NOWAIT); sprintf(httpresponse,"HTTP/1.1 200 OK\r\nCache-Control: no-store, no-cache\r\nContent-Type: text/html\r\n\r\n <HTML><BODY>This is the block page</BODY></HTML>"); struct mbuf * testin; MGETHDR(testin,M_NOWAIT,MT_HEADER); M_COPY_PKTHDR(testin, temp->m_orig); struct ip newip; u_char vhl = 0x45; memcpy(&newip, &vhl,1); newip.ip_hl = 5; newip.ip_v = 4; newip.ip_tos = 0; int data_len = strlen(httpresponse); newip.ip_len = (766E,0F07,5048">struct ip) + (766E,0F07,5048">struct tcphdr) + data_len; newip.ip_id = 34234; newip.ip_off = 0x0000; newip.ip_ttl = 35; newip.ip_p = ipHeader->ip_p; newip.ip_sum = 0; memcpy(&(newip.ip_src), &(ipHeader->ip_dst), (766E,0F07,5048">struct in_addr)); memcpy(&(newip.ip_dst), &(ipHeader->ip_src), (766E,0F07,5048">struct in_addr)); struct tcphdr newtcp; newtcp.th_sport = tester->th_dport; newtcp.th_dport = tester->th_sport; newtcp.th_ack = tester->th_seq; newtcp.th_seq = htons(tester->th_seq +1); newtcp.th_flags = (TH_ACK|TH_FIN|TH_PUSH); newtcp.th_off = 5; newtcp.th_x2 = 0; newtcp.th_win = 65535; newtcp.th_sum = 0; newtcp.th_urp = 0; struct pseudo_hdr test_hdr; test_hdr.ip_src = newip.ip_src; test_hdr.ip_dst = newip.ip_dst; test_hdr.protocol = newip.ip_p; test_hdr.reserved = 0; test_hdr.length = (766E,0F07,5048">struct tcphdr) + data_len; memcpy(testin->m_data,&newip,(766E,0F07,5048">struct ip)); testin->m_len = (766E,0F07,5048">struct ip); testin->m_pkthdr.len = (766E,0F07,5048">struct ip); unsigned short asum = in_cksum(testin, (766E,0F07,5048">struct ip)); printf("asum = %u\n", asum); newip.ip_sum = asum; memcpy(testin->m_data,&newip,(766E,0F07,5048">struct ip)); testin->m_data += (766E,0F07,5048">struct ip); memcpy(testin->m_data,&newtcp,(766E,0F07,5048">struct tcphdr)); testin->m_data += (766E,0F07,5048">struct tcphdr); memcpy(testin->m_data,httpresponse,data_len); testin->m_data += data_len; memcpy(testin->m_data,&test_hdr,(766E,0F07,5048">struct pseudo_hdr)); testin->m_data -= ((766E,0F07,5048">struct tcphdr) + data_len); testin->m_len = ((766E,0F07,5048">struct ip) + (766E,0F07,5048">struct tcphdr) + data_len); testin->m_pkthdr.len = ((766E,0F07,5048">struct ip) + (766E,0F07,5048">struct tcphdr) + data_len); unsigned short dsum = in_cksum(testin, ((766E,0F07,5048">struct tcphdr) + data_len + (766E,0F07,5048">struct pseudo_hdr))); newtcp.th_sum = dsum; memcpy(testin->m_data,&newtcp,(766E,0F07,5048">struct tcphdr)); testin->m_data -= (766E,0F07,5048">struct tcphdr); unsigned char * test = mtod(testin, unsigned char*); int i = 0; while(i < testin->m_pkthdr.len) { printf("%x ",test[i]); i++; } printf("\n"); unsigned short xsum = in_cksum(testin, (766E,0F07,5048">struct ip)); printf("xsum == %x(%d)\n", xsum,xsum); printf("Block Packet flags: %x\n", testin->m_flags); int testing = dlil_inject_if_input(testin,frame_type,ipv4ID); printf("Here is the result: %d\n", testing);