1 #ifndef PACKETPP_DHCP_LAYER 2 #define PACKETPP_DHCP_LAYER 420 if (
getTotalSize() - 2*
sizeof(uint8_t) - valueOffset <
sizeof(T))
424 memcpy(&result, value+valueOffset,
sizeof(T));
434 uint32_t addrAsInt = getValueAs<uint32_t>();
447 if (len-valueOffset < 1)
450 return std::string((
char*)value+valueOffset, len-valueOffset);
464 memcpy(value+valueOffset, &newValue,
sizeof(T));
476 setValue<uint32_t>(addr.
toInt(), valueOffset);
489 std::string val = stringValue;
490 if (stringValue.length() > (size_t)len-(
size_t)valueOffset)
491 val = stringValue.substr(0, len-valueOffset);
493 memcpy(value+valueOffset, val.c_str(), val.length());
503 return sizeof(uint8_t);
505 return sizeof(uint8_t)*2 + (
size_t)
len;
744 size_t m_DhcpOptionsCount;
746 void initDhcpLayer(
size_t numOfBytesToAllocate);
Definition: DhcpLayer.h:326
Definition: DhcpLayer.h:348
DhcpOptionData * addOptionAfter(DhcpOptionTypes optionType, uint16_t optionLen, const uint8_t *optionData, DhcpOptionTypes prevOption)
Definition: DhcpLayer.h:128
Definition: DhcpLayer.h:322
Definition: DhcpLayer.h:126
Definition: DhcpLayer.h:138
Definition: DhcpLayer.h:184
Definition: DhcpLayer.h:174
IPv4Address getClientIpAddress()
Definition: DhcpLayer.h:112
Definition: DhcpLayer.h:396
Definition: DhcpLayer.h:82
Definition: DhcpLayer.h:362
Definition: DhcpLayer.h:98
Definition: DhcpLayer.h:350
void setValueString(const std::string &stringValue, int valueOffset=0)
Definition: DhcpLayer.h:487
void setClientIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:324
void computeCalculateFields()
Definition: DhcpLayer.h:80
DhcpOptionData * getFirstOptionData()
Definition: DhcpLayer.h:100
DhcpOptionTypes getType()
Definition: DhcpLayer.h:522
Definition: DhcpLayer.h:206
Definition: DhcpLayer.h:66
Definition: DhcpLayer.h:186
Definition: DhcpLayer.h:382
Definition: DhcpLayer.h:132
Definition: DhcpLayer.h:214
Definition: DhcpLayer.h:304
Definition: DhcpLayer.h:246
Definition: DhcpLayer.h:198
void setGatewayIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:23
Definition: DhcpLayer.h:344
Definition: DhcpLayer.h:328
uint32_t clientIpAddress
Definition: DhcpLayer.h:39
Definition: DhcpLayer.h:196
Definition: DhcpLayer.h:260
Definition: DhcpLayer.h:368
Definition: DhcpLayer.h:152
Definition: DhcpLayer.h:150
Definition: ProtocolType.h:223
Definition: DhcpLayer.h:342
The main namespace for the PcapPlusPlus lib.
Definition: DhcpLayer.h:148
void setYourIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:136
Definition: DhcpLayer.h:298
Definition: DhcpLayer.h:216
Definition: DhcpLayer.h:114
Definition: DhcpLayer.h:192
Definition: IpAddress.h:113
void setServerIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:332
Definition: DhcpLayer.h:202
std::string getValueAsString(int valueOffset=0)
Definition: DhcpLayer.h:445
Definition: DhcpLayer.h:300
Definition: DhcpLayer.h:228
Definition: DhcpLayer.h:535
Definition: DhcpLayer.h:262
Definition: DhcpLayer.h:116
Definition: DhcpLayer.h:102
Definition: DhcpLayer.h:330
Definition: DhcpLayer.h:190
Definition: DhcpLayer.h:168
Definition: DhcpLayer.h:130
Definition: DhcpLayer.h:314
Definition: DhcpLayer.h:164
OsiModelLayer
Definition: ProtocolType.h:208
Definition: DhcpLayer.h:286
Definition: DhcpLayer.h:144
Definition: DhcpLayer.h:122
uint32_t gatewayIpAddress
Definition: DhcpLayer.h:45
Definition: DhcpLayer.h:336
Definition: DhcpLayer.h:270
Definition: DhcpLayer.h:170
DhcpOptionData * getNextOptionData(DhcpOptionData *dhcpOption)
Definition: DhcpLayer.h:384
Definition: DhcpLayer.h:224
Definition: DhcpLayer.h:318
Definition: DhcpLayer.h:218
uint8_t hardwareAddressLength
Definition: DhcpLayer.h:29
DhcpOptionTypes
Definition: DhcpLayer.h:96
Definition: DhcpLayer.h:172
IPv4Address getServerIpAddress()
Definition: DhcpLayer.h:188
uint8_t value[]
Definition: DhcpLayer.h:404
Definition: DhcpLayer.h:146
Definition: DhcpLayer.h:220
Definition: DhcpLayer.h:306
Definition: DhcpLayer.h:252
Definition: DhcpLayer.h:312
Definition: DhcpLayer.h:240
Definition: DhcpLayer.h:238
Definition: DhcpLayer.h:134
Definition: DhcpLayer.h:156
Definition: DhcpLayer.h:142
Definition: DhcpLayer.h:234
MacAddress getClientHardwareAddress()
Definition: DhcpLayer.h:320
Definition: DhcpLayer.h:204
Definition: DhcpLayer.h:376
Definition: DhcpLayer.h:380
uint8_t clientHardwareAddress[16]
Definition: DhcpLayer.h:47
Definition: DhcpLayer.h:160
Definition: DhcpLayer.h:364
Definition: DhcpLayer.h:366
Definition: DhcpLayer.h:282
uint8_t serverName[64]
Definition: DhcpLayer.h:49
Definition: DhcpLayer.h:288
Definition: DhcpLayer.h:372
DhcpMessageType
Definition: DhcpLayer.h:72
Definition: DhcpLayer.h:386
DhcpOptionData * getOptionData(DhcpOptionTypes option)
OsiModelLayer getOsiModelLayer()
Definition: DhcpLayer.h:740
Definition: DhcpLayer.h:274
Definition: DhcpLayer.h:276
Definition: DhcpLayer.h:182
Definition: DhcpLayer.h:250
Definition: DhcpLayer.h:230
Definition: DhcpLayer.h:378
Definition: DhcpLayer.h:258
Definition: DhcpLayer.h:124
Definition: DhcpLayer.h:268
Definition: DhcpLayer.h:294
Definition: DhcpLayer.h:108
Definition: DhcpLayer.h:162
Definition: DhcpLayer.h:200
uint8_t len
Definition: DhcpLayer.h:402
Definition: DhcpLayer.h:280
IPv4Address getValueAsIpAddr()
Definition: DhcpLayer.h:432
uint16_t secondsElapsed
Definition: DhcpLayer.h:35
uint16_t flags
Definition: DhcpLayer.h:37
size_t getTotalSize() const
Definition: DhcpLayer.h:500
Definition: DhcpLayer.h:158
Definition: DhcpLayer.h:166
Definition: DhcpLayer.h:254
Definition: DhcpLayer.h:84
uint32_t magicNumber
Definition: DhcpLayer.h:53
Definition: MacAddress.h:21
uint32_t yourIpAddress
Definition: DhcpLayer.h:41
Definition: DhcpLayer.h:346
Definition: DhcpLayer.h:176
void parseNextLayer()
Definition: DhcpLayer.h:720
Definition: DhcpLayer.h:226
Definition: DhcpLayer.h:110
Definition: DhcpLayer.h:388
uint8_t opCode
Definition: DhcpLayer.h:25
Definition: DhcpLayer.h:178
Definition: DhcpLayer.h:236
Definition: DhcpLayer.h:222
Definition: DhcpLayer.h:78
Definition: DhcpLayer.h:232
Definition: DhcpLayer.h:272
Definition: DhcpLayer.h:64
Definition: DhcpLayer.h:358
uint8_t bootFilename[128]
Definition: DhcpLayer.h:51
virtual ~DhcpLayer()
Definition: DhcpLayer.h:563
uint32_t transactionID
Definition: DhcpLayer.h:33
Definition: DhcpLayer.h:86
Definition: DhcpLayer.h:106
Definition: DhcpLayer.h:244
Definition: DhcpLayer.h:308
BootpOpCodes
Definition: DhcpLayer.h:61
void setClientHardwareAddress(const MacAddress &addr)
uint32_t serverIpAddress
Definition: DhcpLayer.h:43
Definition: DhcpLayer.h:118
dhcp_header * getDhcpHeader()
Definition: DhcpLayer.h:569
void setValueIpAddr(const IPv4Address &addr, int valueOffset=0)
Definition: DhcpLayer.h:474
Definition: DhcpLayer.h:140
Definition: DhcpLayer.h:266
Definition: DhcpLayer.h:90
Definition: DhcpLayer.h:154
bool removeOption(DhcpOptionTypes optionType)
Definition: DhcpLayer.h:302
Definition: DhcpLayer.h:292
IPv4Address getYourIpAddress()
T getValueAs(int valueOffset=0)
Definition: DhcpLayer.h:416
Definition: DhcpLayer.h:316
Definition: DhcpLayer.h:284
Definition: DhcpLayer.h:354
IPv4Address getGatewayIpAddress()
Definition: DhcpLayer.h:296
bool setMesageType(DhcpMessageType msgType)
Definition: DhcpLayer.h:360
Definition: DhcpLayer.h:278
Definition: DhcpLayer.h:310
Definition: DhcpLayer.h:212
Definition: DhcpLayer.h:194
uint8_t getLength()
Definition: DhcpLayer.h:511
uint8_t opCode
Definition: DhcpLayer.h:400
DhcpMessageType getMesageType()
Definition: DhcpLayer.h:256
Definition: DhcpLayer.h:338
Definition: DhcpLayer.h:340
void setValue(T newValue, int valueOffset=0)
Definition: DhcpLayer.h:462
Definition: DhcpLayer.h:356
BootpOpCodes getOpCode()
Definition: DhcpLayer.h:574
Definition: DhcpLayer.h:180
DhcpOptionData * addOption(DhcpOptionTypes optionType, uint16_t optionLen, const uint8_t *optionData)
Definition: DhcpLayer.h:352
Definition: DhcpLayer.h:248
Definition: DhcpLayer.h:76
Definition: DhcpLayer.h:374
Definition: DhcpLayer.h:210
Definition: DhcpLayer.h:88
Definition: DhcpLayer.h:334
Definition: DhcpLayer.h:264
Definition: DhcpLayer.h:208
Definition: DhcpLayer.h:370
Definition: DhcpLayer.h:120
Definition: DhcpLayer.h:290
uint8_t hardwareType
Definition: DhcpLayer.h:27
Definition: DhcpLayer.h:104
Definition: DhcpLayer.h:242
Definition: DhcpLayer.h:74
uint8_t hops
Definition: DhcpLayer.h:31