Back to index

glibc  2.9
files-ethers.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <string.h>
00020 #include <netinet/ether.h>
00021 #include <netinet/if_ether.h>
00022 
00023 struct etherent_data {};
00024 
00025 #define ENTNAME             etherent
00026 #define DATABASE     "ethers"
00027 #include "files-parse.c"
00028 LINE_PARSER
00029 ("#",
00030  /* Read the ethernet address: 6 x 8bit hexadecimal number.  */
00031  {
00032    size_t cnt;
00033 
00034    for (cnt = 0; cnt < 6; ++cnt)
00035      {
00036        unsigned int number;
00037 
00038        if (cnt < 5)
00039         INT_FIELD (number, ISCOLON , 0, 16, (unsigned int))
00040        else
00041         INT_FIELD (number, isspace, 1, 16, (unsigned int))
00042 
00043        if (number > 0xff)
00044         return 0;
00045        result->e_addr.ether_addr_octet[cnt] = number;
00046      }
00047  };
00048  STRING_FIELD (result->e_name, isspace, 1);
00049  )
00050 
00051 
00052 #include GENERIC
00053 
00054 DB_LOOKUP (hostton, 1 + strlen (name), (".%s", name),
00055           {
00056             if (__strcasecmp (result->e_name, name) == 0)
00057               break;
00058           }, const char *name)
00059 
00060 DB_LOOKUP (ntohost, 18, ("=%x:%x:%x:%x:%x:%x",
00061                       addr->ether_addr_octet[0], addr->ether_addr_octet[1],
00062                       addr->ether_addr_octet[2], addr->ether_addr_octet[3],
00063                       addr->ether_addr_octet[4], addr->ether_addr_octet[5]),
00064           {
00065             if (memcmp (&result->e_addr, addr,
00066                       sizeof (struct ether_addr)) == 0)
00067               break;
00068           }, const struct ether_addr *addr)