3 * PPP library with GLib integration
5 * Copyright (C) 2009-2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 struct ppp_option_iter;
39 PPPCP_CODE_TYPE_CONFIGURE_REQUEST = 1,
40 PPPCP_CODE_TYPE_CONFIGURE_ACK,
41 PPPCP_CODE_TYPE_CONFIGURE_NAK,
42 PPPCP_CODE_TYPE_CONFIGURE_REJECT,
43 PPPCP_CODE_TYPE_TERMINATE_REQUEST,
44 PPPCP_CODE_TYPE_TERMINATE_ACK,
45 PPPCP_CODE_TYPE_CODE_REJECT,
46 PPPCP_CODE_TYPE_PROTOCOL_REJECT,
47 PPPCP_CODE_TYPE_ECHO_REQUEST,
48 PPPCP_CODE_TYPE_ECHO_REPLY,
49 PPPCP_CODE_TYPE_DISCARD_REQUEST
57 } __attribute__((packed));
59 struct ppp_option_iter {
65 const guint8 *option_data;
71 guint16 supported_codes;
72 void (*this_layer_up)(struct pppcp_data *data);
73 void (*this_layer_down)(struct pppcp_data *data);
74 void (*this_layer_started)(struct pppcp_data *data);
75 void (*this_layer_finished)(struct pppcp_data *data);
76 /* Remote side acked these options, we can now use them */
77 void (*rca)(struct pppcp_data *pppcp, const struct pppcp_packet *pkt);
79 * Remote side sent us an Conf-Req-Nak or Conf-Req-Rej. The protocol
80 * driver should examine the packet and update its options accordingly,
81 * then use set_local_options to set a new set of options to try
84 void (*rcn_nak)(struct pppcp_data *pppcp,
85 const struct pppcp_packet *pkt);
86 void (*rcn_rej)(struct pppcp_data *pppcp,
87 const struct pppcp_packet *pkt);
89 * Remote side has sent us a request with its options, return whether
90 * we should ack / nak / rej these options. In the case of nak / rej,
91 * the list of options to be sent to the peer is given in the
92 * new_options & new_len out arguments
94 enum rcr_result (*rcr)(struct pppcp_data *pppcp,
95 const struct pppcp_packet *pkt,
96 guint8 **new_options, guint16 *new_len);
99 void ppp_option_iter_init(struct ppp_option_iter *iter,
100 const struct pppcp_packet *packet);
101 gboolean ppp_option_iter_next(struct ppp_option_iter *iter);
102 guint8 ppp_option_iter_get_type(struct ppp_option_iter *iter);
103 guint8 ppp_option_iter_get_length(struct ppp_option_iter *iter);
104 const guint8 *ppp_option_iter_get_data(struct ppp_option_iter *iter);
106 struct pppcp_data *pppcp_new(GAtPPP *ppp, const struct pppcp_proto *proto,
107 gboolean dormant, guint max_failure);
108 void pppcp_free(struct pppcp_data *data);
110 void pppcp_set_data(struct pppcp_data *pppcp, gpointer data);
111 gpointer pppcp_get_data(struct pppcp_data *pppcp);
112 GAtPPP *pppcp_get_ppp(struct pppcp_data *pppcp);
114 guint8 pppcp_get_code(const guint8 *data);
116 void pppcp_set_local_options(struct pppcp_data *data,
117 const guint8 *options,
120 void pppcp_process_packet(gpointer priv, const guint8 *new_packet, gsize len);
121 void pppcp_send_protocol_reject(struct pppcp_data *data,
122 const guint8 *rejected_packet, gsize len);
123 void pppcp_signal_open(struct pppcp_data *data);
124 void pppcp_signal_close(struct pppcp_data *data);
125 void pppcp_signal_up(struct pppcp_data *data);
126 void pppcp_signal_down(struct pppcp_data *data);