blob: 290a5831cf6e90ea3b39bb4a875a870dd4ad2a84 [file] [log] [blame]
Chia-chi Yeh79e62322009-06-02 08:49:55 +08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __MTPD_H__
18#define __MTPD_H__
19
Elliott Hughes04bd5fc2013-11-12 11:19:48 -080020#if !defined(PX_PROTO_OLAC)
21#define USING_UAPI
22#endif
23
24#if defined(USING_UAPI)
25/* This stuff isn't in uapi. */
26#define PX_PROTO_OLAC 3
27#define PX_PROTO_OPNS 4
28
29struct sockaddr_pppopns {
30 sa_family_t sa_family;
31 unsigned int sa_protocol;
32 int tcp_socket;
33 uint16_t local;
34 uint16_t remote;
35} __attribute__((packed));
36
37struct sockaddr_pppolac {
38 sa_family_t sa_family;
39 unsigned int sa_protocol;
40 int udp_socket;
41 struct __attribute__((packed)) {
42 uint16_t tunnel;
43 uint16_t session;
44 } local, remote;
45} __attribute__((packed));
46#endif
47
Chia-chi Yeh79e62322009-06-02 08:49:55 +080048/* The socket to the server. */
49extern int the_socket;
50
51enum exit_code {
Chia-chi Yeh7b66d202011-06-28 16:39:23 -070052 SYSTEM_ERROR = 1,
53 NETWORK_ERROR = 2,
54 PROTOCOL_ERROR = 3,
55 CHALLENGE_FAILED = 4,
56 USER_REQUESTED = 5,
57 REMOTE_REQUESTED = 6,
Chia-chi Yeh79e62322009-06-02 08:49:55 +080058 PPPD_EXITED = 32,
59};
60
61enum log_level {
62 DEBUG = 0,
63 INFO = 1,
64 WARNING = 2,
65 ERROR = 3,
66 FATAL = 4,
67 LOG_MAX = 4,
68};
69
70void log_print(int level, char *format, ...);
71void create_socket(int family, int type, char *server, char *port);
72void start_pppd(int pppox);
Sam Protsenko28cfaab2017-10-30 17:02:26 +020073void start_pppd_ol2tp(int tunnel_fd, int session_fd, int tunnel_id,
74 int session_id);
Sam Protsenko0368bbd2018-06-08 01:11:16 +030075void start_pppd_pptp(int pptp_fd);
Chia-chi Yeh79e62322009-06-02 08:49:55 +080076
77/* Each protocol must implement everything defined in this structure. Note that
78 * timeout intervals are in milliseconds, where zero means forever. To indicate
79 * an error, one should use a negative exit code such as -REMOTE_REQUESTED. */
80struct protocol {
Chia-chi Yeh7b66d202011-06-28 16:39:23 -070081 /* The name of this protocol. */
Chia-chi Yeh79e62322009-06-02 08:49:55 +080082 char *name;
Chia-chi Yeh7b66d202011-06-28 16:39:23 -070083 /* The number of arguments. */
84 int arguments;
85 /* The usage of the arguments. */
Chia-chi Yeh79e62322009-06-02 08:49:55 +080086 char *usage;
87 /* Connect to the server and return the next timeout interval. */
Chia-chi Yeh7b66d202011-06-28 16:39:23 -070088 int (*connect)(char **arguments);
Chia-chi Yeh79e62322009-06-02 08:49:55 +080089 /* Process the incoming packet and return the next timeout interval. */
90 int (*process)();
91 /* Handle the timeout event and return the next timeout interval. */
92 int (*timeout)();
93 /* Handle the shutdown event. */
94 void (*shutdown)();
95};
96
97#endif /* __MTPD_H__ */