PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/freebsd/sys/net/if_sppp.h

https://bitbucket.org/killerpenguinassassins/open_distrib_devel
C Header | 234 lines | 135 code | 21 blank | 78 comment | 0 complexity | e3f5c64b1e2a01831965817861626673 MD5 | raw file
Possible License(s): CC0-1.0, MIT, LGPL-2.0, LGPL-3.0, WTFPL, GPL-2.0, BSD-2-Clause, AGPL-3.0, CC-BY-SA-3.0, MPL-2.0, JSON, BSD-3-Clause-No-Nuclear-License-2014, LGPL-2.1, CPL-1.0, AGPL-1.0, 0BSD, ISC, Apache-2.0, GPL-3.0, IPL-1.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /*
  2. * Defines for synchronous PPP/Cisco/Frame Relay link level subroutines.
  3. */
  4. /*-
  5. * Copyright (C) 1994-2000 Cronyx Engineering.
  6. * Author: Serge Vakulenko, <vak@cronyx.ru>
  7. *
  8. * Heavily revamped to conform to RFC 1661.
  9. * Copyright (C) 1997, Joerg Wunsch.
  10. *
  11. * This software is distributed with NO WARRANTIES, not even the implied
  12. * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * Authors grant any other persons or organizations permission to use
  15. * or modify this software as long as this message is kept with the software,
  16. * all derivative works or modified versions.
  17. *
  18. * From: Version 2.0, Fri Oct 6 20:39:21 MSK 1995
  19. *
  20. * $FreeBSD$
  21. */
  22. #ifndef _NET_IF_SPPP_H_
  23. #define _NET_IF_SPPP_H_ 1
  24. #define IDX_LCP 0 /* idx into state table */
  25. struct slcp {
  26. u_long opts; /* LCP options to send (bitfield) */
  27. u_long magic; /* local magic number */
  28. u_long mru; /* our max receive unit */
  29. u_long their_mru; /* their max receive unit */
  30. u_long protos; /* bitmask of protos that are started */
  31. u_char echoid; /* id of last keepalive echo request */
  32. /* restart max values, see RFC 1661 */
  33. int timeout;
  34. int max_terminate;
  35. int max_configure;
  36. int max_failure;
  37. };
  38. #define IDX_IPCP 1 /* idx into state table */
  39. #define IDX_IPV6CP 2 /* idx into state table */
  40. struct sipcp {
  41. u_long opts; /* IPCP options to send (bitfield) */
  42. u_int flags;
  43. #define IPCP_HISADDR_SEEN 1 /* have seen his address already */
  44. #define IPCP_MYADDR_DYN 2 /* my address is dynamically assigned */
  45. #define IPCP_MYADDR_SEEN 4 /* have seen his address already */
  46. #ifdef notdef
  47. #define IPV6CP_MYIFID_DYN 8 /* my ifid is dynamically assigned */
  48. #endif
  49. #define IPV6CP_MYIFID_SEEN 0x10 /* have seen his ifid already */
  50. #define IPCP_VJ 0x20 /* can use VJ compression */
  51. int max_state; /* VJ: Max-Slot-Id */
  52. int compress_cid; /* VJ: Comp-Slot-Id */
  53. };
  54. #define AUTHNAMELEN 64
  55. #define AUTHKEYLEN 16
  56. struct sauth {
  57. u_short proto; /* authentication protocol to use */
  58. u_short flags;
  59. #define AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */
  60. /* callouts */
  61. #define AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */
  62. u_char name[AUTHNAMELEN]; /* system identification name */
  63. u_char secret[AUTHKEYLEN]; /* secret password */
  64. u_char challenge[AUTHKEYLEN]; /* random challenge */
  65. };
  66. #define IDX_PAP 3
  67. #define IDX_CHAP 4
  68. #define IDX_COUNT (IDX_CHAP + 1) /* bump this when adding cp's! */
  69. /*
  70. * Don't change the order of this. Ordering the phases this way allows
  71. * for a comparision of ``pp_phase >= PHASE_AUTHENTICATE'' in order to
  72. * know whether LCP is up.
  73. */
  74. enum ppp_phase {
  75. PHASE_DEAD, PHASE_ESTABLISH, PHASE_TERMINATE,
  76. PHASE_AUTHENTICATE, PHASE_NETWORK
  77. };
  78. #define PP_MTU 1500 /* default/minimal MRU */
  79. #define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */
  80. /*
  81. * This is a cut down struct sppp (see below) that can easily be
  82. * exported to/ imported from userland without the need to include
  83. * dozens of kernel-internal header files. It is used by the
  84. * SPPPIO[GS]DEFS ioctl commands below.
  85. */
  86. struct sppp_parms {
  87. enum ppp_phase pp_phase; /* phase we're currently in */
  88. int enable_vj; /* VJ header compression enabled */
  89. int enable_ipv6; /*
  90. * Enable IPv6 negotiations -- only
  91. * needed since each IPv4 i/f auto-
  92. * matically gets an IPv6 address
  93. * assigned, so we can't use this as
  94. * a decision.
  95. */
  96. struct slcp lcp; /* LCP params */
  97. struct sipcp ipcp; /* IPCP params */
  98. struct sipcp ipv6cp; /* IPv6CP params */
  99. struct sauth myauth; /* auth params, i'm peer */
  100. struct sauth hisauth; /* auth params, i'm authenticator */
  101. };
  102. /*
  103. * Definitions to pass struct sppp_parms data down into the kernel
  104. * using the SIOC[SG]IFGENERIC ioctl interface.
  105. *
  106. * In order to use this, create a struct spppreq, fill in the cmd
  107. * field with SPPPIOGDEFS, and put the address of this structure into
  108. * the ifr_data portion of a struct ifreq. Pass this struct to a
  109. * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS,
  110. * modify the defs field as desired, and pass the struct ifreq now
  111. * to a SIOCSIFGENERIC ioctl.
  112. */
  113. #define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) +\
  114. sizeof(struct sppp_parms)))
  115. #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) +\
  116. sizeof(struct sppp_parms)))
  117. struct spppreq {
  118. int cmd;
  119. struct sppp_parms defs;
  120. };
  121. #ifdef _KERNEL
  122. struct sppp {
  123. struct ifnet *pp_ifp; /* network interface data */
  124. struct ifqueue pp_fastq; /* fast output queue */
  125. struct ifqueue pp_cpq; /* PPP control protocol queue */
  126. struct sppp *pp_next; /* next interface in keepalive list */
  127. u_int pp_mode; /* major protocol modes (cisco/ppp/...) */
  128. u_int pp_flags; /* sub modes */
  129. u_short pp_alivecnt; /* keepalive packets counter */
  130. u_short pp_loopcnt; /* loopback detection counter */
  131. u_long pp_seq[IDX_COUNT]; /* local sequence number */
  132. u_long pp_rseq[IDX_COUNT]; /* remote sequence number */
  133. enum ppp_phase pp_phase; /* phase we're currently in */
  134. int state[IDX_COUNT]; /* state machine */
  135. u_char confid[IDX_COUNT]; /* id of last configuration request */
  136. int rst_counter[IDX_COUNT]; /* restart counter */
  137. int fail_counter[IDX_COUNT]; /* negotiation failure counter */
  138. int confflags; /* administrative configuration flags */
  139. #define CONF_ENABLE_VJ 0x01 /* VJ header compression enabled */
  140. #define CONF_ENABLE_IPV6 0x02 /* IPv6 administratively enabled */
  141. time_t pp_last_recv; /* time last packet has been received */
  142. time_t pp_last_sent; /* time last packet has been sent */
  143. struct callout ch[IDX_COUNT]; /* per-proto and if callouts */
  144. struct callout pap_my_to_ch; /* PAP needs one more... */
  145. struct callout keepalive_callout; /* keepalive callout */
  146. struct slcp lcp; /* LCP params */
  147. struct sipcp ipcp; /* IPCP params */
  148. struct sipcp ipv6cp; /* IPv6CP params */
  149. struct sauth myauth; /* auth params, i'm peer */
  150. struct sauth hisauth; /* auth params, i'm authenticator */
  151. struct slcompress *pp_comp; /* for VJ compression */
  152. u_short fr_dlci; /* Frame Relay DLCI number, 16..1023 */
  153. u_char fr_status; /* PVC status, active/new/delete */
  154. /*
  155. * These functions are filled in by sppp_attach(), and are
  156. * expected to be used by the lower layer (hardware) drivers
  157. * in order to communicate the (un)availability of the
  158. * communication link. Lower layer drivers that are always
  159. * ready to communicate (like hardware HDLC) can shortcut
  160. * pp_up from pp_tls, and pp_down from pp_tlf.
  161. */
  162. void (*pp_up)(struct sppp *sp);
  163. void (*pp_down)(struct sppp *sp);
  164. /*
  165. * These functions need to be filled in by the lower layer
  166. * (hardware) drivers if they request notification from the
  167. * PPP layer whether the link is actually required. They
  168. * correspond to the tls and tlf actions.
  169. */
  170. void (*pp_tls)(struct sppp *sp);
  171. void (*pp_tlf)(struct sppp *sp);
  172. /*
  173. * These (optional) functions may be filled by the hardware
  174. * driver if any notification of established connections
  175. * (currently: IPCP up) is desired (pp_con) or any internal
  176. * state change of the interface state machine should be
  177. * signaled for monitoring purposes (pp_chg).
  178. */
  179. void (*pp_con)(struct sppp *sp);
  180. void (*pp_chg)(struct sppp *sp, int new_state);
  181. /* These two fields are for use by the lower layer */
  182. void *pp_lowerp;
  183. int pp_loweri;
  184. /* Lock */
  185. struct mtx mtx;
  186. /* if_start () wrapper */
  187. void (*if_start) (struct ifnet *);
  188. struct callout ifstart_callout; /* if_start () scheduler */
  189. };
  190. #define IFP2SP(ifp) ((struct sppp *)(ifp)->if_l2com)
  191. #define SP2IFP(sp) ((sp)->pp_ifp)
  192. /* bits for pp_flags */
  193. #define PP_KEEPALIVE 0x01 /* use keepalive protocol */
  194. #define PP_FR 0x04 /* use Frame Relay protocol instead of PPP */
  195. /* 0x04 was PP_TIMO */
  196. #define PP_CALLIN 0x08 /* we are being called */
  197. #define PP_NEEDAUTH 0x10 /* remote requested authentication */
  198. void sppp_attach (struct ifnet *ifp);
  199. void sppp_detach (struct ifnet *ifp);
  200. void sppp_input (struct ifnet *ifp, struct mbuf *m);
  201. int sppp_ioctl (struct ifnet *ifp, u_long cmd, void *data);
  202. struct mbuf *sppp_dequeue (struct ifnet *ifp);
  203. struct mbuf *sppp_pick(struct ifnet *ifp);
  204. int sppp_isempty (struct ifnet *ifp);
  205. void sppp_flush (struct ifnet *ifp);
  206. /* Internal functions */
  207. void sppp_fr_input (struct sppp *sp, struct mbuf *m);
  208. struct mbuf *sppp_fr_header (struct sppp *sp, struct mbuf *m, int fam);
  209. void sppp_fr_keepalive (struct sppp *sp);
  210. void sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst,
  211. u_long *srcmask);
  212. #endif
  213. #endif /* _NET_IF_SPPP_H_ */