ecp.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * ecp.c - PPP Encryption Control Protocol.
  3. *
  4. * Copyright (c) 2002 Google, Inc.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The name(s) of the authors of this software must not be used to
  20. * endorse or promote products derived from this software without
  21. * prior written permission.
  22. *
  23. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  24. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  25. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  26. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  28. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  29. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. *
  31. * Derived from ccp.c, which is:
  32. *
  33. * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. *
  39. * 1. Redistributions of source code must retain the above copyright
  40. * notice, this list of conditions and the following disclaimer.
  41. *
  42. * 2. The name(s) of the authors of this software must not be used to
  43. * endorse or promote products derived from this software without
  44. * prior written permission.
  45. *
  46. * 3. Redistributions of any form whatsoever must retain the following
  47. * acknowledgment:
  48. * "This product includes software developed by Paul Mackerras
  49. * <paulus@samba.org>".
  50. *
  51. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  52. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  53. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  54. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  55. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  56. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  57. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  58. */
  59. #define RCSID "$Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp $"
  60. static const char rcsid[] = RCSID;
  61. #include <string.h>
  62. #include "pppd.h"
  63. #include "fsm.h"
  64. #include "ecp.h"
  65. static option_t ecp_option_list[] = {
  66. { "noecp", o_bool, &ecp_protent.enabled_flag,
  67. "Disable ECP negotiation" },
  68. { "-ecp", o_bool, &ecp_protent.enabled_flag,
  69. "Disable ECP negotiation", OPT_ALIAS },
  70. { NULL }
  71. };
  72. /*
  73. * Protocol entry points from main code.
  74. */
  75. static void ecp_init __P((int unit));
  76. /*
  77. static void ecp_open __P((int unit));
  78. static void ecp_close __P((int unit, char *));
  79. static void ecp_lowerup __P((int unit));
  80. static void ecp_lowerdown __P((int));
  81. static void ecp_input __P((int unit, u_char *pkt, int len));
  82. static void ecp_protrej __P((int unit));
  83. */
  84. static int ecp_printpkt __P((u_char *pkt, int len,
  85. void (*printer) __P((void *, char *, ...)),
  86. void *arg));
  87. /*
  88. static void ecp_datainput __P((int unit, u_char *pkt, int len));
  89. */
  90. struct protent ecp_protent = {
  91. PPP_ECP,
  92. ecp_init,
  93. NULL, /* ecp_input, */
  94. NULL, /* ecp_protrej, */
  95. NULL, /* ecp_lowerup, */
  96. NULL, /* ecp_lowerdown, */
  97. NULL, /* ecp_open, */
  98. NULL, /* ecp_close, */
  99. ecp_printpkt,
  100. NULL, /* ecp_datainput, */
  101. 0,
  102. "ECP",
  103. "Encrypted",
  104. ecp_option_list,
  105. NULL,
  106. NULL,
  107. NULL
  108. };
  109. fsm ecp_fsm[NUM_PPP];
  110. ecp_options ecp_wantoptions[NUM_PPP]; /* what to request the peer to use */
  111. ecp_options ecp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
  112. ecp_options ecp_allowoptions[NUM_PPP]; /* what we'll agree to do */
  113. ecp_options ecp_hisoptions[NUM_PPP]; /* what we agreed to do */
  114. static fsm_callbacks ecp_callbacks = {
  115. NULL, /* ecp_resetci, */
  116. NULL, /* ecp_cilen, */
  117. NULL, /* ecp_addci, */
  118. NULL, /* ecp_ackci, */
  119. NULL, /* ecp_nakci, */
  120. NULL, /* ecp_rejci, */
  121. NULL, /* ecp_reqci, */
  122. NULL, /* ecp_up, */
  123. NULL, /* ecp_down, */
  124. NULL,
  125. NULL,
  126. NULL,
  127. NULL,
  128. NULL, /* ecp_extcode, */
  129. "ECP"
  130. };
  131. /*
  132. * ecp_init - initialize ECP.
  133. */
  134. static void
  135. ecp_init(unit)
  136. int unit;
  137. {
  138. fsm *f = &ecp_fsm[unit];
  139. f->unit = unit;
  140. f->protocol = PPP_ECP;
  141. f->callbacks = &ecp_callbacks;
  142. fsm_init(f);
  143. memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options));
  144. memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options));
  145. memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));
  146. memset(&ecp_hisoptions[unit], 0, sizeof(ecp_options));
  147. }
  148. static int
  149. ecp_printpkt(p, plen, printer, arg)
  150. u_char *p;
  151. int plen;
  152. void (*printer) __P((void *, char *, ...));
  153. void *arg;
  154. {
  155. return 0;
  156. }