home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NET-TOOL.1 / NET-TOOL / net-tools / lib / af.c next >
Encoding:
C/C++ Source or Header  |  1994-02-10  |  1.5 KB  |  78 lines

  1. /*
  2.  * NET-2    This file contains the top-level part of the protocol
  3.  *        support functions module for the NET-2 base distribution.
  4.  *
  5.  * Version:    @(#)af.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 aftype    unspec_aftype;
  30. extern    struct aftype    unix_aftype;
  31. extern    struct aftype    inet_aftype;
  32. extern    struct aftype    ax25_aftype;
  33.  
  34.  
  35. static struct aftype *aftypes[] = {
  36.   &unspec_aftype,
  37. #if HAVE_AFINET
  38.   &unix_aftype,
  39. #endif
  40. #if HAVE_AFINET
  41.   &inet_aftype,
  42. #endif
  43. #if HAVE_AFAX25
  44.   &ax25_aftype,
  45. #endif
  46.   NULL
  47. };
  48.  
  49.  
  50. /* Check our protocol family table for this family. */
  51. struct aftype *
  52. get_aftype(char *name)
  53. {
  54.   struct aftype **afp;
  55.  
  56.   afp = aftypes;
  57.   while (*afp != NULL) {
  58.     if (!strcmp((*afp)->name, name)) return(*afp);
  59.     afp++;
  60.   }
  61.   return(NULL);
  62. }
  63.  
  64.  
  65. /* Check our protocol family table for this family. */
  66. struct aftype *
  67. get_afntype(int af)
  68. {
  69.   struct aftype **afp;
  70.  
  71.   afp = aftypes;
  72.   while (*afp != NULL) {
  73.     if ((*afp)->af == af) return(*afp);
  74.     afp++;
  75.   }
  76.   return(NULL);
  77. }
  78.