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

« back to all changes in this revision

Viewing changes to 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:
26
26
#error "No FDDI Support in your current Kernelsource Tree."
27
27
#error "Disable HW Type FDDI"
28
28
#endif
29
 
#include <linux/types.h>
30
29
#if __GLIBC__ >= 2
31
30
#include <netinet/if_fddi.h>
32
31
#else
47
46
 
48
47
 
49
48
/* Display an FDDI address in readable format. */
50
 
static char *pr_fddi(unsigned char *ptr)
 
49
static const char *pr_fddi(const char *ptr)
51
50
{
52
51
    static char buff[64];
53
52
 
58
57
    return (buff);
59
58
}
60
59
 
 
60
#ifdef DEBUG
 
61
#define _DEBUG 1
 
62
#else
 
63
#define _DEBUG 0
 
64
#endif
61
65
 
62
66
/* Input an FDDI address and convert to binary. */
63
67
static int in_fddi(char *bufp, struct sockaddr *sap)
64
68
{
65
 
    unsigned char *ptr;
 
69
    char *ptr;
66
70
    char c, *orig;
67
71
    int i, val;
68
72
 
81
85
        else if (c >= 'A' && c <= 'F')
82
86
            val = c - 'A' + 10;
83
87
        else {
84
 
#ifdef DEBUG
85
 
            fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
86
 
#endif
 
88
            if (_DEBUG)
 
89
                fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
87
90
            errno = EINVAL;
88
91
            return (-1);
89
92
        }
96
99
        else if (c >= 'A' && c <= 'F')
97
100
            val |= c - 'A' + 10;
98
101
        else {
99
 
#ifdef DEBUG
100
 
            fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
101
 
#endif
 
102
            if (_DEBUG)
 
103
                fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
102
104
            errno = EINVAL;
103
105
            return (-1);
104
106
        }
107
109
 
108
110
        /* We might get a semicolon here - not required. */
109
111
        if (*bufp == ':') {
110
 
            if (i == FDDI_K_ALEN) {
111
 
#ifdef DEBUG
 
112
            if (_DEBUG && i == FDDI_K_ALEN)
112
113
                fprintf(stderr, _("in_fddi(%s): trailing : ignored!\n"),
113
 
                        orig)
114
 
#endif
115
 
                    ;           /* nothing */
116
 
            }
 
114
                        orig);
117
115
            bufp++;
118
116
        }
119
117
    }
120
118
 
121
119
    /* That's it.  Any trailing junk? */
122
 
    if ((i == FDDI_K_ALEN) && (*bufp != '\0')) {
123
 
#ifdef DEBUG
 
120
    if (_DEBUG && (i == FDDI_K_ALEN) && (*bufp != '\0')) {
124
121
        fprintf(stderr, _("in_fddi(%s): trailing junk!\n"), orig);
125
122
        errno = EINVAL;
126
123
        return (-1);
127
 
#endif
128
124
    }
129
 
#ifdef DEBUG
130
 
    fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
131
 
#endif
 
125
    if (_DEBUG)
 
126
        fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
132
127
 
133
128
    return (0);
134
129
}