#include <xinu.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
◆ xsh_ping()
shellcmd xsh_ping |
( |
int |
nargs, |
|
|
char * |
args[] |
|
) |
| |
Definition at line 11 of file xsh_ping.c.
References dnslookup(), dot2ip(), FALSE, fprintf(), ICMP_ECHOREQST, icmp_recv(), icmp_register(), icmp_release(), icmp_send(), printf(), stderr, strlen(), strncmp(), SYSERR, TIMEOUT, and TRUE.
24 if (nargs == 2 &&
strncmp(args[1],
"--help", 7) == 0) {
25 printf(
"Use: %s address\n\n", args[0]);
27 printf(
"\tUse ICMP Echo to ping a remote host\n");
29 printf(
"\t--help\t display this help and exit\n");
30 printf(
"\taddress\t an IP address in dotted decimal\n");
44 for(i = 0; i <
strlen(args[1]); i++) {
45 if( ( (args[1][i] >= 65) && (args[1][i] <= 90) ) ||
46 ( (args[1][i] >= 97) && (args[1][i] <= 122)) ) {
58 printf(
"Pinging %d.%d.%d.%d\n", (ipaddr>>24)&0xff,
66 retval =
dot2ip(args[1], &ipaddr);
85 for (i = 0; i<
sizeof(buf); i++) {
86 buf[i] = 0xff & nextval++;
91 seq++, buf,
sizeof(buf));
93 fprintf(
stderr,
"%s: no response from host %s\n", args[0], args[1]);
100 retval =
icmp_recv(slot, buf,
sizeof(buf), 3000);
108 if (retval !=
sizeof(buf)) {
110 sizeof(buf), retval);
status icmp_release(int32)
int32 strncmp(const char *, const char *, int32)
int strlen(char *str)
NULL終端された文字列の長さを返す。NULL終端は長さに含まない。
int32 printf(const char *,...)
#define TIMEOUT
システムコールがタイムアウトした場合
status icmp_send(uint32, uint16, uint16, uint16, char *, int32)
int32 icmp_recv(int32, char *, int32, uint32)
int32 icmp_register(uint32)
#define FALSE
Boolean False(0)
#define TRUE
Boolean True(1)
int int32
符号あり32ビット整数(int)
int32 fprintf(int, char *,...)
unsigned int uint32
符号なし32ビット整数(unsigned int)
uint32 dot2ip(char *, uint32 *)