files-ethers.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 1996-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include <string.h>
  15. #include <netinet/ether.h>
  16. #include <netinet/if_ether.h>
  17. #include <nss.h>
  18. struct etherent_data {};
  19. #define ENTNAME etherent
  20. #define DATABASE "ethers"
  21. #include "files-parse.c"
  22. LINE_PARSER
  23. ("#",
  24. /* Read the ethernet address: 6 x 8bit hexadecimal number. */
  25. {
  26. size_t cnt;
  27. for (cnt = 0; cnt < 6; ++cnt)
  28. {
  29. unsigned int number;
  30. if (cnt < 5)
  31. INT_FIELD (number, ISCOLON , 0, 16, (unsigned int))
  32. else
  33. INT_FIELD (number, isspace, 1, 16, (unsigned int))
  34. if (number > 0xff)
  35. return 0;
  36. result->e_addr.ether_addr_octet[cnt] = number;
  37. }
  38. };
  39. STRING_FIELD (result->e_name, isspace, 1);
  40. )
  41. #include GENERIC
  42. DB_LOOKUP (hostton, '.', 0, ("%s", name),
  43. {
  44. if (__strcasecmp (result->e_name, name) == 0)
  45. break;
  46. }, const char *name)
  47. DB_LOOKUP (ntohost, '=', 18, ("%x:%x:%x:%x:%x:%x",
  48. addr->ether_addr_octet[0], addr->ether_addr_octet[1],
  49. addr->ether_addr_octet[2], addr->ether_addr_octet[3],
  50. addr->ether_addr_octet[4], addr->ether_addr_octet[5]),
  51. {
  52. if (memcmp (&result->e_addr, addr,
  53. sizeof (struct ether_addr)) == 0)
  54. break;
  55. }, const struct ether_addr *addr)