~ubuntu-branches/ubuntu/warty/net-tools/warty

« back to all changes in this revision

Viewing changes to arp.c

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Eckenfels
  • Date: 2004-04-23 00:57:20 UTC
  • Revision ID: james.westby@ubuntu.com-20040423005720-q36dnihblq1oa5j3
Tags: 1.60-10
* typo fix in po/de.po for german arp command output (Closes: Bug #176151)
* added diagnostics messages to mii-tool.8 (Closes: Bug #239229)
* new version of nstrcmp (Closes: Bug #226503)
* enable EUI64 support
* stadanrds version 3.6.1 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *              NET-3 Networking Distribution for the LINUX operating
9
9
 *              system.
10
10
 *
11
 
 * Version:     $Id: arp.c,v 1.20 2001/04/08 17:05:05 pb Exp $
 
11
 * Version:     $Id: arp.c,v 1.23 2003/02/08 19:56:25 ecki Exp $
12
12
 *
13
13
 * Maintainer:  Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
14
14
 *
102
102
    struct arpreq req;
103
103
    struct sockaddr sa;
104
104
    int flags = 0;
105
 
    int err;
 
105
    int deleted = 0;
106
106
 
107
107
    memset((char *) &req, 0, sizeof(req));
108
108
 
190
190
        }
191
191
        usage();
192
192
    }
 
193
 
 
194
    // if neighter priv nor pub is given, work on both
193
195
    if (flags == 0)
194
196
        flags = 3;
195
197
 
196
198
    strcpy(req.arp_dev, device);
197
199
 
198
 
    err = -1;
 
200
    /* unfortuatelly the kernel interface does not allow us to
 
201
       delete private entries anlone, so we need this hack
 
202
       to avoid "not found" errors if we try both. */
 
203
    deleted = 0;
199
204
 
200
205
    /* Call the kernel. */
201
206
    if (flags & 2) {
202
207
        if (opt_v)
203
208
            fprintf(stderr, "arp: SIOCDARP(nopub)\n");
204
 
        if ((err = ioctl(sockfd, SIOCDARP, &req) < 0)) {
205
 
            if (errno == ENXIO) {
 
209
        if (ioctl(sockfd, SIOCDARP, &req) < 0) {
 
210
            if ((errno == ENXIO) || (errno == ENOENT)) {
206
211
                if (flags & 1)
207
212
                    goto nopub;
208
213
                printf(_("No ARP entry for %s\n"), host);
209
214
                return (-1);
210
215
            }
211
 
            perror("SIOCDARP(priv)");
 
216
            perror("SIOCDARP(nopub)");
212
217
            return (-1);
213
 
        }
 
218
        } else
 
219
          deleted = 1;
214
220
    }
215
 
    if ((flags & 1) && (err)) {
 
221
    if (!deleted && (flags & 1)) {
216
222
      nopub:
217
223
        req.arp_flags |= ATF_PUBL;
218
224
        if (opt_v)
219
225
            fprintf(stderr, "arp: SIOCDARP(pub)\n");
220
226
        if (ioctl(sockfd, SIOCDARP, &req) < 0) {
221
 
            if (errno == ENXIO) {
 
227
            if ((errno == ENXIO) || (errno == ENOENT)) {
222
228
                printf(_("No ARP entry for %s\n"), host);
223
229
                return (-1);
224
230
            }
463
469
 
464
470
    if (!(arp_flags & ATF_COM)) {
465
471
        if (arp_flags & ATF_PUBL)
466
 
            printf("%-8.8s%-20.20s", "*", "*");
 
472
            printf("%-8.8s%-20.20s", "*", _("<from_interface>"));
467
473
        else
468
474
            printf("%-8.8s%-20.20s", "", _("(incomplete)"));
469
475
    } else {
486
492
 
487
493
    if (!(arp_flags & ATF_COM)) {
488
494
        if (arp_flags & ATF_PUBL)
489
 
            printf("* ");
 
495
            printf("<from_interface> ");
490
496
        else
491
497
            printf(_("<incomplete> "));
492
498
    } else {
499
505
    if (arp_flags & ATF_PERM)
500
506
        printf("PERM ");
501
507
    if (arp_flags & ATF_PUBL)
502
 
        printf("PUP ");
 
508
        printf("PUB ");
503
509
#ifdef HAVE_ATF_MAGIC
504
510
    if (arp_flags & ATF_MAGIC)
505
511
        printf("AUTO ");
613
619
{
614
620
    fprintf(stderr, _("Usage:\n  arp [-vn]  [<HW>] [-i <if>] [-a] [<hostname>]             <-Display ARP cache\n"));
615
621
    fprintf(stderr, _("  arp [-v]          [-i <if>] -d  <hostname> [pub][nopub]    <-Delete ARP entry\n"));
616
 
    fprintf(stderr, _("  arp [-vnD] [<HW>] [-i <if>] -f  [<filename>]              <-Add entry from file\n"));
 
622
    fprintf(stderr, _("  arp [-vnD] [<HW>] [-i <if>] -f  [<filename>]            <-Add entry from file\n"));
617
623
    fprintf(stderr, _("  arp [-v]   [<HW>] [-i <if>] -s  <hostname> <hwaddr> [temp][nopub] <-Add entry\n"));
618
 
    fprintf(stderr, _("  arp [-v]   [<HW>] [-i <if>] -s  <hostname> <hwaddr> [netmask <nm>] pub  <-''-\n"));
619
624
    fprintf(stderr, _("  arp [-v]   [<HW>] [-i <if>] -Ds <hostname> <if> [netmask <nm>] pub      <-''-\n\n"));
620
625
    
621
626
    fprintf(stderr, _("        -a                       display (all) hosts in alternative (BSD) style\n"));