~ubuntu-branches/debian/sid/net-tools/sid

« back to all changes in this revision

Viewing changes to .pc/lib_local_changes.patch/lib/fddi.c

  • Committer: Package Import Robot
  • Author(s): Martín Ferrari
  • Date: 2015-09-07 01:54:07 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150907015407-v2tfsgxayjd3iq4i
Tags: 1.60+git20150829.73cef8a-1
* After 14 years without an upstream release, I am producing a new package
  based on today's upstream repository.
  Closes: #391495, #486448, #323261, #260587, #545328, #511395.
* Remove many patches now merged upstream, delete unmaintainable and
  undocumented local changes, and update the rest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * lib/fddi.c This file contains an implementation of the "FDDI"
3
 
 *              support functions.
4
 
 *
5
 
 * Version:     $Id: fddi.c,v 1.7 2000/03/05 11:26:02 philip Exp $
6
 
 *
7
 
 * Author:      Lawrence V. Stefani, <stefani@lkg.dec.com>
8
 
 *
9
 
 * 1998-07-01 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> GNU gettext
10
 
 *
11
 
 *              This program is free software; you can redistribute it
12
 
 *              and/or  modify it under  the terms of  the GNU General
13
 
 *              Public  License as  published  by  the  Free  Software
14
 
 *              Foundation;  either  version 2 of the License, or  (at
15
 
 *              your option) any later version.
16
 
 */
17
 
#include "config.h"
18
 
 
19
 
#include <features.h>
20
 
 
21
 
#if HAVE_HWFDDI
22
 
#include <sys/types.h>
23
 
#include <sys/socket.h>
24
 
#include <net/if_arp.h>
25
 
#ifndef ARPHRD_FDDI
26
 
#error "No FDDI Support in your current Kernelsource Tree."
27
 
#error "Disable HW Type FDDI"
28
 
#endif
29
 
#if __GLIBC__ >= 2
30
 
#include <netinet/if_fddi.h>
31
 
#else
32
 
#include <linux/if_fddi.h>
33
 
#endif
34
 
#include <stdlib.h>
35
 
#include <stdio.h>
36
 
#include <errno.h>
37
 
#include <ctype.h>
38
 
#include <string.h>
39
 
#include <unistd.h>
40
 
#include "net-support.h"
41
 
#include "pathnames.h"
42
 
#include "intl.h"
43
 
#include "util.h"
44
 
 
45
 
extern struct hwtype fddi_hwtype;
46
 
 
47
 
 
48
 
/* Display an FDDI address in readable format. */
49
 
static char *pr_fddi(unsigned char *ptr)
50
 
{
51
 
    static char buff[64];
52
 
 
53
 
    snprintf(buff, sizeof(buff), "%02X-%02X-%02X-%02X-%02X-%02X",
54
 
             (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
55
 
             (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
56
 
        );
57
 
    return (buff);
58
 
}
59
 
 
60
 
 
61
 
/* Input an FDDI address and convert to binary. */
62
 
static int in_fddi(char *bufp, struct sockaddr *sap)
63
 
{
64
 
    unsigned char *ptr;
65
 
    char c, *orig;
66
 
    int i, val;
67
 
 
68
 
    sap->sa_family = fddi_hwtype.type;
69
 
    ptr = sap->sa_data;
70
 
 
71
 
    i = 0;
72
 
    orig = bufp;
73
 
    while ((*bufp != '\0') && (i < FDDI_K_ALEN)) {
74
 
        val = 0;
75
 
        c = *bufp++;
76
 
        if (isdigit(c))
77
 
            val = c - '0';
78
 
        else if (c >= 'a' && c <= 'f')
79
 
            val = c - 'a' + 10;
80
 
        else if (c >= 'A' && c <= 'F')
81
 
            val = c - 'A' + 10;
82
 
        else {
83
 
#ifdef DEBUG
84
 
            fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
85
 
#endif
86
 
            errno = EINVAL;
87
 
            return (-1);
88
 
        }
89
 
        val <<= 4;
90
 
        c = *bufp++;
91
 
        if (isdigit(c))
92
 
            val |= c - '0';
93
 
        else if (c >= 'a' && c <= 'f')
94
 
            val |= c - 'a' + 10;
95
 
        else if (c >= 'A' && c <= 'F')
96
 
            val |= c - 'A' + 10;
97
 
        else {
98
 
#ifdef DEBUG
99
 
            fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
100
 
#endif
101
 
            errno = EINVAL;
102
 
            return (-1);
103
 
        }
104
 
        *ptr++ = (unsigned char) (val & 0377);
105
 
        i++;
106
 
 
107
 
        /* We might get a semicolon here - not required. */
108
 
        if (*bufp == ':') {
109
 
            if (i == FDDI_K_ALEN) {
110
 
#ifdef DEBUG
111
 
                fprintf(stderr, _("in_fddi(%s): trailing : ignored!\n"),
112
 
                        orig)
113
 
#endif
114
 
                    ;           /* nothing */
115
 
            }
116
 
            bufp++;
117
 
        }
118
 
    }
119
 
 
120
 
    /* That's it.  Any trailing junk? */
121
 
    if ((i == FDDI_K_ALEN) && (*bufp != '\0')) {
122
 
#ifdef DEBUG
123
 
        fprintf(stderr, _("in_fddi(%s): trailing junk!\n"), orig);
124
 
        errno = EINVAL;
125
 
        return (-1);
126
 
#endif
127
 
    }
128
 
#ifdef DEBUG
129
 
    fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
130
 
#endif
131
 
 
132
 
    return (0);
133
 
}
134
 
 
135
 
 
136
 
struct hwtype fddi_hwtype =
137
 
{
138
 
    "fddi", NULL, /*"Fiber Distributed Data Interface (FDDI)", */ ARPHRD_FDDI, FDDI_K_ALEN,
139
 
    pr_fddi, in_fddi, NULL
140
 
};
141
 
 
142
 
 
143
 
#endif                          /* HAVE_HWFDDI */