2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #include "NetworkTargetHostInterfaceInfo.h"
7 #include <AutoDeleter.h>
9 #include "NetworkTargetHostInterface.h"
10 #include "SettingsDescription.h"
14 static const char* kHostnameSetting
= "hostname";
15 static const char* kPortSetting
= "port";
18 NetworkTargetHostInterfaceInfo::NetworkTargetHostInterfaceInfo()
20 TargetHostInterfaceInfo("Network"),
26 NetworkTargetHostInterfaceInfo::~NetworkTargetHostInterfaceInfo()
33 NetworkTargetHostInterfaceInfo::Init()
35 fDescription
= new(std::nothrow
) SettingsDescription
;
36 if (fDescription
== NULL
)
39 Setting
* setting
= new(std::nothrow
) StringSettingImpl(kHostnameSetting
,
43 ObjectDeleter
<Setting
> settingDeleter(setting
);
44 if (!fDescription
->AddSetting(setting
))
47 settingDeleter
.Detach();
48 setting
= new(std::nothrow
) BoundedSettingImpl(kPortSetting
, "Port",
49 (uint16
)0, (uint16
)65535, (uint16
)8305);
52 if (!fDescription
->AddSetting(setting
)) {
62 NetworkTargetHostInterfaceInfo::IsLocal() const
69 NetworkTargetHostInterfaceInfo::IsConfigured(Settings
* settings
) const
76 NetworkTargetHostInterfaceInfo::GetSettingsDescription() const
83 NetworkTargetHostInterfaceInfo::CreateInterface(Settings
* settings
,
84 TargetHostInterface
*& _interface
) const
86 NetworkTargetHostInterface
* interface
87 = new(std::nothrow
) NetworkTargetHostInterface
;
88 if (interface
== NULL
)
91 status_t error
= interface
->Init(settings
);
97 _interface
= interface
;