ppp.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. #ifndef _DEV_PPP_H_
  2. #define _DEV_PPP_H_
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. * -
  34. *
  35. * Copyright (C) 2002 by Call Direct Cellular Solutions Pty. Ltd. All rights reserved.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. *
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the copyright holders nor the names of
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY CALL DIRECT CELLULAR SOLUTIONS AND CONTRIBUTORS
  51. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  53. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALL DIRECT
  54. * CELLULAR SOLUTIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  55. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  56. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  57. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  58. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  59. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  60. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  61. * SUCH DAMAGE.
  62. *
  63. * For additional information see http://www.calldirect.com.au/
  64. */
  65. /*
  66. * $Log$
  67. * Revision 1.6 2008/08/11 06:59:59 haraldkipp
  68. * BSD types replaced by stdint types (feature request #1282721).
  69. *
  70. * Revision 1.5 2005/08/02 17:46:48 haraldkipp
  71. * Major API documentation update.
  72. *
  73. * Revision 1.4 2004/03/14 10:14:42 haraldkipp
  74. * Unused prototypes removed
  75. *
  76. * Revision 1.3 2003/08/14 15:05:55 haraldkipp
  77. * Distinguish negotiated and final magic
  78. *
  79. * Revision 1.2 2003/07/24 16:13:58 haraldkipp
  80. * Never request a rejected DNS
  81. *
  82. * Revision 1.1.1.1 2003/05/09 14:41:08 haraldkipp
  83. * Initial using 3.2.1
  84. *
  85. * Revision 1.2 2003/05/06 18:43:30 harald
  86. * Cleanup
  87. *
  88. * Revision 1.1 2003/03/31 14:53:23 harald
  89. * Prepare release 3.1
  90. *
  91. */
  92. #include <sys/device.h>
  93. #include <dev/netbuf.h>
  94. /*!
  95. * \file dev/ppp.h
  96. * \brief PPP device definitions.
  97. */
  98. /*
  99. * Reject flags. Not completed, more will follow.
  100. */
  101. #define REJ_IPCP_DNS1 0x00000100
  102. #define REJ_IPCP_DNS2 0x00000200
  103. #ifdef __cplusplus
  104. extern "C" {
  105. #endif
  106. /*!
  107. * \addtogroup xgPPP
  108. */
  109. /*@{*/
  110. #define PPP_PFC 0x01
  111. #define PPP_ACFC 0x02
  112. #define LCP_DEFOPT_ASYNCMAP 0x000A0000UL
  113. /*!
  114. * \brief PPP server configuration type.
  115. */
  116. typedef struct _PPPSERVER_CFG PPPSERVER_CFG;
  117. /*!
  118. * \brief PPP server configuration structure.
  119. */
  120. struct _PPPSERVER_CFG {
  121. uint32_t ppsc_remote_ip;
  122. uint32_t ppsc_dns1;
  123. uint32_t ppsc_dns2;
  124. };
  125. /*!
  126. * \brief PPP interface type.
  127. */
  128. typedef struct _PPPDCB PPPDCB;
  129. /*!
  130. * \struct _PPPDCB ppp.h dev/ppp.h
  131. * \brief PPP interface structure.
  132. *
  133. * Contains information about the PPP device.
  134. */
  135. struct _PPPDCB {
  136. /*! \brief PPP State event queue.
  137. * The state machine posts an event to this queue when the
  138. * network interface becomes ready.
  139. */
  140. HANDLE dcb_state_chg;
  141. /*! \brief Current state of the link layer.
  142. */
  143. uint8_t dcb_lcp_state;
  144. /*! \brief ID of our last request.
  145. */
  146. uint8_t dcb_reqid;
  147. /*! \brief ID of our last reject.
  148. */
  149. uint8_t dcb_rejid;
  150. /*! \brief Flag to remember ack received.
  151. */
  152. uint8_t dcb_acked;
  153. /*! \brief Maximum local receive unit.
  154. */
  155. uint16_t dcb_loc_mru;
  156. /*! \brief Maximum remote receive unit.
  157. */
  158. uint16_t dcb_rem_mru;
  159. /*! \brief Asynch control character map.
  160. * TODO: Pass to ahdlc driver.
  161. */
  162. uint32_t dcb_accm;
  163. /*! \brief Compression flags.
  164. * TODO: Pass to ahdlc driver. dcb_useACFC dcb_usePFC
  165. */
  166. uint8_t dcb_compr;
  167. /*! \brief Authentication type.
  168. */
  169. uint16_t dcb_auth;
  170. /*! \brief Magic number to negotiate.
  171. */
  172. uint32_t dcb_neg_magic;
  173. /*! \brief Local magic number.
  174. * Used to detect loopback conditions.
  175. */
  176. uint32_t dcb_loc_magic;
  177. /*! \brief Remote magic number.
  178. * Used to detect loopback conditions.
  179. */
  180. uint32_t dcb_rem_magic;
  181. /*! \brief User authentication.
  182. */
  183. uint8_t *dcb_user;
  184. /*! \brief Password authentication.
  185. */
  186. uint8_t *dcb_pass;
  187. /*! \brief Local IP address.
  188. */
  189. uint32_t dcb_local_ip;
  190. /*! \brief Remote IP address.
  191. */
  192. uint32_t dcb_remote_ip;
  193. /*! \brief Negotiated IP mask.
  194. */
  195. uint32_t dcb_ip_mask;
  196. /*! \brief Negotiated primary DNS.
  197. */
  198. uint32_t dcb_ip_dns1;
  199. /*! \brief Negotiated secondary DNS.
  200. */
  201. uint32_t dcb_ip_dns2;
  202. /*! \brief Rejected items.
  203. */
  204. uint32_t dcb_rejects;
  205. /*! \brief LCP/IPCP retransmit counter.
  206. */
  207. uint8_t dcb_retries;
  208. /*! \brief LCP NAK counter, avoids endless loops.
  209. */
  210. uint8_t dcb_lcp_naks;
  211. /*! \brief Identifier of our last LCP request.
  212. */
  213. uint8_t dcb_lcp_reqid;
  214. /*! \brief Current state of the network layer.
  215. */
  216. uint8_t dcb_ipcp_state;
  217. /*! \brief LCP NAK counter, avoids endless loops.
  218. */
  219. uint8_t dcb_ipcp_naks;
  220. /*! \brief Current authentication state.
  221. */
  222. uint8_t dcb_auth_state;
  223. /*! \brief File descriptor of physical device.
  224. */
  225. int dcb_fd;
  226. };
  227. /*
  228. * Available devices.
  229. */
  230. extern NUTDEVICE devPpp;
  231. #define LCP_OPEN 1
  232. #define LCP_CLOSE 2
  233. #define LCP_LOWERUP 3
  234. #define LCP_LOWERDOWN 4
  235. /*@}*/
  236. #ifdef __cplusplus
  237. }
  238. #endif
  239. #endif