blob: e75382d593c23232f627c1f7426e8e19aa2ddbc1 [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#ifndef _NETWORKMANAGER_H
18#define _NETWORKMANAGER_H
19
San Mehat1441e762009-05-07 11:37:10 -070020#include <sysutils/SocketListener.h>
San Mehatdc266072009-05-06 11:16:52 -070021
San Mehat1441e762009-05-07 11:37:10 -070022#include "Controller.h"
San Mehat3c5a6f02009-05-22 15:36:13 -070023
24#include "PropertyManager.h"
San Mehatdc266072009-05-06 11:16:52 -070025
San Mehat192331d2009-05-22 13:58:06 -070026class InterfaceConfig;
27
San Mehatdc266072009-05-06 11:16:52 -070028class NetworkManager {
29private:
San Mehat1441e762009-05-07 11:37:10 -070030 static NetworkManager *sInstance;
31
32private:
San Mehatdc266072009-05-06 11:16:52 -070033 ControllerCollection *mControllers;
San Mehat1441e762009-05-07 11:37:10 -070034 SocketListener *mBroadcaster;
San Mehat3c5a6f02009-05-22 15:36:13 -070035 PropertyManager *mPropMngr;
San Mehatdc266072009-05-06 11:16:52 -070036
37public:
San Mehat3c5a6f02009-05-22 15:36:13 -070038 virtual ~NetworkManager();
San Mehatdc266072009-05-06 11:16:52 -070039
40 int run();
41
San Mehat1441e762009-05-07 11:37:10 -070042 int attachController(Controller *controller);
43
44 Controller *findController(const char *name);
45
46 void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; }
47 SocketListener *getBroadcaster() { return mBroadcaster; }
San Mehat3c5a6f02009-05-22 15:36:13 -070048 PropertyManager *getPropMngr() { return mPropMngr; }
San Mehat1441e762009-05-07 11:37:10 -070049
50 static NetworkManager *Instance();
51
San Mehatdc266072009-05-06 11:16:52 -070052private:
San Mehatdc266072009-05-06 11:16:52 -070053 int startControllers();
54 int stopControllers();
San Mehat48765672009-05-20 15:28:43 -070055
San Mehat3c5a6f02009-05-22 15:36:13 -070056 NetworkManager(PropertyManager *propMngr);
San Mehatdc266072009-05-06 11:16:52 -070057
58public:
San Mehat192331d2009-05-22 13:58:06 -070059 /*
60 * Called from a controller when an interface is available/ready for use.
61 * 'cfg' contains information on how this interface should be configured.
62 */
63 int onInterfaceStart(Controller *c, const InterfaceConfig *cfg);
San Mehatdc266072009-05-06 11:16:52 -070064
San Mehat192331d2009-05-22 13:58:06 -070065 /*
66 * Called from a controller when an interface should be shut down
67 */
68 int onInterfaceStop(Controller *c, const char *name);
San Mehatdc266072009-05-06 11:16:52 -070069};
70#endif