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