home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3297 / printprotoinet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-07  |  1.1 KB  |  58 lines

  1. /* History:
  2. 5/1/91 DJB baseline public domain
  3. */
  4.  
  5. /*
  6.  
  7. char *printprotoinet(proto) int proto; returns a string representation
  8. of the given Internet protocol, or 0 if the protocol is unrecognized.
  9. The string returned might not be malloced but will not be overwritten on
  10. separate calls.
  11.  
  12. */
  13.  
  14. #include "structsockaddrin.h"
  15. #include "printprotoinet.h"
  16.  
  17. char *printprotoinet(proto)
  18. int proto;
  19. {
  20.  switch(proto)
  21.   {
  22. #ifdef IPPROTO_TCP
  23.    case IPPROTO_TCP: return "tcp";
  24. #endif
  25. #ifdef IPPROTO_UDP
  26.    case IPPROTO_UDP: return "udp";
  27. #endif
  28. #ifdef IPPROTO_IP
  29.    case IPPROTO_IP: return "ip";
  30. #endif
  31. #ifdef IPPROTO_ICMP
  32.    case IPPROTO_ICMP: return "icmp";
  33. #endif
  34. #ifdef IPPROTO_IGMP
  35.    case IPPROTO_IGMP: return "igmp";
  36. #endif
  37. #ifdef IPPROTO_GGP
  38.    case IPPROTO_GGP: return "ggp";
  39. #endif
  40. #ifdef IPPROTO_EGP
  41.    case IPPROTO_EGP: return "egp";
  42. #endif
  43. #ifdef IPPROTO_PUP
  44.    case IPPROTO_PUP: return "pup";
  45. #endif
  46. #ifdef IPPROTO_IDP
  47.    case IPPROTO_IDP: return "idp";
  48. #endif
  49. #ifdef IPPROTO_ND
  50.    case IPPROTO_ND: return "nd";
  51. #endif
  52. #ifdef IPPROTO_RAW
  53.    case IPPROTO_RAW: return "raw";
  54. #endif
  55.    default: return 0;
  56.   }
  57. }
  58.