Debian Codegraph @

pppd/plugins/pppol2tp/l2tp_event.h

raw
1 /*****************************************************************************
2 * Copyright (C) 2008 Katalix Systems Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 *****************************************************************************/
19
20 /*
21 * OpenL2TP application event interface definition.
22 *
23 * This plugin is used by OpenL2TP to receive events from pppd.
24 *
25 * Events are used as follows:-
26 * PPP_UPDOWN_IND - tells OpenL2TP of PPP session state changes.
27 * PPP_ACCM_IND - tells OpenL2TP of PPP ACCM negotiated options
28 *
29 * Non-GPL applications are permitted to use this API, provided that
30 * any changes to this source file are made available under GPL terms.
31 */
32
33 #ifndef L2TP_EVENT_H
34 #define L2TP_EVENT_H
35
36 #include <stdint.h>
37
38 /*****************************************************************************
39 * API definition
40 *****************************************************************************/
41
42 #define OPENL2TP_EVENT_SOCKET_NAME "/tmp/openl2tp-event.sock"
43
44 #define OPENL2TP_MSG_TYPE_NULL 0
45 #define OPENL2TP_MSG_TYPE_PPP_UPDOWN_IND 1
46 #define OPENL2TP_MSG_TYPE_PPP_ACCM_IND 2
47 #define OPENL2TP_MSG_TYPE_MAX 3
48
49 enum {
50 OPENL2TP_TLV_TYPE_TUNNEL_ID,
51 OPENL2TP_TLV_TYPE_SESSION_ID,
52 OPENL2TP_TLV_TYPE_PPP_ACCM,
53 OPENL2TP_TLV_TYPE_PPP_UNIT,
54 OPENL2TP_TLV_TYPE_PPP_IFNAME,
55 OPENL2TP_TLV_TYPE_PPP_USER_NAME,
56 OPENL2TP_TLV_TYPE_PPP_STATE
57 };
58 #define OPENL2TP_TLV_TYPE_MAX (OPENL2TP_TLV_TYPE_PPP_STATE + 1)
59
60 #define OPENL2TP_MSG_MAX_LEN 512
61 #define OPENL2TP_MSG_SIGNATURE 0x6b6c7831
62
63 #define ALIGN32(n) (((n) + 3) & ~3)
64
65 /* Each data field in a message is defined by a Type-Length-Value
66 * (TLV) tuplet.
67 */
68 struct openl2tp_event_tlv {
69 uint16_t tlv_type;
70 uint16_t tlv_len;
71 uint8_t tlv_value[0];
72 };
73
74 /* Messages contain a small header followed by a list of TLVs. Each
75 * TLV starts on a 4-byte boundary.
76 */
77 struct openl2tp_event_msg {
78 uint32_t msg_signature; /* OPENL2TP_MSG_SIGNATURE */
79 uint16_t msg_type; /* OPENL2TP_MSG_TYPE_* */
80 uint16_t msg_len; /* length of data that follows */
81 uint8_t msg_data[0]; /* list of TLVs, each always longword aligned */
82 };
83
84 /* These structs define the data field layout of each TLV.
85 */
86 struct openl2tp_tlv_tunnel_id {
87 uint16_t tunnel_id;
88 };
89
90 struct openl2tp_tlv_session_id {
91 uint16_t session_id;
92 };
93
94 struct openl2tp_tlv_ppp_accm {
95 uint32_t send_accm;
96 uint32_t recv_accm;
97 };
98
99 struct openl2tp_tlv_ppp_unit {
100 uint32_t unit;
101 };
102
103 struct openl2tp_tlv_ppp_state {
104 uint8_t up; /* 0=down, 1=up */
105 };
106
107 struct openl2tp_tlv_ppp_ifname {
108 char ifname[0];
109 };
110
111 struct openl2tp_tlv_ppp_user_name {
112 char user_name[0];
113 };
114
115 #endif /* L2TP_EVENT_H */