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

  1. /*
  2.  * NET-2    This file contains the general hardware types.
  3.  *
  4.  * Version:    @(#)loopback.c    1.10    10/07/93
  5.  *
  6.  * Author:    Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  7.  *        Copyright 1993 MicroWalt Corporation
  8.  *
  9.  *        This program is free software; you can redistribute it
  10.  *        and/or  modify it under  the terms of  the GNU General
  11.  *        Public  License as  published  by  the  Free  Software
  12.  *        Foundation;  either  version 2 of the License, or  (at
  13.  *        your option) any later version.
  14.  */
  15. #include "config.h"
  16.  
  17. #include <sys/types.h>
  18. #include <sys/socket.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <errno.h>
  22. #include <ctype.h>
  23. #include <string.h>
  24. #include <unistd.h>
  25. #include <linux/if.h>
  26. #include "support.h"
  27. #include "pathnames.h"
  28.  
  29.  
  30. /* Display an UNSPEC address. */
  31. static char *
  32. pr_unspec(unsigned char *ptr)
  33. {
  34.   static char buff[64];
  35.   char *pos;
  36.   int i;
  37.  
  38.   pos = buff;
  39.   for(i = 0; i < sizeof(struct sockaddr); i++) {
  40.     pos += sprintf(pos, "%02X-", (*ptr++ & 0377));
  41.   }
  42.   buff[strlen(buff) - 1] = '\0';
  43.   return(buff);
  44. }
  45.  
  46.  
  47. /* Display an UNSPEC socket address. */
  48. static char *
  49. pr_sunspec(struct sockaddr *sap)
  50. {
  51.   if (sap->sa_family == 0xFFFF || sap->sa_family == 0) return("[NONE SET]");
  52.   return(pr_unspec(sap->sa_data));
  53. }
  54.  
  55.  
  56. struct hwtype unspec_hwtype = {
  57.   "unspec",    "UNSPEC",        0,        0,
  58.   pr_unspec,    pr_sunspec,        NULL,        NULL
  59. };
  60. struct hwtype loop_hwtype = {
  61.   "loop",    "Local Loopback",    255,        0,
  62.   NULL,        NULL,            NULL,        NULL
  63. };
  64.