1 /* 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 20 /* The socket to the server. */ 21 extern int the_socket; 22 23 enum exit_code { 24 USAGE_ERROR = 1, 25 SYSTEM_ERROR = 2, 26 NETWORK_ERROR = 3, 27 PROTOCOL_ERROR = 4, 28 CHALLENGE_FAILED = 5, 29 USER_REQUESTED = 6, 30 REMOTE_REQUESTED = 7, 31 PPPD_EXITED = 32, 32 }; 33 34 enum log_level { 35 DEBUG = 0, 36 INFO = 1, 37 WARNING = 2, 38 ERROR = 3, 39 FATAL = 4, 40 LOG_MAX = 4, 41 }; 42 43 void log_print(int level, char *format, ...); 44 void create_socket(int family, int type, char *server, char *port); 45 void start_pppd(int pppox); 46 47 /* Each protocol must implement everything defined in this structure. Note that 48 * timeout intervals are in milliseconds, where zero means forever. To indicate 49 * an error, one should use a negative exit code such as -REMOTE_REQUESTED. */ 50 struct protocol { 51 /* The name specified in the first argument. */ 52 char *name; 53 /* The usage of the rest of the arguments. */ 54 char *usage; 55 /* Connect to the server and return the next timeout interval. */ 56 int (*connect)(int argc, char **argv); 57 /* Process the incoming packet and return the next timeout interval. */ 58 int (*process)(); 59 /* Handle the timeout event and return the next timeout interval. */ 60 int (*timeout)(); 61 /* Handle the shutdown event. */ 62 void (*shutdown)(); 63 }; 64 65 #endif /* __MTPD_H__ */ 66