420 return getValueAs<uint32_t>();
432 setValue<uint32_t>(addr.
toInt(), valueOffset);
444 if (m_Data ==
nullptr || m_Data->recordLen - valueOffset < 1)
447 return std::string((
const char*)m_Data->recordValue + valueOffset, (
int)m_Data->recordLen - valueOffset);
461 size_t len = (size_t)m_Data->recordLen - (
size_t)valueOffset;
464 if (stringValue.length() < len)
465 len = stringValue.length();
467 memcpy(m_Data->recordValue + valueOffset, stringValue.data(), len);
476 static bool canAssign(
const uint8_t* recordRawData,
size_t tlvDataLen)
478 auto data = (TLVRawData*)recordRawData;
482 if (tlvDataLen <
sizeof(TLVRawData::recordType))
495 if (m_Data ==
nullptr)
499 return sizeof(uint8_t);
501 return sizeof(uint8_t) * 2 + (
size_t)m_Data->recordLen;
506 if (m_Data ==
nullptr)
512 return m_Data->recordLen;
600 TLVRecordBuilder::operator=(other);
830 static inline bool isDhcpPorts(uint16_t portSrc, uint16_t portDst);
868 uint8_t* getOptionsBasePtr()
const
873 TLVRecordReader<DhcpOption> m_OptionReader;
875 void initDhcpLayer(
size_t numOfBytesToAllocate);
877 DhcpOption addOptionAt(
const DhcpOptionBuilder& optionBuilder,
int offset);
884 return ((portSrc == 68 && portDst == 67) || (portSrc == 67 && portDst == 68) ||
885 (portSrc == 67 && portDst == 67));
Definition: DhcpLayer.h:616
void computeCalculateFields()
DhcpLayer(DhcpMessageType msgType, const MacAddress &clientMacAddr)
void parseNextLayer()
Definition: DhcpLayer.h:837
void setClientHardwareAddress(const MacAddress &addr)
static bool isDhcpPorts(uint16_t portSrc, uint16_t portDst)
Definition: DhcpLayer.h:882
void setServerIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:695
BootpOpCodes getOpCode() const
Definition: DhcpLayer.h:659
size_t getHeaderLen() const
Definition: DhcpLayer.h:843
dhcp_header * getDhcpHeader() const
Definition: DhcpLayer.h:651
virtual ~DhcpLayer()
Definition: DhcpLayer.h:643
DhcpOption addOptionAfter(const DhcpOptionBuilder &optionBuilder, DhcpOptionTypes prevOption)
IPv4Address getYourIpAddress() const
Definition: DhcpLayer.h:703
IPv4Address getClientIpAddress() const
Definition: DhcpLayer.h:668
DhcpOption getFirstOptionData() const
OsiModelLayer getOsiModelLayer() const
Definition: DhcpLayer.h:862
void setClientIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:677
std::string toString() const
void setGatewayIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:729
DhcpOption getNextOptionData(DhcpOption dhcpOption) const
MacAddress getClientHardwareAddress() const
DhcpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
IPv4Address getGatewayIpAddress() const
Definition: DhcpLayer.h:720
bool setMessageType(DhcpMessageType msgType)
size_t getOptionsCount() const
void setYourIpAddress(const IPv4Address &addr)
Definition: DhcpLayer.h:712
DhcpOption addOption(const DhcpOptionBuilder &optionBuilder)
DhcpOption getOptionData(DhcpOptionTypes option) const
IPv4Address getServerIpAddress() const
Definition: DhcpLayer.h:686
bool removeOption(DhcpOptionTypes optionType)
DhcpMessageType getMessageType() const
Definition: DhcpLayer.h:522
DhcpOptionBuilder(DhcpOptionTypes optionType, uint32_t optionValue)
Definition: DhcpLayer.h:562
DhcpOptionBuilder(DhcpOptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: DhcpLayer.h:532
DhcpOptionBuilder(DhcpOptionTypes optionType, const IPv4Address &optionValue)
Definition: DhcpLayer.h:572
DhcpOptionBuilder & operator=(const DhcpOptionBuilder &other)
Definition: DhcpLayer.h:598
DhcpOptionBuilder(DhcpOptionTypes optionType, uint8_t optionValue)
Definition: DhcpLayer.h:542
DhcpOptionBuilder(DhcpOptionTypes optionType, const std::string &optionValue)
Definition: DhcpLayer.h:582
DhcpOptionBuilder(DhcpOptionTypes optionType, uint16_t optionValue)
Definition: DhcpLayer.h:552
DhcpOptionBuilder(const DhcpOptionBuilder &other)
Definition: DhcpLayer.h:590
Definition: DhcpLayer.h:399
void setValueString(const std::string &stringValue, int valueOffset=0)
Definition: DhcpLayer.h:458
virtual ~DhcpOption()
Definition: DhcpLayer.h:411
std::string getValueAsString(int valueOffset=0) const
Definition: DhcpLayer.h:442
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: DhcpLayer.h:476
void setValueIpAddr(const IPv4Address &addr, int valueOffset=0)
Definition: DhcpLayer.h:430
DhcpOption(uint8_t *optionRawData)
Definition: DhcpLayer.h:405
IPv4Address getValueAsIpAddr() const
Definition: DhcpLayer.h:418
size_t getDataSize() const
Definition: DhcpLayer.h:504
size_t getTotalSize() const
Definition: DhcpLayer.h:493
Definition: IpAddress.h:32
uint32_t toInt() const
Definition: IpAddress.h:187
Definition: MacAddress.h:25
Definition: TLVData.h:413
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TLVData.h:79
The main namespace for the PcapPlusPlus lib.
DhcpOptionTypes
Definition: DhcpLayer.h:98
@ DHCPOPT_INTERFACE_MTU
Definition: DhcpLayer.h:154
@ DHCPOPT_CCC
Definition: DhcpLayer.h:320
@ DHCPOPT_FINGER_SERVER
Definition: DhcpLayer.h:248
@ DHCPOPT_OPTION_IPV4_ADDRESS_MOS
Definition: DhcpLayer.h:334
@ DHCPOPT_SMTP_SERVER
Definition: DhcpLayer.h:240
@ DHCPOPT_RAPID_COMMIT
Definition: DhcpLayer.h:262
@ DHCPOPT_START_TIME_OF_STATE
Definition: DhcpLayer.h:352
@ DHCPOPT_QUERY_END_TIME
Definition: DhcpLayer.h:356
@ DHCPOPT_ROUTER_SOLICITATION_ADDRESS
Definition: DhcpLayer.h:166
@ DHCPOPT_DHCP_MAX_MESSAGE_SIZE
Definition: DhcpLayer.h:216
@ DHCPOPT_DOMAIN_NAME
Definition: DhcpLayer.h:132
@ DHCPOPT_IP_FORWARDING
Definition: DhcpLayer.h:140
@ DHCPOPT_TRAILER_ENCAPSULATION
Definition: DhcpLayer.h:170
@ DHCPOPT_OPTION_V4_ACCESS_DOMAIN
Definition: DhcpLayer.h:384
@ DHCPOPT_SWAP_SERVER
Definition: DhcpLayer.h:134
@ DHCPOPT_SERVICE_SCOPE
Definition: DhcpLayer.h:260
@ DHCPOPT_DHCP_CLIENT_IDENTIFIER
Definition: DhcpLayer.h:224
@ DHCPOPT_NIS_SERVERS
Definition: DhcpLayer.h:184
@ DHCPOPT_DIRECTORY_AGENT
Definition: DhcpLayer.h:258
@ DHCPOPT_QUERY_START_TIME
Definition: DhcpLayer.h:354
@ DHCPOPT_TCP_KEEPALIVE_INTERVAL
Definition: DhcpLayer.h:178
@ DHCPOPT_GEOCONF
Definition: DhcpLayer.h:322
@ DHCPOPT_NAME_SERVICE_SEARCH
Definition: DhcpLayer.h:310
@ DHCPOPT_DHCP_OPTION_OVERLOAD
Definition: DhcpLayer.h:206
@ DHCPOPT_NETBIOS_NODE_TYPE
Definition: DhcpLayer.h:194
@ DHCPOPT_POP3_SERVER
Definition: DhcpLayer.h:242
@ DHCPOPT_UNKNOWN
Definition: DhcpLayer.h:100
@ DHCPOPT_SUBNET_MASK
Definition: DhcpLayer.h:104
@ DHCPOPT_DHCP_SERVER_IDENTIFIER
Definition: DhcpLayer.h:210
@ DHCPOPT_BOOT_SIZE
Definition: DhcpLayer.h:128
@ DHCPOPT_TIME_SERVERS
Definition: DhcpLayer.h:110
@ DHCPOPT_URL
Definition: DhcpLayer.h:306
@ DHCPOPT_SIP_UA_CONFIG
Definition: DhcpLayer.h:338
@ DHCPOPT_BASE_TIME
Definition: DhcpLayer.h:350
@ DHCPOPT_NDS_SERVERS
Definition: DhcpLayer.h:270
@ DHCPOPT_HOST_NAME
Definition: DhcpLayer.h:126
@ DHCPOPT_STATIC_ROUTES
Definition: DhcpLayer.h:168
@ DHCPOPT_QUOTES_SERVERS
Definition: DhcpLayer.h:118
@ DHCPOPT_REBOOT_TIME
Definition: DhcpLayer.h:380
@ DHCPOPT_GEOLOC
Definition: DhcpLayer.h:342
@ DHCPOPT_CAPTIVE_PORTAL
Definition: DhcpLayer.h:366
@ DHCPOPT_OPTION_MUD_URL_V4
Definition: DhcpLayer.h:368
@ DHCPOPT_IRC_SERVER
Definition: DhcpLayer.h:250
@ DHCPOPT_DHCP_MESSAGE_TYPE
Definition: DhcpLayer.h:208
@ DHCPOPT_OPTION_IPV4_FQDN_MOS
Definition: DhcpLayer.h:336
@ DEFAULT_IP_TTL
Definition: DhcpLayer.h:148
@ DHCPOPT_X_DISPLAY_MANAGER
Definition: DhcpLayer.h:200
@ DHCPOPT_DHCP_REBINDING_TIME
Definition: DhcpLayer.h:220
@ DHCPOPT_SIP_SERVERS
Definition: DhcpLayer.h:316
@ DHCPOPT_WWW_SERVER
Definition: DhcpLayer.h:246
@ DHCPOPT_OPTION_V4_PORTPARAMS
Definition: DhcpLayer.h:364
@ DHCPOPT_OPTION_6RD
Definition: DhcpLayer.h:382
@ DHCPOPT_CONFIGURATION_FILE
Definition: DhcpLayer.h:376
@ DHCPOPT_OPTION_CAPWAP_AC_V4
Definition: DhcpLayer.h:332
@ DHCPOPT_NON_LOCAL_SOURCE_ROUTING
Definition: DhcpLayer.h:142
@ DHCPOPT_MERIT_DUMP
Definition: DhcpLayer.h:130
@ DHCPOPT_FONT_SERVERS
Definition: DhcpLayer.h:198
@ DHCPOPT_RESOURCE_LOCATION_SERVERS
Definition: DhcpLayer.h:124
@ DHCPOPT_DATA_SOURCE
Definition: DhcpLayer.h:360
@ DHCPOPT_SUBNET_ALLOCATION
Definition: DhcpLayer.h:386
@ DHCPOPT_TIME_OFFSET
Definition: DhcpLayer.h:106
@ DHCPOPT_ALL_SUBNETS_LOCAL
Definition: DhcpLayer.h:156
@ DHCPOPT_TCODE
Definition: DhcpLayer.h:300
@ DHCPOPT_LOG_SERVERS
Definition: DhcpLayer.h:116
@ DHCPOPT_NWIP_SUBOPTIONS
Definition: DhcpLayer.h:228
@ DHCPOPT_STREETTALK_SERVER
Definition: DhcpLayer.h:252
@ DHCPOPT_GEOCONF_CIVIC
Definition: DhcpLayer.h:296
@ DHCPOPT_NWIP_DOMAIN_NAME
Definition: DhcpLayer.h:226
@ DHCPOPT_PXELINUX_MAGIC
Definition: DhcpLayer.h:374
@ DHCPOPT_IMPRESS_SERVERS
Definition: DhcpLayer.h:122
@ DHCPOPT_ROUTERS
Definition: DhcpLayer.h:108
@ DHCPOPT_V_I_VENDOR_CLASS
Definition: DhcpLayer.h:324
@ DHCPOPT_STATUS_CODE
Definition: DhcpLayer.h:348
@ DHCPOPT_DHCP_PARAMETER_REQUEST_LIST
Definition: DhcpLayer.h:212
@ DHCPOPT_BOOTFILE_NAME
Definition: DhcpLayer.h:236
@ DHCPOPT_NDS_TREE_NAME
Definition: DhcpLayer.h:272
@ DHCPOPT_CLIENT_LAST_TXN_TIME
Definition: DhcpLayer.h:282
@ DHCPOPT_FQDN
Definition: DhcpLayer.h:264
@ DHCPOPT_PATH_PREFIX
Definition: DhcpLayer.h:378
@ DHCPOPT_POLICY_FILTER
Definition: DhcpLayer.h:144
@ DHCPOPT_DHCP_STATE
Definition: DhcpLayer.h:358
@ DHCPOPT_PATH_MTU_AGING_TIMEOUT
Definition: DhcpLayer.h:150
@ DHCPOPT_NIS_DOMAIN_NAME
Definition: DhcpLayer.h:230
@ DHCPOPT_PAD
Definition: DhcpLayer.h:102
@ DHCPOPT_NDS_CONTEXT
Definition: DhcpLayer.h:274
@ DHCPOPT_SUBNET_SELECTION
Definition: DhcpLayer.h:312
@ DHCPOPT_NNTP_SERVER
Definition: DhcpLayer.h:244
@ DHCPOPT_DEFAULT_TCP_TTL
Definition: DhcpLayer.h:176
@ DHCPOPT_NETBIOS_SCOPE
Definition: DhcpLayer.h:196
@ DHCPOPT_OPTION_V4_PCP_SERVER
Definition: DhcpLayer.h:362
@ DHCPOPT_NETINFO_ADDRESS
Definition: DhcpLayer.h:302
@ DHCPOPT_PCODE
Definition: DhcpLayer.h:298
@ DHCPOPT_NTP_SERVERS
Definition: DhcpLayer.h:186
@ DHCPOPT_DHCP_REQUESTED_ADDRESS
Definition: DhcpLayer.h:202
@ DHCPOPT_FORCERENEW_NONCE_CAPABLE
Definition: DhcpLayer.h:344
@ DHCPOPT_ASSOCIATED_IP
Definition: DhcpLayer.h:284
@ DHCPOPT_NETBIOS_DD_SERVER
Definition: DhcpLayer.h:192
@ DHCPOPT_ARP_CACHE_TIMEOUT
Definition: DhcpLayer.h:172
@ DHCPOPT_MAX_DGRAM_REASSEMBLY
Definition: DhcpLayer.h:146
@ DHCPOPT_BROADCAST_ADDRESS
Definition: DhcpLayer.h:158
@ DHCPOPT_V_I_VENDOR_OPTS
Definition: DhcpLayer.h:326
@ DHCPOPT_ROUTER_DISCOVERY
Definition: DhcpLayer.h:164
@ DHCPOPT_NETBIOS_NAME_SERVERS
Definition: DhcpLayer.h:190
@ DHCPOPT_NAME_SERVERS
Definition: DhcpLayer.h:112
@ DHCPOPT_EXTENSIONS_PATH
Definition: DhcpLayer.h:138
@ DHCPOPT_IEEE802_3_ENCAPSULATION
Definition: DhcpLayer.h:174
@ DHCPOPT_ISNS
Definition: DhcpLayer.h:268
@ DHCPOPT_USER_AUTH
Definition: DhcpLayer.h:294
@ DHCPOPT_DHCP_MESSAGE
Definition: DhcpLayer.h:214
@ DHCPOPT_DHCP_RENEWAL_TIME
Definition: DhcpLayer.h:218
@ DHCPOPT_BCMCS_CONTROLLER_DOMAIN_NAME_LIST
Definition: DhcpLayer.h:276
@ DHCPOPT_OPTION_PANA_AGENT
Definition: DhcpLayer.h:328
@ DHCPOPT_DOMAIN_NAME_SERVERS
Definition: DhcpLayer.h:114
@ DHCPOPT_NETINFO_TAG
Definition: DhcpLayer.h:304
@ DHCPOPT_NIS_DOMAIN
Definition: DhcpLayer.h:182
@ DHCPOPT_VENDOR_ENCAPSULATED_OPTIONS
Definition: DhcpLayer.h:188
@ DHCPOPT_OPTION_V4_LOST
Definition: DhcpLayer.h:330
@ DHCPOPT_HOME_AGENT_ADDRESS
Definition: DhcpLayer.h:238
@ DHCPOPT_END
Definition: DhcpLayer.h:390
@ DHCPOPT_TCP_KEEPALIVE_GARBAGE
Definition: DhcpLayer.h:180
@ DHCPOPT_USER_CLASS
Definition: DhcpLayer.h:256
@ DHCPOPT_ETHERBOOT
Definition: DhcpLayer.h:370
@ PATH_MTU_PLATEAU_TABLE
Definition: DhcpLayer.h:152
@ DHCPOPT_LDAP
Definition: DhcpLayer.h:290
@ DHCPOPT_IP_TELEPHONE
Definition: DhcpLayer.h:372
@ DHCPOPT_NIS_SERVER_ADDRESS
Definition: DhcpLayer.h:232
@ DHCPOPT_AUTHENTICATION
Definition: DhcpLayer.h:280
@ DHCPOPT_BCMCS_CONTROLLER_IPV4_ADDRESS
Definition: DhcpLayer.h:278
@ DHCPOPT_CLIENT_SYSTEM
Definition: DhcpLayer.h:286
@ DHCPOPT_OPTION_IPV4_ADDRESS_ANDSF
Definition: DhcpLayer.h:340
@ DHCPOPT_DHCP_LEASE_TIME
Definition: DhcpLayer.h:204
@ DHCPOPT_DHCP_AGENT_OPTIONS
Definition: DhcpLayer.h:266
@ DHCPOPT_CLASSLESS_STATIC_ROUTE
Definition: DhcpLayer.h:318
@ DHCPOPT_TFTP_SERVER_NAME
Definition: DhcpLayer.h:234
@ DHCPOPT_RDNSS_SELECTION
Definition: DhcpLayer.h:346
@ DHCPOPT_CLIENT_NDI
Definition: DhcpLayer.h:288
@ DHCPOPT_ROOT_PATH
Definition: DhcpLayer.h:136
@ DHCPOPT_VIRTUAL_SUBNET_SELECTION
Definition: DhcpLayer.h:388
@ DHCPOPT_LPR_SERVERS
Definition: DhcpLayer.h:120
@ DHCPOPT_PERFORM_MASK_DISCOVERY
Definition: DhcpLayer.h:160
@ DHCPOPT_DOMAIN_SEARCH
Definition: DhcpLayer.h:314
@ DHCPOPT_STDA_SERVER
Definition: DhcpLayer.h:254
@ DHCPOPT_VENDOR_CLASS_IDENTIFIER
Definition: DhcpLayer.h:222
@ DHCPOPT_MASK_SUPPLIER
Definition: DhcpLayer.h:162
@ DHCPOPT_UUID_GUID
Definition: DhcpLayer.h:292
@ DHCPOPT_AUTO_CONFIG
Definition: DhcpLayer.h:308
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelApplicationLayer
Definition: ProtocolType.h:368
DhcpMessageType
Definition: DhcpLayer.h:73
@ DHCP_UNKNOWN_MSG_TYPE
Definition: DhcpLayer.h:75
@ DHCP_NAK
Definition: DhcpLayer.h:87
@ DHCP_REQUEST
Definition: DhcpLayer.h:81
@ DHCP_OFFER
Definition: DhcpLayer.h:79
@ DHCP_DECLINE
Definition: DhcpLayer.h:83
@ DHCP_DISCOVER
Definition: DhcpLayer.h:77
@ DHCP_ACK
Definition: DhcpLayer.h:85
@ DHCP_RELEASE
Definition: DhcpLayer.h:89
@ DHCP_INFORM
Definition: DhcpLayer.h:91
BootpOpCodes
Definition: DhcpLayer.h:62
@ DHCP_BOOTREQUEST
Definition: DhcpLayer.h:64
@ DHCP_BOOTREPLY
Definition: DhcpLayer.h:66