blob: 44f3417fd22b19c6360f0ec3fadd98fffea64f31 [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#include "PropertyManager.h"
San Mehat3aff2d12009-06-15 14:10:44 -070024#include "IControllerHandler.h"
San Mehatd6c67962009-06-22 10:39:36 -070025#include "IDhcpEventHandlers.h"
San Mehatdc266072009-05-06 11:16:52 -070026
San Mehat192331d2009-05-22 13:58:06 -070027class InterfaceConfig;
San Mehatd6c67962009-06-22 10:39:36 -070028class DhcpClient;
San Mehat192331d2009-05-22 13:58:06 -070029
San Mehatd6c67962009-06-22 10:39:36 -070030class NetworkManager : public IControllerHandler, public IDhcpEventHandlers {
San Mehatdc266072009-05-06 11:16:52 -070031private:
San Mehat1441e762009-05-07 11:37:10 -070032 static NetworkManager *sInstance;
33
34private:
San Mehatdc266072009-05-06 11:16:52 -070035 ControllerCollection *mControllers;
San Mehat1441e762009-05-07 11:37:10 -070036 SocketListener *mBroadcaster;
San Mehat3c5a6f02009-05-22 15:36:13 -070037 PropertyManager *mPropMngr;
San Mehatd6c67962009-06-22 10:39:36 -070038 DhcpClient *mDhcp;
San Mehatdc266072009-05-06 11:16:52 -070039
40public:
San Mehat3c5a6f02009-05-22 15:36:13 -070041 virtual ~NetworkManager();
San Mehatdc266072009-05-06 11:16:52 -070042
43 int run();
44
San Mehat1441e762009-05-07 11:37:10 -070045 int attachController(Controller *controller);
46
47 Controller *findController(const char *name);
48
49 void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; }
50 SocketListener *getBroadcaster() { return mBroadcaster; }
San Mehat3c5a6f02009-05-22 15:36:13 -070051 PropertyManager *getPropMngr() { return mPropMngr; }
San Mehat1441e762009-05-07 11:37:10 -070052
53 static NetworkManager *Instance();
54
San Mehatdc266072009-05-06 11:16:52 -070055private:
San Mehatdc266072009-05-06 11:16:52 -070056 int startControllers();
57 int stopControllers();
San Mehat48765672009-05-20 15:28:43 -070058
San Mehat3c5a6f02009-05-22 15:36:13 -070059 NetworkManager(PropertyManager *propMngr);
San Mehatdc266072009-05-06 11:16:52 -070060
San Mehatd6c67962009-06-22 10:39:36 -070061 void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg);
62 void onInterfaceDisconnected(Controller *c, const char *name);
San Mehatdc266072009-05-06 11:16:52 -070063};
64#endif