本文整理汇总了C++中SPtr::addOption方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::addOption方法的具体用法?C++ SPtr::addOption怎么用?C++ SPtr::addOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPtr
的用法示例。
在下文中一共展示了SPtr::addOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendClientData
void TSrvMsgLeaseQueryReply::appendClientData(SPtr<TAddrClient> cli) {
Log(Debug) << "LQ: Appending data for client " << cli->getDUID()->getPlain() << LogEnd;
SPtr<TSrvOptLQClientData> cliData = new TSrvOptLQClientData(this);
SPtr<TAddrIA> ia;
SPtr<TAddrAddr> addr;
SPtr<TAddrPrefix> prefix;
unsigned long nowTs = now();
unsigned long cliTs = cli->getLastTimestamp();
unsigned long diff = nowTs - cliTs;
Log(Debug) << "LQ: modifying the lifetimes (client last seen " << diff << "secs ago)." << LogEnd;
// add all assigned addresses
cli->firstIA();
while ( ia = cli->getIA() ) {
ia->firstAddr();
while ( addr=ia->getAddr() ) {
unsigned long a = addr->getPref() - diff;
unsigned long b = addr->getValid() - diff;
cliData->addOption( new TSrvOptIAAddress(addr->get(), a, b, this) );
}
}
// add all assigned prefixes
cli->firstPD();
while ( ia = cli->getPD() ) {
ia->firstPrefix();
while (prefix = ia->getPrefix()) {
cliData->addOption( new TSrvOptIAPrefix( prefix->getPrefix(), prefix->getLength(), prefix->getPref(),
prefix->getValid(), this));
}
}
cliData->addOption(new TOptDUID(OPTION_CLIENTID, cli->getDUID(), this));
// TODO: add all temporary addresses
// add CLT_TIME
Log(Debug) << "LQ: Adding CLT_TIME option: " << diff << " second(s)." << LogEnd;
cliData->addOption( new TSrvOptLQClientTime(diff, this));
Options.push_back((Ptr*)cliData);
}
示例2: appendRequestedOptions
/* CHANGED in this function: According to RFC3315,'status==STATE_NOTCONFIGURED' is not a must.
* this method adds requested (which have status==STATE_NOTCONFIGURED) options
*/
void TClntMsg::appendRequestedOptions() {
// find configuration specified in config file
SPtr<TClntCfgIface> iface = ClntCfgMgr().getIface(this->Iface);
if (!iface) {
Log(Error) << "Unable to find interface with ifindex=" << this->Iface << LogEnd;
return;
}
if ( (MsgType==SOLICIT_MSG || MsgType==REQUEST_MSG) &&
ClntCfgMgr().getReconfigure())
{
SPtr<TOptEmpty> optReconfigure = new TOptEmpty(OPTION_RECONF_ACCEPT, this);
Options.push_back( (Ptr*) optReconfigure);
}
SPtr<TClntOptOptionRequest> optORO = new TClntOptOptionRequest(iface, this);
if (iface->getUnicast()) {
optORO->addOption(OPTION_UNICAST);
Log(Debug) << "Adding UNICAST to ORO." << LogEnd;
}
if (ClntCfgMgr().addInfRefreshTime()) {
optORO->addOption(OPTION_INFORMATION_REFRESH_TIME);
Log(Debug) << "Adding INFORMATION REFRESH TIME to ORO." << LogEnd;
}
// --- option: DNS-SERVERS ---
if ( iface->isReqDNSServer() ) {
optORO->addOption(OPTION_DNS_SERVERS);
List(TIPv6Addr) * dnsLst = iface->getProposedDNSServerLst();
if (dnsLst->count()) {
// if there are any hints specified in config file, include them
Options.push_back( new TOptAddrLst(OPTION_DNS_SERVERS, *dnsLst, this) );
}
iface->setDNSServerState(STATE_INPROCESS);
}
// --- option: DOMAINS --
if ( iface->isReqDomain() ) {
optORO->addOption(OPTION_DOMAIN_LIST);
List(string) * domainsLst = iface->getProposedDomainLst();
if ( domainsLst->count() ) {
// if there are any hints specified in config file, include them
Options.push_back( new TOptDomainLst(OPTION_DOMAIN_LIST, *domainsLst, this));
}
iface->setDomainState(STATE_INPROCESS);
}
// --- option: NTP SERVER ---
if ( iface->isReqNTPServer() ) {
optORO->addOption(OPTION_SNTP_SERVERS);
List(TIPv6Addr) * ntpLst = iface->getProposedNTPServerLst();
if (ntpLst->count()) {
// if there are any hints specified in config file, include them
Options.push_back( new TOptAddrLst(OPTION_SNTP_SERVERS, *ntpLst, this) );
}
iface->setNTPServerState(STATE_INPROCESS);
}
// --- option: TIMEZONE ---
if ( iface->isReqTimezone() ) {
optORO->addOption(OPTION_NEW_TZDB_TIMEZONE);
string timezone = iface->getProposedTimezone();
if (timezone.length()) {
// if there are any hints specified in config file, include them
SPtr<TClntOptTimeZone> opt = new TClntOptTimeZone(timezone,this);
Options.push_back( (Ptr*)opt );
}
iface->setTimezoneState(STATE_INPROCESS);
}
// --- option: SIP-SERVERS ---
if ( iface->isReqSIPServer() ) {
optORO->addOption(OPTION_SIP_SERVER_A);
List(TIPv6Addr) * lst = iface->getProposedSIPServerLst();
if ( lst->count()) {
// if there are any hints specified in config file, include them
Options.push_back( new TOptAddrLst(OPTION_SIP_SERVER_A, *lst, this ) );
}
iface->setSIPServerState(STATE_INPROCESS);
}
// --- option: SIP-DOMAINS ---
if ( iface->isReqSIPDomain() ) {
optORO->addOption(OPTION_SIP_SERVER_D);
List(string) * domainsLst = iface->getProposedSIPDomainLst();
if ( domainsLst->count() ) {
// if there are any hints specified in config file, include them
Options.push_back( new TOptDomainLst(OPTION_SIP_SERVER_D, *domainsLst, this ));
//.........这里部分代码省略.........
示例3: appendAuthenticationOption
/**
* @brief appends authentication option.
*
*/
void TClntMsg::appendAuthenticationOption()
{
#ifndef MOD_DISABLE_AUTH
uint8_t algorithm = 0; // algorithm is protocol specific
DigestType_ = DIGEST_NONE;
// ClntAddrMgr().firstClient();
// SPtr<TAddrClient> client = ClntAddrMgr().getClient();
string realm;
switch (ClntCfgMgr().getAuthProtocol()) {
case AUTH_PROTO_NONE: {
algorithm = 0;
// Do not sent AUTH with proto=0.
return;
}
case AUTH_PROTO_DELAYED: {
algorithm = 1;
realm = ClntCfgMgr().getAuthRealm();
break;
}
case AUTH_PROTO_RECONFIGURE_KEY: { // RFC 3315, section 21.5.1
// When reconfigure-key is enabled, client does not send anything
return;
}
case AUTH_PROTO_DIBBLER: { // Mechanism proposed by Kowalczuk
DigestType_ = ClntCfgMgr().getDigest();
algorithm = static_cast<uint8_t>(DigestType_);
setSPI(ClntCfgMgr().getSPI());
SPtr<TClntOptOptionRequest> optORO = (Ptr*) getOption(OPTION_ORO);
if (optORO) {
// request Authentication
optORO->addOption(OPTION_AUTH);
}
break;
}
default: {
Log(Error) << "Auth: Invalid protocol specified. Can't sent AUTH option." << LogEnd;
return;
}
}
SPtr<TOptAuthentication> auth =
new TOptAuthentication(ClntCfgMgr().getAuthProtocol(),
algorithm,
ClntCfgMgr().getAuthReplay(), this);
// Realm is used by delayed-auth only. Even fro delayed-auth, it is set
// only for non-SOLICIT messages
if (MsgType != SOLICIT_MSG && !realm.empty()) {
auth->setRealm(realm);
}
// replay detection
if (ClntCfgMgr().getAuthReplay() == AUTH_REPLAY_MONOTONIC) {
auth->setReplayDetection(ClntAddrMgr().getNextReplayDetectionValue());
}
addOption((Ptr*)auth);
// otherwise replay value is zero
#endif
}