icsetbuf.c,v
上传用户:lywr2008
上传日期:2022-05-26
资源大小:9k
文件大小:2k
源码类别:

网络

开发平台:

Unix_Linux

  1. head 1.1;
  2. access;
  3. symbols;
  4. locks
  5. dls:1.1; strict;
  6. comment @ * @;
  7. 1.1
  8. date 97.09.21.19.26.41; author dls; state Dist;
  9. branches;
  10. next ;
  11. desc
  12. @@
  13. 1.1
  14. log
  15. @pre-3e code
  16. @
  17. text
  18. @/* icsetbuf.c - icsetbuf */
  19. #include <conf.h>
  20. #include <kernel.h>
  21. #include <network.h>
  22. /*------------------------------------------------------------------------
  23.  *  icsetbuf -  set up a buffer for an ICMP message
  24.  *------------------------------------------------------------------------
  25.  */
  26. struct ep *icsetbuf(type, pa1, pisresp, piserr)
  27. int type;
  28. char *pa1; /* old packet, if any */
  29. Bool *pisresp, /* packet is a response */
  30. *piserr; /* packet is an error */
  31. {
  32. struct ep *pep;
  33. *pisresp = *piserr = FALSE;
  34. switch (type) {
  35. case ICT_REDIRECT:
  36. pep = (struct ep *)getbuf(Net.netpool);
  37. if ((int)pep == SYSERR)
  38. return 0;
  39. blkcopy(pep, pa1, MAXNETBUF);
  40. pa1 = (char *)pep;
  41. *piserr = TRUE;
  42. break;
  43. case ICT_DESTUR:
  44. case ICT_SRCQ:
  45. case ICT_TIMEX:
  46. case ICT_PARAMP:
  47. pep = (struct ep *)pa1;
  48. *piserr = TRUE;
  49. break;
  50. case ICT_ECHORP:
  51. case ICT_INFORP:
  52. case ICT_MASKRP:
  53. pep = (struct ep *)pa1;
  54. *pisresp = TRUE;
  55. break;
  56. case ICT_ECHORQ:
  57. case ICT_TIMERQ:
  58. case ICT_INFORQ:
  59. case ICT_MASKRQ:
  60. pep = (struct ep *)getbuf(Net.lrgpool);
  61. if ((int)pep == SYSERR)
  62. return 0;
  63. break;
  64. case ICT_TIMERP: /* Not Implemented */
  65. /* IcmpOutTimestampsReps++; */
  66. IcmpOutErrors--; /* Kludge: we increment above */
  67. freebuf(pa1);
  68. return 0;
  69. default:
  70. kprintf("icsetbuf: unknown ICMP type (%d)n", type);
  71. return 0;
  72. }
  73. if (*piserr)
  74. *pisresp = TRUE;
  75. switch (type) { /* Update MIB Statistics */
  76. case ICT_ECHORP: IcmpOutEchos++; break;
  77. case ICT_ECHORQ: IcmpOutEchoReps++; break;
  78. case ICT_DESTUR: IcmpOutDestUnreachs++; break;
  79. case ICT_SRCQ: IcmpOutSrcQuenchs++; break;
  80. case ICT_REDIRECT: IcmpOutRedirects++; break;
  81. case ICT_TIMEX: IcmpOutTimeExcds++; break;
  82. case ICT_PARAMP: IcmpOutParmProbs++; break;
  83. case ICT_TIMERQ: IcmpOutTimestamps++; break;
  84. case ICT_TIMERP: IcmpOutTimestampReps++; break;
  85. case ICT_MASKRQ: IcmpOutAddrMasks++; break;
  86. case ICT_MASKRP: IcmpOutAddrMaskReps++; break;
  87. }
  88. return pep;
  89. }
  90. @