1 /*
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 */
16
17 #include <stdlib.h>
18 #include <errno.h>
19
20 #define LOG_TAG "Nexus"
21
22 #include "cutils/log.h"
23 #include "NetworkManager.h"
24 #include "CommandListener.h"
25
26 #include "LoopController.h"
27 #include "OpenVpnController.h"
28 #include "TiwlanWifiController.h"
29
main()30 int main() {
31 LOGI("Nexus version 0.1 firing up");
32
33 CommandListener *cl = new CommandListener();
34
35 NetworkManager *nm;
36 if (!(nm = NetworkManager::Instance())) {
37 LOGE("Unable to create NetworkManager");
38 exit (-1);
39 };
40
41 nm->setBroadcaster((SocketListener *) cl);
42
43 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));
47
48
49 if (NetworkManager::Instance()->run()) {
50 LOGE("Unable to Run NetworkManager (%s)", strerror(errno));
51 exit (1);
52 }
53
54 if (cl->startListener()) {
55 LOGE("Unable to start CommandListener (%s)", strerror(errno));
56 exit (1);
57 }
58
59 // XXX: we'll use the main thread for the NetworkManager eventually
60
61 while(1) {
62 sleep(1000);
63 }
64
65 LOGI("Nexus exiting");
66 exit(0);
67 }
68