File: OptPreference.cpp

package info (click to toggle)
dibbler 0.7.3-1.3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,148 kB
  • ctags: 8,720
  • sloc: cpp: 54,863; sh: 9,389; ansic: 8,659; yacc: 2,570; makefile: 1,061; lex: 842; perl: 49; xml: 6
file content (61 lines) | stat: -rw-r--r-- 1,201 bytes parent folder | download | duplicates (2)
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
/*
 * Dibbler - a portable DHCPv6
 *
 * authors: Tomasz Mrugalski <thomson@klub.com.pl>
 *          Marek Senderski <msend@o2.pl>
 *
 * released under GNU GPL v2 licence
 *
 * $Id: OptPreference.cpp,v 1.3 2004-10-25 20:45:53 thomson Exp $
 *
 * $Log: OptPreference.cpp,v $
 * Revision 1.3  2004-10-25 20:45:53  thomson
 * Option support, parsers rewritten. ClntIfaceMgr now handles options.
 *
 * Revision 1.2  2004/03/29 18:53:08  thomson
 * Author/Licence/cvs log/cvs version headers added.
 *
 *
 */
#ifdef WIN32
#include <winsock2.h>
#endif
#ifdef LINUX
#include <netinet/in.h>
#endif 
#include "DHCPConst.h"
#include "OptPreference.h"

TOptPreference::TOptPreference( char * &buf,  int &n, TMsg* parent)
	:TOpt(OPTION_PREFERENCE, parent)
{
	this->Pref=buf[0];
	buf++; n--;
}

TOptPreference::TOptPreference( char pref, TMsg* parent)
	:TOpt(OPTION_PREFERENCE, parent)
{
    Pref = pref;
}

 int TOptPreference::getSize()
{
    return 5;
}


 char * TOptPreference::storeSelf( char* buf)
{
    *(uint16_t*)buf = htons(OptType);
    buf+=2;
    *(uint16_t*)buf = htons(getSize() - 4);
    buf+=2;
    *buf = Pref;
    return buf+1;
}

int TOptPreference::getPreference(void)
{
	return this->Pref;
}