site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Matt, On Sep 18, 2004, at 20:26, Matt Jaffa wrote: That's the way to bet. Don't forget to free this. struct mbuf * testin; MGET(testin,M_NOWAIT,M_MBUF); newip.ip_hl = 5; printf("ipHeader version: %d\n", ipHeader->ip_v); printf("ipHeader hdrleng: %d\n", ipHeader->ip_hl); printf("newipheader: %d\n", newip.ip_v); printf("newipheader: %d\n", newip.ip_hl); newip.ip_v = 4;//ipHeader->ip_v; I assume 'tester' is set up as something valid. 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 = sizeof(struct tcphdr); newtcp.th_x2 = 0; newtcp.th_win = 65535; newtcp.th_sum = 0; newtcp.th_urp = 0; What does this do? Why? [snip] Regards, Justin -- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | When LuteFisk is outlawed | Only outlaws will have | LuteFisk *--------------------------------------*-------------------------------* _______________________________________________ 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... If you are serious about doing this kind of programming, you really have to work harder at learning the area. We are happy to help you with problems, but it's no fun trying to teach you what you should be learning on your own. Is my mbuf set up wrong?? char * httpresponse = (char*)_MALLOC(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>"); What is 'M_MBUF'? What is 'M_NOWAIT'? Are these valid arguments to MGET? Is MGET the right call? It would seem that you are building a "complete" frame, so I would think you need a "packet header" mbuf (which you don't get with MGET). (This is discussed in Stevens' "TCP/IP Illustrated, V2"). struct ip newip;// = (struct ip*)_MALLOC(sizeof(struct ip),M_FREE,M_NOWAIT); u_char vhl = 0x45; memcpy(&newip, &vhl,1); This may not do what you think (if this is supposed to be more than a quick hack, don't be sloppy). Why do this and then use ip_hl and ip_v? [snip] struct tcphdr newtcp;// = (struct tcphdr*)_MALLOC(sizeof(struct tcphdr),M_FREE,M_NOWAIT); newtcp.th_sport = tester->th_dport; newtcp.th_dport = tester->th_sport; testin->m_data += 20; Does the 'dump' show a valid packet? You might also print out the beginning of the mbuf structure (i.e, all the bytes from 'testin' to the end of the data). Any help on the mbuf injecting and the Seq and Ack would be great thanks. I think you have not set up the mbuf correctly (it needs to be a "packet header" mbuf). As for the seq/ack values, you should sit down with Stevens and go through the discussion related to this. We could show you how to hack this, but you need to understand what you are doing. It isn't difficult, and it's worth the investment of an hour of your time. This email sent to site_archiver@lists.apple.com
participants (1)
-
Justin Walker