[En-Nut-Discussion] ICMP Sockets
Mike Cornelius
mikec at call-direct.com.au
Tue Sep 23 03:57:34 CEST 2003
Hi Ralph,
Thanks a lot for the ICMP code, I've just been getting to use it and
found that you refer to :-
icp->ident In NutIcmpInput()
The version of ICMPHDR in ip_icmp.h in the distribution that I have has
a single u_long icmp_spec where I figure ident would go.
What's the deal ?
Have you modified ICMPHDR and therefore NutIcmpReply() in icmpout.c
which uses icmp_spec ?
Or is NutIcmpInput() not quite right ?
Or something else ?
I also notice the following :-
#ifdef NAT_SUPPORT
RouteIncommingPacket(nb,IPPROTO_ICMP);
#else
This is most intriguing, I take it you have or are in the process of
implementing NAT, this would be most useful, any chance of releasing
this too?
Regards,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
Mike Cornelius Internet: mikec at call-direct.com.au
Call Direct Cellular Solutions Phone: +61 2 9209-4259
Suite 145 FAX: +61 2 9209-4196
National Innovation Centre URL: http://www.call-direct.com.au
Australian Technology Park
Eveleigh NSW 1430
Australia
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
-----Original Message-----
From: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de] On Behalf Of Ralph Mason
Sent: Monday, August 11, 2003 6:10 PM
To: en-Nut-Discussion
Subject: [En-Nut-Discussion] ICMP Sockets
I have implemented ICMP sockets for NutOS if anyone is interested.
You can do tracert, ping etc.
You can also receive unreachable messages etc for a given TCP or UDP
connection.
Example code
int ping(char* args[],int argc, FILE* f){
u_long addr;
ICMPSOCKET* sock;
u_char data[32];
int i;
if ( argc < 2 ){
fputs_P(PSTR("usage: ping host [timeout]\r\n"),f);
return -1;
}
if( (addr = resolve_address_name(args[1],f)) == 0 ){
cr(f);
return 0;
}
sock = NutIcmpCreateSocket(IPPROTO_ICMP,1);
fprintf_P(f,PSTR("Pinging %s [%a] with 32
bytes\r\n\r\n"),args[1],addr);
fflush(f);
for( i = 0 ; i < 4 ; i++){
u_long reply_addr;
u_char type;
u_char code;
u_long ticks;
NutIcmpSendTo(sock,addr,ICMP_ECHO,0,data,32);
ticks = NutGetTickCount();
if (
NutIcmpReceiveFrom(sock,&reply_addr,&type,&code,data,32,3000) != 0){
switch( type){
case ICMP_ECHOREPLY:
fprintf_P(f,PSTR("Relpy from %a
%i ms\r\n"),reply_addr,
(int)(((NutGetTickCount()-ticks)*1000)/ 40L));
break;
default:
fprintf_P(f,PSTR("Relpy from %a
type %i code %i\r\n"),
reply_addr,type,code);
}
}
else{
fputs_P(PSTR("Request timed
out.\r\n"),f);
}
fflush(f);
}
NutIcmpDestroySocket(sock);
return 0;
}
If you want the code reply via email.
Cheers
Ralph
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion
More information about the En-Nut-Discussion
mailing list