Home | History | Annotate | Download | only in pppd
      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 #include <unistd.h>
     18 #include "pppd.h"
     19 
     20 static int pppox_set(char **);
     21 static int pppox_connect();
     22 static void pppox_disconnect();
     23 
     24 static option_t pppox_options[] = {
     25     {"pppox", o_special, pppox_set, "PPPoX socket", OPT_DEVNAM},
     26     {NULL},
     27 };
     28 
     29 static struct channel pppox_channel = {
     30     .options = pppox_options,
     31     .process_extra_options = NULL,
     32     .check_options = NULL,
     33     .connect = pppox_connect,
     34     .disconnect = pppox_disconnect,
     35     .establish_ppp = generic_establish_ppp,
     36     .disestablish_ppp = generic_disestablish_ppp,
     37     .send_config = NULL,
     38     .recv_config = NULL,
     39     .cleanup = NULL,
     40     .close = NULL,
     41 };
     42 
     43 static int pppox = -1;
     44 
     45 static int pppox_set(char **argv) {
     46     if (!int_option(*argv, &pppox)) {
     47         return 0;
     48     }
     49     info("Using PPPoX (socket = %d)", pppox);
     50     the_channel = &pppox_channel;
     51     return 1;
     52 }
     53 
     54 static int pppox_connect() {
     55     return pppox;
     56 }
     57 
     58 static void pppox_disconnect() {
     59     if (pppox != -1) {
     60         close(pppox);
     61         pppox = -1;
     62     }
     63 }
     64 
     65 void pppox_init() {
     66     add_options(pppox_options);
     67 }
     68