blob: 936d33f65868a06ad06f2fbed42e85520bb0a263 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 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 */
San Mehat3c5a6f02009-05-22 15:36:13 -070016
San Mehatdc266072009-05-06 11:16:52 -070017#include <stdlib.h>
18#include <errno.h>
19
20#define LOG_TAG "Nexus"
21
22#include "cutils/log.h"
23#include "NetworkManager.h"
San Mehat1441e762009-05-07 11:37:10 -070024#include "CommandListener.h"
25
26#include "LoopController.h"
San Mehat94447ca2009-05-13 11:54:16 -070027#include "OpenVpnController.h"
San Mehat1441e762009-05-07 11:37:10 -070028#include "TiwlanWifiController.h"
San Mehatdc266072009-05-06 11:16:52 -070029
30int main() {
San Mehatdc266072009-05-06 11:16:52 -070031 LOGI("Nexus version 0.1 firing up");
32
San Mehat1441e762009-05-07 11:37:10 -070033 CommandListener *cl = new CommandListener();
34
35 NetworkManager *nm;
36 if (!(nm = NetworkManager::Instance())) {
San Mehatdc266072009-05-06 11:16:52 -070037 LOGE("Unable to create NetworkManager");
38 exit (-1);
39 };
40
San Mehat1441e762009-05-07 11:37:10 -070041 nm->setBroadcaster((SocketListener *) cl);
42
San Mehat3aff2d12009-06-15 14:10:44 -070043 nm->attachController(new LoopController(nm->getPropMngr(), nm));
44 nm->attachController(new TiwlanWifiController(nm->getPropMngr(), nm, "/system/lib/modules/wlan.ko", "wlan", ""));
45// nm->attachController(new AndroidL2TPVpnController(nm->getPropMngr(), nm));
46 nm->attachController(new OpenVpnController(nm->getPropMngr(), nm));
San Mehat1441e762009-05-07 11:37:10 -070047
48
49 if (NetworkManager::Instance()->run()) {
San Mehatdc266072009-05-06 11:16:52 -070050 LOGE("Unable to Run NetworkManager (%s)", strerror(errno));
51 exit (1);
52 }
53
San Mehat1441e762009-05-07 11:37:10 -070054 if (cl->startListener()) {
San Mehat94447ca2009-05-13 11:54:16 -070055 LOGE("Unable to start CommandListener (%s)", strerror(errno));
San Mehat1441e762009-05-07 11:37:10 -070056 exit (1);
57 }
58
San Mehat94447ca2009-05-13 11:54:16 -070059 // XXX: we'll use the main thread for the NetworkManager eventually
San Mehat3c5a6f02009-05-22 15:36:13 -070060
San Mehat1441e762009-05-07 11:37:10 -070061 while(1) {
62 sleep(1000);
63 }
64
San Mehatdc266072009-05-06 11:16:52 -070065 LOGI("Nexus exiting");
66 exit(0);
67}