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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* Dibbler - a portable DHCPv6
*
* authors: Tomasz Mrugalski <thomson@klub.com.pl>
* Marek Senderski <msend@o2.pl>
* changes: Michal Kowalczuk <michal@kowalczuk.eu>
*
* released under GNU GPL v2 only licence
*
*/
#include <sstream>
#include "ClntMsgAdvertise.h"
#include "OptInteger.h"
#include "OptDUID.h"
#include "ClntOptPreference.h"
using namespace std;
/*
* creates buffer based on buffer
*/
TClntMsgAdvertise::TClntMsgAdvertise(int iface, SPtr<TIPv6Addr> addr,
char* buf, int buflen)
:TClntMsg(iface,addr,buf,buflen) {
}
bool TClntMsgAdvertise::check() {
return TClntMsg::check(true /* clientID mandatory */, true /* serverID mandatory */ );
}
int TClntMsgAdvertise::getPreference() {
SPtr<TOptInteger> ptr;
ptr = (Ptr*) this->getOption(OPTION_PREFERENCE);
if (!ptr)
return 0;
return ptr->getValue();
}
void TClntMsgAdvertise::answer(SPtr<TClntMsg> Rep) {
// this should never happen
}
void TClntMsgAdvertise::doDuties() {
// this should never happen
}
string TClntMsgAdvertise::getName() const {
return "ADVERTISE";
}
string TClntMsgAdvertise::getInfo()
{
ostringstream tmp;
SPtr<TClntOptPreference> pref;
SPtr<TOptDUID> srvID;
pref = (Ptr*) getOption(OPTION_PREFERENCE);
srvID = (Ptr*) getOption(OPTION_SERVERID);
if (srvID) {
tmp << "Server ID=" << srvID->getDUID()->getPlain();
} else {
tmp << "malformed (Server ID option missing)";
}
if (pref) {
tmp << ", preference=" << pref->getValue();
} else {
tmp << ", no preference option, assumed 0";
}
return tmp.str();
}
TClntMsgAdvertise::~TClntMsgAdvertise() {
}
|