Re: dlil_inject_if_input
Re: dlil_inject_if_input
- Subject: Re: dlil_inject_if_input
- From: Justin Walker <email@hidden>
- Date: Sat, 18 Sep 2004 21:30:39 -0700
Matt,
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.
On Sep 18, 2004, at 20:26, Matt Jaffa wrote:
Is my mbuf set up wrong??
That's the way to bet.
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>");
Don't forget to free this.
struct mbuf * testin;
MGET(testin,M_NOWAIT,M_MBUF);
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?
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;
[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;
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;
testin->m_data += 20;
What does this do? Why?
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).
[snip]
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.
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden