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 78 79
|
/*
* Dibbler - a portable DHCPv6
*
* authors: Tomasz Mrugalski <thomson@klub.com.pl>
* Marek Senderski <msend@o2.pl>
*
* released under GNU GPL v2 licence
*
* $Id: OptDUID.cpp,v 1.2 2006-03-05 21:37:46 thomson Exp $
*
* $Log: OptDUID.cpp,v $
* Revision 1.2 2006-03-05 21:37:46 thomson
* TA support merged.
*
* Revision 1.1.2.1 2006/02/05 23:38:08 thomson
* Devel branch with Temporary addresses support added.
*
* Revision 1.1 2006/01/29 10:46:46 thomson
* Opt{Client|Server}Identifier classes removed, OptDUID added.
*
* Revision 1.3 2004/03/29 18:53:08 thomson
* Author/Licence/cvs log/cvs version headers added.
*
*
*/
#include <stdlib.h>
#ifdef WIN32
#include <winsock2.h>
#endif
#ifdef LINUX
#include <netinet/in.h>
#endif
#include "DHCPConst.h"
#include "OptDUID.h"
TOptDUID::TOptDUID(int type, SmartPtr<TDUID> duid, TMsg* parent)
:TOpt(type, parent)
{
this->DUID=duid;
}
int TOptDUID::getSize()
{
if (this->DUID)
return this->DUID->getLen()+4;
return 4;
}
char * TOptDUID::storeSelf( char* buf)
{
*(uint16_t*)buf = htons(OptType);
buf+=2;
*(uint16_t*)buf = htons(DUID->getLen());
buf+=2;
return this->DUID->storeSelf(buf);
}
TOptDUID::TOptDUID(int type, char* &buf, int &bufsize, TMsg* parent)
:TOpt(type, parent)
{
this->DUID=new TDUID(buf,bufsize);
buf+=DUID->getLen();
bufsize-=DUID->getLen();
}
SmartPtr<TDUID> TOptDUID::getDUID()
{
return DUID;
}
bool TOptDUID::isValid()
{
if (this->getDUID()->getLen()>2)
return true;
return false;
}
|