blob: d97f20b2dceb1db234aa7f80eb91517e089fc052 [file] [log] [blame]
San Mehat192331d2009-05-22 13:58:06 -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 */
16
17#ifndef _INTERFACE_CONFIG_H
18#define _INTERFACE_CONFIG_H
19
San Mehat3c5a6f02009-05-22 15:36:13 -070020#include <unistd.h>
21#include <sys/types.h>
San Mehat192331d2009-05-22 13:58:06 -070022#include <netinet/in.h>
23#include <arpa/inet.h>
24
San Mehat3c5a6f02009-05-22 15:36:13 -070025#include "IPropertyProvider.h"
26
27class PropertyManager;
28
29class InterfaceConfig : public IPropertyProvider {
30public:
31 static const char *PropertyNames[];
32
San Mehat192331d2009-05-22 13:58:06 -070033private:
San Mehat3c5a6f02009-05-22 15:36:13 -070034 char *mPropPrefix;
San Mehat192331d2009-05-22 13:58:06 -070035 bool mUseDhcp;
36 struct in_addr mIp;
37 struct in_addr mNetmask;
38 struct in_addr mGateway;
39 struct in_addr mDns1;
40 struct in_addr mDns2;
41 struct in_addr mDns3;
42
43public:
San Mehat3c5a6f02009-05-22 15:36:13 -070044 InterfaceConfig(const char *prop_prefix);
45 InterfaceConfig(const char *prop_prefix,
46 const char *ip, const char *nm,
San Mehat192331d2009-05-22 13:58:06 -070047 const char *gw, const char *dns1, const char *dns2,
48 const char *dns3);
49
San Mehat3c5a6f02009-05-22 15:36:13 -070050 InterfaceConfig(const char *prop_prefix,
51 const struct in_addr *ip,
San Mehat192331d2009-05-22 13:58:06 -070052 const struct in_addr *nm, const struct in_addr *gw,
53 const struct in_addr *dns1, const struct in_addr *dns2,
54 const struct in_addr *dns3);
55
56 virtual ~InterfaceConfig();
San Mehat3c5a6f02009-05-22 15:36:13 -070057
58 int set(const char *name, const char *value);
59 const char *get(const char *name, char *buffer, size_t maxsize);
San Mehat192331d2009-05-22 13:58:06 -070060
San Mehat192331d2009-05-22 13:58:06 -070061 bool getUseDhcp() const { return mUseDhcp; }
62 const struct in_addr &getIp() const { return mIp; }
63 const struct in_addr &getNetmask() const { return mNetmask; }
64 const struct in_addr &getGateway() const { return mGateway; }
65 const struct in_addr &getDns1() const { return mDns1; }
66 const struct in_addr &getDns2() const { return mDns2; }
67 const struct in_addr &getDns3() const { return mDns3; }
San Mehat3c5a6f02009-05-22 15:36:13 -070068
69private:
70 int registerProperties();
71 int unregisterProperties();
San Mehat192331d2009-05-22 13:58:06 -070072};
73
74
75#endif