XINU
Functions
xsh_arp.c File Reference
#include <xinu.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for xsh_arp.c:

Go to the source code of this file.

Functions

static void arp_dmp ()
 
shellcmd xsh_arp (int nargs, char *args[])
 

Function Documentation

◆ arp_dmp()

static void arp_dmp ( )
static

Definition at line 37 of file xsh_arp.c.

References AR_FREE, AR_PENDING, AR_RESOLVED, arpentry::arhaddr, ARP_HALEN, ARP_SIZ, arpentry::arpaddr, arpcache, arpentry::arpid, arpentry::arstate, and printf().

Referenced by xsh_arp().

38 {
39  int32 i, j; /* index into the ARP table */
40  struct arpentry *arptr; /* pointer to entry in cache */
41 
42  /* Print entries from the ARP table */
43 
44  printf("ARP cache:\n");
45  printf(" State Pid IP Address Hardware Address\n");
46  printf(" ----- --- --------------- -----------------\n");
47  for (i = 0; i < ARP_SIZ; i++) {
48  arptr = &arpcache[i];
49  if (arptr->arstate == AR_FREE) {
50  continue;
51  }
52  switch(arptr->arstate) {
53  case AR_PENDING: printf(" PEND "); break;
54  case AR_RESOLVED: printf(" RESLV"); break;
55  default: printf(" ?????"); break;
56  }
57  if (arptr->arstate == AR_PENDING) {
58  printf("%4d ", arptr->arpid);
59  } else {
60  printf(" ");
61  }
62  printf("%3d.", (arptr->arpaddr & 0xFF000000) >> 24);
63  printf("%3d.", (arptr->arpaddr & 0x00FF0000) >> 16);
64  printf("%3d.", (arptr->arpaddr & 0x0000FF00) >> 8);
65  printf("%3d", (arptr->arpaddr & 0x000000FF));
66 
67  printf(" %02X", arptr->arhaddr[0]);
68  for (j = 1; j < ARP_HALEN; j++) {
69  printf(":%02X", arptr->arhaddr[j]);
70  }
71  printf("\n");
72  }
73  printf("\n");
74  return;
75 }
#define AR_FREE
ARPキャッシュエントリ状態:スロットが未使用
Definition: arp.h:27
#define ARP_SIZ
キャシュ中のエントリ数
Definition: arp.h:20
int32 printf(const char *,...)
Definition: printf.c:13
int32 arstate
エントリの状態
Definition: arp.h:75
struct arpentry arpcache[]
ARPキャッシュエントリテーブル
Definition: arp.c:5
uint32 arpaddr
エントリのIPアドレス
Definition: arp.h:77
#define ARP_HALEN
EthernetのMACアドレスサイズ
Definition: arp.h:8
ARPキャッシュエントリ
Definition: arp.h:72
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
byte arhaddr[ARP_HALEN]
エントリのEthernetアドレス
Definition: arp.h:81
#define AR_RESOLVED
ARPキャッシュエントリ状態:エントリが正常
Definition: arp.h:31
pid32 arpid
待機中プロセスか-1
Definition: arp.h:79
#define AR_PENDING
ARPキャッシュエントリ状態:解決中
Definition: arp.h:29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xsh_arp()

shellcmd xsh_arp ( int  nargs,
char *  args[] 
)

Definition at line 12 of file xsh_arp.c.

References arp_dmp(), printf(), and strncmp().

13 {
14  /* For argument '--help', emit help about the 'arp' command */
15 
16  if (nargs == 2 && strncmp(args[1], "--help", 7) == 0) {
17  printf("Use: %s\n\n", args[0]);
18  printf("Description:\n");
19  printf("\tDisplays information from the ARP cache\n");
20  printf("Options:\n");
21  printf("\t--help\t display this help and exit\n");
22  return 0;
23  }
24 
25  /* Dump the Entire ARP cache */
26  printf("\n");
27  arp_dmp();
28 
29  return 0;
30 }
int32 strncmp(const char *, const char *, int32)
int32 printf(const char *,...)
Definition: printf.c:13
static void arp_dmp()
Definition: xsh_arp.c:37
Here is the call graph for this function: