98 lines
2.6 KiB
C
98 lines
2.6 KiB
C
|
/*
|
||
|
* Copyright (C) 2009 The Android Open Source Project
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
#ifndef __MTPD_H__
|
||
|
#define __MTPD_H__
|
||
|
|
||
|
#if !defined(PX_PROTO_OLAC)
|
||
|
#define USING_UAPI
|
||
|
#endif
|
||
|
|
||
|
#if defined(USING_UAPI)
|
||
|
/* This stuff isn't in uapi. */
|
||
|
#define PX_PROTO_OLAC 3
|
||
|
#define PX_PROTO_OPNS 4
|
||
|
|
||
|
struct sockaddr_pppopns {
|
||
|
sa_family_t sa_family;
|
||
|
unsigned int sa_protocol;
|
||
|
int tcp_socket;
|
||
|
uint16_t local;
|
||
|
uint16_t remote;
|
||
|
} __attribute__((packed));
|
||
|
|
||
|
struct sockaddr_pppolac {
|
||
|
sa_family_t sa_family;
|
||
|
unsigned int sa_protocol;
|
||
|
int udp_socket;
|
||
|
struct __attribute__((packed)) {
|
||
|
uint16_t tunnel;
|
||
|
uint16_t session;
|
||
|
} local, remote;
|
||
|
} __attribute__((packed));
|
||
|
#endif
|
||
|
|
||
|
/* The socket to the server. */
|
||
|
extern int the_socket;
|
||
|
|
||
|
enum exit_code {
|
||
|
SYSTEM_ERROR = 1,
|
||
|
NETWORK_ERROR = 2,
|
||
|
PROTOCOL_ERROR = 3,
|
||
|
CHALLENGE_FAILED = 4,
|
||
|
USER_REQUESTED = 5,
|
||
|
REMOTE_REQUESTED = 6,
|
||
|
PPPD_EXITED = 32,
|
||
|
};
|
||
|
|
||
|
enum log_level {
|
||
|
DEBUG = 0,
|
||
|
INFO = 1,
|
||
|
WARNING = 2,
|
||
|
ERROR = 3,
|
||
|
FATAL = 4,
|
||
|
LOG_MAX = 4,
|
||
|
};
|
||
|
|
||
|
void log_print(int level, char *format, ...);
|
||
|
void create_socket(int family, int type, char *server, char *port);
|
||
|
void start_pppd(int pppox);
|
||
|
void start_pppd_ol2tp(int tunnel_fd, int session_fd, int tunnel_id,
|
||
|
int session_id);
|
||
|
void start_pppd_pptp(int pptp_fd);
|
||
|
|
||
|
/* Each protocol must implement everything defined in this structure. Note that
|
||
|
* timeout intervals are in milliseconds, where zero means forever. To indicate
|
||
|
* an error, one should use a negative exit code such as -REMOTE_REQUESTED. */
|
||
|
struct protocol {
|
||
|
/* The name of this protocol. */
|
||
|
char *name;
|
||
|
/* The number of arguments. */
|
||
|
int arguments;
|
||
|
/* The usage of the arguments. */
|
||
|
char *usage;
|
||
|
/* Connect to the server and return the next timeout interval. */
|
||
|
int (*connect)(char **arguments);
|
||
|
/* Process the incoming packet and return the next timeout interval. */
|
||
|
int (*process)();
|
||
|
/* Handle the timeout event and return the next timeout interval. */
|
||
|
int (*timeout)();
|
||
|
/* Handle the shutdown event. */
|
||
|
void (*shutdown)();
|
||
|
};
|
||
|
|
||
|
#endif /* __MTPD_H__ */
|