[En-Nut-Discussion] Ping

Ralf Spettel r.spettel at raumcomputer.com
Mon Nov 21 15:29:27 CET 2005


Hello Ralph,
where can I find the 'NutIcmpReply' with seven parameters, which is called 
from your 'NutIcmpSendTo' in the sample below ?
The original 'NutIcmpReply' has only five parameters..

The 'NutIcmpSendTo'  was found at http://www.ethernut.de/arc/rm-icmp.zip

Ralf



>I have a full and stable ICMP sockets implementation that I have been 
>using for about 12 months.
>
>I wonder if it's time that this gets integrated into the main ether nut 
>distribution
>
>example ping 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("Reply from %a %i 
> ms\r\n"),reply_addr,(int)(((NutGetTickCount()-ticks)*1000)/ 40L));
>                    break;
>
>                default:
>                    fprintf_P(f,PSTR("Reply 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;
>}
>
>
>Ralph
>
>>Hi
>>
>>Does that mean I have to modify the NutIcmpInput function? Is there no
>>possibility to do such thing without modifying NutOS?
>>
>>bye
>>Thorsten
>>
>>
>>
>>>modification  file icmpin.c
>>>//**********************************************
>>>void NutIcmpInput(NUTDEVICE * dev, NETBUF * nb)
>>>{
>>>
>>
>>_______________________________________________
>>En-Nut-Discussion mailing list
>>En-Nut-Discussion at egnite.de
>>http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>>
>>
>>
>
>_______________________________________________
>En-Nut-Discussion mailing list
>En-Nut-Discussion at egnite.de
>http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion


Mit freundlichen Grüssen
Ralf Spettel

_________________________________________________
Dipl.Ing. Ralf Spettel
Embedded Systems Engineer
RaumComputer AG
Abt. Hardwareentwicklung
Augartenstrasse 1
76137 Karlsruhe, Germany
T: +49 721 / 989600-84
F: +49 721 / 989600-98
r.spettel at raumcomputer.com
_________________________________________________




More information about the En-Nut-Discussion mailing list