Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From abe15ba10ddc3548c528ccb088097d7abf5be48b Mon Sep 17 00:00:00 2001 |
| 2 | From: Li xin <lixin.fnst@cn.fujitsu.com> |
| 3 | Date: Tue, 18 Nov 2014 18:14:07 +0900 |
| 4 | Subject: [PATCH 5/5] ethernet.c : remove it |
| 5 | |
| 6 | Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com> |
| 7 | --- |
| 8 | ethernet.c | 224 ------------------------------------------------------------- |
| 9 | 1 file changed, 224 deletions(-) |
| 10 | delete mode 100644 ethernet.c |
| 11 | |
| 12 | diff --git a/ethernet.c b/ethernet.c |
| 13 | deleted file mode 100644 |
| 14 | index d682b63..0000000 |
| 15 | --- a/ethernet.c |
| 16 | +++ /dev/null |
| 17 | @@ -1,224 +0,0 @@ |
| 18 | -/* |
| 19 | - * Copyright (c) 1990, 1993 The Regents of the University of California. |
| 20 | - * All rights reserved. |
| 21 | - * |
| 22 | - * Redistribution and use in source and binary forms, with or without |
| 23 | - * modification, are permitted provided that: (1) source code distributions |
| 24 | - * retain the above copyright notice and this paragraph in its entirety, (2) |
| 25 | - * distributions including binary code include the above copyright notice and |
| 26 | - * this paragraph in its entirety in the documentation or other materials |
| 27 | - * provided with the distribution, and (3) all advertising materials mentioning |
| 28 | - * features or use of this software display the following acknowledgement: |
| 29 | - * ``This product includes software developed by the University of California, |
| 30 | - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
| 31 | - * the University nor the names of its contributors may be used to endorse |
| 32 | - * or promote products derived from this software without specific prior |
| 33 | - * written permission. |
| 34 | - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
| 35 | - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 36 | - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 37 | - */ |
| 38 | -#ifndef lint |
| 39 | -static char rcsid[] = |
| 40 | - "@(#) $Header: etherent.c,v 1.4 96/06/14 20:34:25 leres Exp $ (LBL)"; |
| 41 | -#endif |
| 42 | - |
| 43 | -#include <sys/types.h> |
| 44 | -#include <sys/stat.h> |
| 45 | -#include <sys/time.h> |
| 46 | - |
| 47 | -#include <ctype.h> |
| 48 | -#include <stdio.h> |
| 49 | -#include <string.h> |
| 50 | - |
| 51 | -#ifndef ETHERS_FILE |
| 52 | -#define ETHERS_FILE "/etc/ethers" |
| 53 | -#endif |
| 54 | - |
| 55 | -struct etherent { |
| 56 | - u_char addr[6]; |
| 57 | - char name[122]; |
| 58 | -}; |
| 59 | - |
| 60 | -static FILE *ether_fp = NULL; |
| 61 | - |
| 62 | - |
| 63 | -/* Hex digit to integer. */ |
| 64 | -static inline int |
| 65 | -xdtoi(c) |
| 66 | - int c; |
| 67 | -{ |
| 68 | - |
| 69 | - if (isdigit(c)) |
| 70 | - return c - '0'; |
| 71 | - else if (islower(c)) |
| 72 | - return c - 'a' + 10; |
| 73 | - else |
| 74 | - return c - 'A' + 10; |
| 75 | -} |
| 76 | - |
| 77 | -static inline int |
| 78 | -skip_space(f) |
| 79 | - FILE *f; |
| 80 | -{ |
| 81 | - int c; |
| 82 | - |
| 83 | - do { |
| 84 | - c = getc(f); |
| 85 | - } while (isspace(c) && c != '\n'); |
| 86 | - |
| 87 | - return c; |
| 88 | -} |
| 89 | - |
| 90 | -static inline int |
| 91 | -skip_line(f) |
| 92 | - FILE *f; |
| 93 | -{ |
| 94 | - int c; |
| 95 | - |
| 96 | - do |
| 97 | - c = getc(f); |
| 98 | - while (c != '\n' && c != EOF); |
| 99 | - |
| 100 | - return c; |
| 101 | -} |
| 102 | - |
| 103 | -static struct etherent * |
| 104 | -next_etherent(fp) |
| 105 | - FILE *fp; |
| 106 | -{ |
| 107 | - register int c, d, i; |
| 108 | - char *bp; |
| 109 | - static struct etherent e; |
| 110 | - static int nline = 1; |
| 111 | - top: |
| 112 | - while (nline) { |
| 113 | - /* Find addr */ |
| 114 | - c = skip_space(fp); |
| 115 | - if (c == '\n') |
| 116 | - continue; |
| 117 | - /* If this is a comment, or first thing on line |
| 118 | - cannot be etehrnet address, skip the line. */ |
| 119 | - else if (!isxdigit(c)) |
| 120 | - c = skip_line(fp); |
| 121 | - else { |
| 122 | - /* must be the start of an address */ |
| 123 | - for (i = 0; i < 6; i += 1) { |
| 124 | - d = xdtoi(c); |
| 125 | - c = getc(fp); |
| 126 | - if (c != ':') { |
| 127 | - d <<= 4; |
| 128 | - d |= xdtoi(c); |
| 129 | - c = getc(fp); |
| 130 | - } |
| 131 | - e.addr[i] = d; |
| 132 | - if (c != ':') |
| 133 | - break; |
| 134 | - c = getc(fp); |
| 135 | - } |
| 136 | - nline = 0; |
| 137 | - } |
| 138 | - if (c == EOF) |
| 139 | - return NULL; |
| 140 | - } |
| 141 | - |
| 142 | - /* If we started a new line, 'c' holds the char past the ether addr, |
| 143 | - which we assume is white space. If we are continuing a line, |
| 144 | - 'c' is garbage. In either case, we can throw it away. */ |
| 145 | - |
| 146 | - c = skip_space(fp); |
| 147 | - if (c == '\n') { |
| 148 | - nline = 1; |
| 149 | - goto top; |
| 150 | - } |
| 151 | - else if (c == '#') { |
| 152 | - (void)skip_line(fp); |
| 153 | - nline = 1; |
| 154 | - goto top; |
| 155 | - } |
| 156 | - else if (c == EOF) |
| 157 | - return NULL; |
| 158 | - |
| 159 | - /* Must be a name. */ |
| 160 | - bp = e.name; |
| 161 | - /* Use 'd' to prevent buffer overflow. */ |
| 162 | - d = sizeof(e.name) - 1; |
| 163 | - do { |
| 164 | - *bp++ = c; |
| 165 | - c = getc(fp); |
| 166 | - } while (!isspace(c) && c != EOF && --d > 0); |
| 167 | - *bp = '\0'; |
| 168 | - if (c == '\n') |
| 169 | - nline = 1; |
| 170 | - |
| 171 | - return &e; |
| 172 | -} |
| 173 | - |
| 174 | -/* Open/rewind the ethers files; returns 1 if file was reopened */ |
| 175 | -int |
| 176 | -ether_rewind() |
| 177 | -{ |
| 178 | - struct stat st; |
| 179 | - static long mtime = 0, ctime = 0; |
| 180 | - |
| 181 | - if (ether_fp != NULL) { |
| 182 | - if (fstat(fileno(ether_fp), &st) < 0 || |
| 183 | - mtime != st.st_mtime || ctime != st.st_ctime || |
| 184 | - fseek(ether_fp, 0L, SEEK_SET) < 0) { |
| 185 | - fclose(ether_fp); |
| 186 | - ether_fp = NULL; |
| 187 | - } |
| 188 | - } |
| 189 | - if (ether_fp == NULL) { |
| 190 | - ether_fp = fopen(ETHERS_FILE, "r"); |
| 191 | - if (ether_fp == NULL) |
| 192 | - return (-1); |
| 193 | - if (fstat(fileno(ether_fp), &st) < 0) { |
| 194 | - fclose(ether_fp); |
| 195 | - ether_fp = NULL; |
| 196 | - return (-1); |
| 197 | - } |
| 198 | - mtime = st.st_mtime; |
| 199 | - ctime = st.st_ctime; |
| 200 | - return (1); |
| 201 | - } |
| 202 | - return (0); |
| 203 | -} |
| 204 | - |
| 205 | -/* Map an ethernet address to a name; returns 0 on success, else 1. */ |
| 206 | -int |
| 207 | -ether_ntohost(name, ea) |
| 208 | - register char *name; |
| 209 | - register u_char *ea; |
| 210 | -{ |
| 211 | - register struct etherent *ep; |
| 212 | - |
| 213 | - if (ether_rewind() < 0) |
| 214 | - return (1); |
| 215 | - |
| 216 | - while ((ep = next_etherent(ether_fp)) != NULL) |
| 217 | - if (bcmp(ep->addr, ea, 6) == 0) { |
| 218 | - strcpy(name, ep->name); |
| 219 | - return (0); |
| 220 | - } |
| 221 | - return (1); |
| 222 | -} |
| 223 | - |
| 224 | -/* Map an ethernet name to an address; returns 0 on success, else 1. */ |
| 225 | -int |
| 226 | -ether_hostton(name, ea) |
| 227 | - register char *name; |
| 228 | - register u_char *ea; |
| 229 | -{ |
| 230 | - register struct etherent *ep; |
| 231 | - |
| 232 | - if (ether_rewind() < 0) |
| 233 | - return (1); |
| 234 | - |
| 235 | - while ((ep = next_etherent(ether_fp)) != NULL) |
| 236 | - if (strcmp(ep->name, name) == 0) { |
| 237 | - bcopy(ep->addr, ea, 6); |
| 238 | - return (0); |
| 239 | - } |
| 240 | - return (1); |
| 241 | -} |
| 242 | -- |
| 243 | 1.8.4.2 |
| 244 | |