home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NET-TOOL.1 / NET-TOOL / net-tools / lib / hw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-11  |  2.0 KB  |  103 lines

  1. /*
  2.  * NET-2    This file contains the top-level part of the hardware
  3.  *        support functions module for the NET-2 base distribution.
  4.  *
  5.  * Version:    @(#)hw.c    1.10    10/07/93
  6.  *
  7.  * Author:    Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  8.  *        Copyright 1993 MicroWalt Corporation
  9.  *
  10.  *        This program is free software; you can redistribute it
  11.  *        and/or  modify it under  the terms of  the GNU General
  12.  *        Public  License as  published  by  the  Free  Software
  13.  *        Foundation;  either  version 2 of the License, or  (at
  14.  *        your option) any later version.
  15.  */
  16. #include <sys/types.h>
  17. #include <sys/socket.h>
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include <errno.h>
  21. #include <ctype.h>
  22. #include <string.h>
  23. #include <unistd.h>
  24. #include "config.h"
  25. #include "support.h"
  26. #include "pathnames.h"
  27.  
  28.  
  29. extern    struct hwtype    unspec_hwtype;
  30. extern    struct hwtype    loop_hwtype;
  31.  
  32. extern    struct hwtype    slip_hwtype;
  33. extern    struct hwtype    cslip_hwtype;
  34. extern    struct hwtype    slip6_hwtype;
  35. extern    struct hwtype    cslip6_hwtype;
  36. extern    struct hwtype    adaptive_hwtype;
  37.  
  38. extern    struct hwtype    ether_hwtype;
  39.  
  40. extern    struct hwtype    ax25_hwtype;
  41. extern  struct hwtype   kiss_hwtype;
  42.  
  43. extern struct hwtype    ppp_hwtype;
  44.  
  45. extern struct hwtype    arc_hwtype;
  46.  
  47. static struct hwtype *hwtypes[] = {
  48.  
  49.   &loop_hwtype,
  50.  
  51. #if HAVE_HWSLIP
  52.   &slip_hwtype,
  53.   &cslip_hwtype,
  54.   &slip6_hwtype,
  55.   &cslip6_hwtype,
  56.   &adaptive_hwtype,
  57. #endif
  58.   &unspec_hwtype,
  59. #if HAVE_HWETHER
  60.   ðer_hwtype,
  61. #endif
  62. #if HAVE_HWAX25
  63.   &ax25_hwtype,
  64. #endif
  65. #if HAVE_HWPPP
  66.   &ppp_hwtype,
  67. #endif  
  68. #if HAVE_HWARC
  69.   &arc_hwtype,
  70. #endif  
  71.   NULL
  72. };
  73.  
  74.  
  75. /* Check our hardware type table for this type. */
  76. struct hwtype *
  77. get_hwtype(char *name)
  78. {
  79.   struct hwtype **hwp;
  80.  
  81.   hwp = hwtypes;
  82.   while (*hwp != NULL) {
  83.     if (!strcmp((*hwp)->name, name)) return(*hwp);
  84.     hwp++;
  85.   }
  86.   return(NULL);
  87. }
  88.  
  89.  
  90. /* Check our hardware type table for this type. */
  91. struct hwtype *
  92. get_hwntype(int type)
  93. {
  94.   struct hwtype **hwp;
  95.  
  96.   hwp = hwtypes;
  97.   while (*hwp != NULL) {
  98.     if ((*hwp)->type == type) return(*hwp);
  99.     hwp++;
  100.   }
  101.   return(NULL);
  102. }
  103.