1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
* Dibbler - a portable DHCPv6
*
* authors: Tomasz Mrugalski <thomson@klub.com.pl>
* Marek Senderski <msend@o2.pl>
*
* released under GNU GPL v2 licence
*/
#include "ClntOptTimeZone.h"
#include "OptDUID.h"
#include "ClntMsg.h"
#include "Logger.h"
TClntOptTimeZone::TClntOptTimeZone(const std::string& domain, TMsg* parent)
:TOptString(OPTION_NEW_TZDB_TIMEZONE, domain, parent) {
}
TClntOptTimeZone::TClntOptTimeZone(char *buf, int bufsize, TMsg* parent)
:TOptString(OPTION_NEW_TZDB_TIMEZONE, buf,bufsize, parent) {
/// @todo: do some validity check
}
bool TClntOptTimeZone::isValid() const {
/// @todo: check is somehow
return true;
}
bool TClntOptTimeZone::doDuties() {
std::string reason = "trying to set time zone.";
int ifindex = Parent->getIface();
SPtr<TOptDUID> duid = (Ptr*)Parent->getOption(OPTION_SERVERID);
if (!duid) {
Log(Error) << "Unable to find proper DUID while " << reason << LogEnd;
return false;
}
SPtr<TClntIfaceIface> iface = (Ptr*)ClntIfaceMgr().getIfaceByID(ifindex);
if (!iface) {
Log(Error) << "Unable to find interface ifindex=" << ifindex
<< reason << LogEnd;
return false;
}
SPtr<TClntCfgIface> cfgIface = ClntCfgMgr().getIface(ifindex);
cfgIface->setTimezoneState(STATE_CONFIGURED);
return iface->setTimezone(duid->getDUID(), Parent->getRemoteAddr(), Str);
}
/// @todo remove this
void TClntOptTimeZone::setSrvDuid(SPtr<TDUID> duid) {
SrvDUID=duid;
}
|