pkt.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. // Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef PKT_H
  15. #define PKT_H
  16. #include <asiolink/io_address.h>
  17. #include <util/buffer.h>
  18. #include <dhcp/option.h>
  19. #include <dhcp/hwaddr.h>
  20. #include <dhcp/classify.h>
  21. #include <boost/date_time/posix_time/posix_time.hpp>
  22. namespace isc {
  23. namespace dhcp {
  24. /// @brief Base class for classes representing DHCP messages.
  25. ///
  26. /// This is a base class that holds common information (e.g. source
  27. /// and destination ports) and operations (e.g. add, get, delete options)
  28. /// for derived classes representing both DHCPv4 and DHCPv6 messages.
  29. /// The @c Pkt4 and @c Pkt6 classes derive from it.
  30. ///
  31. /// @note This is abstract class. Please instantiate derived classes
  32. /// such as @c Pkt4 or @c Pkt6.
  33. class Pkt {
  34. public:
  35. /// @defgroup hw_sources Specifies where a given MAC/hardware address was
  36. /// obtained.
  37. ///
  38. /// @brief The list covers all possible MAC/hw address sources.
  39. ///
  40. /// @note The uncommented ones are currently supported. When you implement
  41. /// a new method, please uncomment appropriate line here.
  42. ///
  43. /// @{
  44. /// Not really a type, only used in getMAC() calls.
  45. static const uint32_t HWADDR_SOURCE_ANY = 0xffff;
  46. /// Obtained first hand from raw socket (100% reliable).
  47. static const uint32_t HWADDR_SOURCE_RAW = 0x0001;
  48. /// Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client
  49. /// can send fake DUID).
  50. //static const uint32_t HWADDR_SOURCE_DUID = 0x0002;
  51. /// Extracted from IPv6 link-local address. Not 100% reliable, as the
  52. /// client can use different IID other than EUI-64, e.g. Windows supports
  53. /// RFC4941 and uses random values instead of EUI-64.
  54. static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL = 0x0004;
  55. /// Get it from RFC6939 option. (A relay agent can insert client link layer
  56. /// address option). Note that a skilled attacker can fake that by sending
  57. /// his request relayed, so the legitimate relay will think it's a second
  58. /// relay.
  59. static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION = 0x0008;
  60. /// A relay can insert remote-id. In some deployments it contains a MAC
  61. /// address (RFC4649).
  62. //static const uint32_t HWADDR_SOURCE_REMOTE_ID = 0x0010;
  63. /// A relay can insert a subscriber-id option. In some deployments it
  64. /// contains a MAC address (RFC4580).
  65. //static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID = 0x0020;
  66. /// A CMTS (acting as DHCP relay agent) that supports DOCSIS standard
  67. /// can insert DOCSIS options that contain client's MAC address.
  68. /// Client in this context would be a cable modem.
  69. //static const uint32_t HWADDR_SOURCE_DOCSIS_OPTIONS = 0x0040;
  70. /// @}
  71. protected:
  72. /// @brief Constructor.
  73. ///
  74. /// This constructor is typically used for transmitted messages as it
  75. /// creates an empty (no options) packet. The constructor is protected,
  76. /// so only derived classes can call it. Pkt class cannot be instantiated
  77. /// anyway, because it is an abstract class.
  78. ///
  79. /// @param transid transaction-id
  80. /// @param local_addr local IPv4 or IPv6 address
  81. /// @param remote_addr remote IPv4 or IPv6 address
  82. /// @param local_port local UDP (one day also TCP) port
  83. /// @param remote_port remote UDP (one day also TCP) port
  84. Pkt(uint32_t transid, const isc::asiolink::IOAddress& local_addr,
  85. const isc::asiolink::IOAddress& remote_addr, uint16_t local_port,
  86. uint16_t remote_port);
  87. /// @brief Constructor.
  88. ///
  89. /// This constructor is typically used for received messages as it takes
  90. /// a buffer that's going to be parsed as one of arguments. The constructor
  91. /// is protected, so only derived classes can call it. Pkt class cannot be
  92. /// instantiated anyway, because it is an abstract class.
  93. ///
  94. /// @param buf pointer to a buffer that contains on-wire data
  95. /// @param len length of the pointer specified in buf
  96. /// @param local_addr local IPv4 or IPv6 address
  97. /// @param remote_addr remote IPv4 or IPv6 address
  98. /// @param local_port local UDP (one day also TCP) port
  99. /// @param remote_port remote UDP (one day also TCP) port
  100. Pkt(const uint8_t* buf, uint32_t len,
  101. const isc::asiolink::IOAddress& local_addr,
  102. const isc::asiolink::IOAddress& remote_addr, uint16_t local_port,
  103. uint16_t remote_port);
  104. public:
  105. /// @brief Prepares on-wire format of DHCP (either v4 or v6) packet.
  106. ///
  107. /// Prepares on-wire format of message and all its options.
  108. /// A caller must ensure that options are stored in options_ field
  109. /// prior to calling this method.
  110. ///
  111. /// Output buffer will be stored in buffer_out_.
  112. /// The buffer_out_ should be cleared before writting to the buffer
  113. /// in the derived classes.
  114. ///
  115. /// @note This is a pure virtual method and must be implemented in
  116. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  117. /// implementations of this method.
  118. ///
  119. /// @throw InvalidOperation if packing fails
  120. virtual void pack() = 0;
  121. /// @brief Parses on-wire form of DHCP (either v4 or v6) packet.
  122. ///
  123. /// Parses received packet, stored in on-wire format in data_.
  124. ///
  125. /// Will create a collection of option objects that will
  126. /// be stored in options_ container.
  127. ///
  128. /// @note This is a pure virtual method and must be implemented in
  129. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  130. /// implementations of this method.
  131. ///
  132. /// Method will throw exception if packet parsing fails.
  133. ///
  134. /// @throw tbd
  135. virtual void unpack() = 0;
  136. /// @brief Returns reference to output buffer.
  137. ///
  138. /// Returned buffer will contain reasonable data only for
  139. /// output (TX) packet and after pack() was called.
  140. ///
  141. /// RX packet or TX packet before pack() will return buffer with
  142. /// zero length. This buffer is returned as non-const, so hooks
  143. /// framework (and user's callouts) can modify them if needed
  144. ///
  145. /// @note This buffer is only valid till object that returned it exists.
  146. ///
  147. /// @return reference to output buffer
  148. isc::util::OutputBuffer& getBuffer() { return (buffer_out_); };
  149. /// @brief Adds an option to this packet.
  150. ///
  151. /// Derived classes may provide more specialized implementations.
  152. /// In particular @c Pkt4 provides one that checks if option is
  153. /// unique.
  154. ///
  155. /// @param opt option to be added.
  156. virtual void addOption(const OptionPtr& opt);
  157. /// @brief Attempts to delete first suboption of requested type.
  158. ///
  159. /// If there are several options of the same type present, only
  160. /// the first option will be deleted.
  161. ///
  162. /// @param type Type of option to be deleted.
  163. ///
  164. /// @return true if option was deleted, false if no such option existed
  165. bool delOption(uint16_t type);
  166. /// @brief Returns text representation of the packet.
  167. ///
  168. /// This function is useful mainly for debugging.
  169. ///
  170. /// @note This is a pure virtual method and must be implemented in
  171. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  172. /// implementations of this method.
  173. ///
  174. /// @return string with text representation
  175. virtual std::string toText() = 0;
  176. /// @brief Returns packet size in binary format.
  177. ///
  178. /// Returns size of the packet in on-wire format or size needed to store
  179. /// it in on-wire format.
  180. ///
  181. /// @note This is a pure virtual method and must be implemented in
  182. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  183. /// implementations of this method.
  184. ///
  185. /// @return packet size in bytes
  186. virtual size_t len() = 0;
  187. /// @brief Returns message type (e.g. 1 = SOLICIT).
  188. ///
  189. /// @note This is a pure virtual method and must be implemented in
  190. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  191. /// implementations of this method.
  192. ///
  193. /// @return message type
  194. virtual uint8_t getType() const = 0;
  195. /// @brief Sets message type (e.g. 1 = SOLICIT).
  196. ///
  197. /// @note This is a pure virtual method and must be implemented in
  198. /// the derived classes. The @c Pkt4 and @c Pkt6 class have respective
  199. /// implementations of this method.
  200. ///
  201. /// @param type message type to be set
  202. virtual void setType(uint8_t type) = 0;
  203. /// @brief Sets transaction-id value.
  204. ///
  205. /// @param transid transaction-id to be set.
  206. void setTransid(uint32_t transid) { transid_ = transid; }
  207. /// @brief Returns value of transaction-id field.
  208. ///
  209. /// @return transaction-id
  210. uint32_t getTransid() const { return (transid_); };
  211. /// @brief Checks whether a client belongs to a given class.
  212. ///
  213. /// @param client_class name of the class
  214. /// @return true if belongs
  215. bool inClass(const isc::dhcp::ClientClass& client_class);
  216. /// @brief Adds packet to a specified class.
  217. ///
  218. /// A packet can be added to the same class repeatedly. Any additional
  219. /// attempts to add to a class the packet already belongs to, will be
  220. /// ignored silently.
  221. ///
  222. /// @note It is a matter of naming convention. Conceptually, the server
  223. /// processes a stream of packets, with some packets belonging to given
  224. /// classes. From that perspective, this method adds a packet to specifed
  225. /// class. Implementation wise, it looks the opposite - the class name
  226. /// is added to the packet. Perhaps the most appropriate name for this
  227. /// method would be associateWithClass()? But that seems overly long,
  228. /// so I decided to stick with addClass().
  229. ///
  230. /// @param client_class name of the class to be added
  231. void addClass(const isc::dhcp::ClientClass& client_class);
  232. /// @brief Unparsed data (in received packets).
  233. ///
  234. /// @warning This public member is accessed by derived
  235. /// classes directly. One of such derived classes is
  236. /// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
  237. /// behavior must be taken into consideration before making
  238. /// changes to this member such as access scope restriction or
  239. /// data format change etc.
  240. OptionBuffer data_;
  241. /// @brief Returns the first option of specified type.
  242. ///
  243. /// Returns the first option of specified type. Note that in DHCPv6 several
  244. /// instances of the same option are allowed (and frequently used).
  245. /// Also see \ref Pkt6::getOptions().
  246. ///
  247. /// The options will be only returned after unpack() is called.
  248. ///
  249. /// @param type option type we are looking for
  250. ///
  251. /// @return pointer to found option (or NULL)
  252. OptionPtr getOption(uint16_t type) const;
  253. /// @brief Update packet timestamp.
  254. ///
  255. /// Updates packet timestamp. This method is invoked
  256. /// by interface manager just before sending or
  257. /// just after receiving it.
  258. /// @throw isc::Unexpected if timestamp update failed
  259. void updateTimestamp();
  260. /// @brief Returns packet timestamp.
  261. ///
  262. /// Returns packet timestamp value updated when
  263. /// packet is received or send.
  264. ///
  265. /// @return packet timestamp.
  266. const boost::posix_time::ptime& getTimestamp() const {
  267. return timestamp_;
  268. }
  269. /// @brief Copies content of input buffer to output buffer.
  270. ///
  271. /// This is mostly a diagnostic function. It is being used for sending
  272. /// received packet. Received packet is stored in data_, but
  273. /// transmitted data is stored in buffer_out_. If we want to send packet
  274. /// that we just received, a copy between those two buffers is necessary.
  275. void repack();
  276. /// @brief Set callback function to be used to parse options.
  277. ///
  278. /// @param callback An instance of the callback function or NULL to
  279. /// uninstall callback.
  280. void setCallback(UnpackOptionsCallback callback) {
  281. callback_ = callback;
  282. }
  283. /// @brief Sets remote IP address.
  284. ///
  285. /// @param remote specifies remote address
  286. void setRemoteAddr(const isc::asiolink::IOAddress& remote) {
  287. remote_addr_ = remote;
  288. }
  289. /// @brief Returns remote IP address.
  290. ///
  291. /// @return remote address
  292. const isc::asiolink::IOAddress& getRemoteAddr() const {
  293. return (remote_addr_);
  294. }
  295. /// @brief Sets local IP address.
  296. ///
  297. /// @param local specifies local address
  298. void setLocalAddr(const isc::asiolink::IOAddress& local) {
  299. local_addr_ = local;
  300. }
  301. /// @brief Returns local IP address.
  302. ///
  303. /// @return local address
  304. const isc::asiolink::IOAddress& getLocalAddr() const {
  305. return (local_addr_);
  306. }
  307. /// @brief Sets local UDP (and soon TCP) port.
  308. ///
  309. /// This sets a local port, i.e. destination port for recently received
  310. /// packet or a source port for to be transmitted packet.
  311. ///
  312. /// @param local specifies local port
  313. void setLocalPort(uint16_t local) {
  314. local_port_ = local;
  315. }
  316. /// @brief Returns local UDP (and soon TCP) port.
  317. ///
  318. /// This sets a local port, i.e. destination port for recently received
  319. /// packet or a source port for to be transmitted packet.
  320. ///
  321. /// @return local port
  322. uint16_t getLocalPort() const {
  323. return (local_port_);
  324. }
  325. /// @brief Sets remote UDP (and soon TCP) port.
  326. ///
  327. /// This sets a remote port, i.e. source port for recently received
  328. /// packet or a destination port for to be transmitted packet.
  329. ///
  330. /// @param remote specifies remote port
  331. void setRemotePort(uint16_t remote) {
  332. remote_port_ = remote;
  333. }
  334. /// @brief Returns remote port.
  335. ///
  336. /// @return remote port
  337. uint16_t getRemotePort() const {
  338. return (remote_port_);
  339. }
  340. /// @brief Sets interface index.
  341. ///
  342. /// @param ifindex specifies interface index.
  343. void setIndex(uint32_t ifindex) {
  344. ifindex_ = ifindex;
  345. };
  346. /// @brief Returns interface index.
  347. ///
  348. /// @return interface index
  349. uint32_t getIndex() const {
  350. return (ifindex_);
  351. };
  352. /// @brief Returns interface name.
  353. ///
  354. /// Returns interface name over which packet was received or is
  355. /// going to be transmitted.
  356. ///
  357. /// @return interface name
  358. std::string getIface() const { return (iface_); };
  359. /// @brief Sets interface name.
  360. ///
  361. /// Sets interface name over which packet was received or is
  362. /// going to be transmitted.
  363. ///
  364. /// @return interface name
  365. void setIface(const std::string& iface ) { iface_ = iface; };
  366. /// @brief Sets remote hardware address.
  367. ///
  368. /// Sets hardware address (MAC) from an existing HWAddr structure.
  369. /// The remote address is a destination address for outgoing
  370. /// packet and source address for incoming packet. When this
  371. /// is an outgoing packet, this address will be used to
  372. /// construct the link layer header.
  373. ///
  374. /// @param hw_addr structure representing HW address.
  375. ///
  376. /// @throw BadValue if addr is null
  377. void setRemoteHWAddr(const HWAddrPtr& hw_addr);
  378. /// @brief Sets remote hardware address.
  379. ///
  380. /// Sets the destination hardware (MAC) address for the outgoing packet
  381. /// or source HW address for the incoming packet. When this
  382. /// is an outgoing packet this address will be used to construct
  383. /// the link layer header.
  384. ///
  385. /// @note mac_addr must be a buffer of at least hlen bytes.
  386. ///
  387. /// In a typical case, hlen field would be redundant, as it could
  388. /// be extracted from mac_addr.size(). However, the difference is
  389. /// when running on exotic hardware, like Infiniband, that had
  390. /// MAC addresses 20 bytes long. In that case, hlen is set to zero
  391. /// in DHCPv4.
  392. ///
  393. /// @param htype hardware type (will be sent in htype field)
  394. /// @param hlen hardware length (will be sent in hlen field)
  395. /// @param hw_addr pointer to hardware address
  396. void setRemoteHWAddr(const uint8_t htype, const uint8_t hlen,
  397. const std::vector<uint8_t>& hw_addr);
  398. /// @brief Returns the remote HW address obtained from raw sockets.
  399. ///
  400. /// @return remote HW address.
  401. HWAddrPtr getRemoteHWAddr() const {
  402. return (remote_hwaddr_);
  403. }
  404. /// @brief Returns MAC address.
  405. ///
  406. /// The difference between this method and getRemoteHWAddr() is that
  407. /// getRemoteHWAddr() returns only what was obtained from raw sockets.
  408. /// This method is more generic and can attempt to obtain MAC from
  409. /// varied sources: raw sockets, client-id, link-local IPv6 address,
  410. /// and various relay options.
  411. ///
  412. /// @note Technically the proper term for this information is a link layer
  413. /// address, but it is frequently referred to MAC or hardware address.
  414. /// Since we're calling the feature "MAC addresses in DHCPv6", we decided
  415. /// to keep the name of getMAC().
  416. ///
  417. /// hw_addr_src takes a combination of bit values specified in
  418. /// HWADDR_SOURCE_* constants.
  419. ///
  420. /// @param hw_addr_src a bitmask that specifies hardware address source
  421. HWAddrPtr getMAC(uint32_t hw_addr_src);
  422. /// @brief Virtual desctructor.
  423. ///
  424. /// There is nothing to clean up here, but since there are virtual methods,
  425. /// we define virtual destructor to ensure that derived classes will have
  426. /// a virtual one, too.
  427. virtual ~Pkt() {
  428. }
  429. /// @brief Classes this packet belongs to.
  430. ///
  431. /// This field is public, so the code outside of Pkt4 or Pkt6 class can
  432. /// iterate over existing classes. Having it public also solves the problem
  433. /// of returned reference lifetime. It is preferred to use @ref inClass and
  434. /// @ref addClass should be used to operate on this field.
  435. ClientClasses classes_;
  436. /// @brief Collection of options present in this message.
  437. ///
  438. /// @warning This public member is accessed by derived
  439. /// classes directly. One of such derived classes is
  440. /// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
  441. /// behavior must be taken into consideration before making
  442. /// changes to this member such as access scope restriction or
  443. /// data format change etc.
  444. isc::dhcp::OptionCollection options_;
  445. protected:
  446. /// @brief Attempts to obtain MAC address from source link-local
  447. /// IPv6 address
  448. ///
  449. /// This method is called from getMAC(HWADDR_SOURCE_IPV6_LINK_LOCAL)
  450. /// and should not be called directly. It is not 100% reliable.
  451. /// The source IPv6 address does not necessarily have to be link-local
  452. /// (may be global or ULA) and even if it's link-local, it doesn't
  453. /// necessarily be based on EUI-64. For example, Windows supports
  454. /// RFC4941, which randomized IID part of the link-local address.
  455. /// If this method fails, it will return NULL.
  456. ///
  457. /// For direct message, it attempts to use remote_addr_ field. For relayed
  458. /// message, it uses peer-addr of the first relay.
  459. ///
  460. /// @note This is a pure virtual method and must be implemented in
  461. /// the derived classes. The @c Pkt6 class have respective implementation.
  462. /// This method is not applicable to DHCPv4.
  463. ///
  464. /// @return hardware address (or NULL)
  465. virtual HWAddrPtr getMACFromSrcLinkLocalAddr() = 0;
  466. /// @brief Attempts to obtain MAC address from relay option
  467. /// client-linklayer-addr
  468. ///
  469. /// This method is called from getMAC(HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION)
  470. /// and should not be called directly. It will extract the client's
  471. // MAC/Hardware address from option client_linklayer_addr (RFC6939)
  472. // inserted by the relay agent closest to the client.
  473. /// If this method fails, it will return NULL.
  474. ///
  475. /// @note This is a pure virtual method and must be implemented in
  476. /// the derived classes. The @c Pkt6 class have respective implementation.
  477. /// This method is not applicable to DHCPv4.
  478. ///
  479. /// @return hardware address (or NULL)
  480. virtual HWAddrPtr getMACFromIPv6RelayOpt() = 0;
  481. /// @brief Attempts to convert IPv6 address into MAC.
  482. ///
  483. /// Utility method that attempts to convert link-local IPv6 address to the
  484. /// MAC address. That works only for link-local IPv6 addresses that are
  485. /// based on EUI-64.
  486. ///
  487. /// @note This method uses hardware type of the interface the packet was
  488. /// received on. If you have multiple access technologies in your network
  489. /// (e.g. client connected to WiFi that relayed the traffic to the server
  490. /// over Ethernet), hardware type may be invalid.
  491. ///
  492. /// @param addr IPv6 address to be converted
  493. /// @return hardware address (or NULL)
  494. HWAddrPtr
  495. getMACFromIPv6(const isc::asiolink::IOAddress& addr);
  496. /// Transaction-id (32 bits for v4, 24 bits for v6)
  497. uint32_t transid_;
  498. /// Name of the network interface the packet was received/to be sent over.
  499. std::string iface_;
  500. /// @brief Interface index.
  501. ///
  502. /// Each network interface has assigned an unique ifindex.
  503. /// It is a functional equivalent of a name, but sometimes more useful, e.g.
  504. /// when using odd systems that allow spaces in interface names.
  505. int ifindex_;
  506. /// @brief Local IP (v4 or v6) address.
  507. ///
  508. /// Specifies local IPv4 or IPv6 address. It is a destination address for
  509. /// received packet, and a source address if it packet is being transmitted.
  510. isc::asiolink::IOAddress local_addr_;
  511. /// @brief Remote IP address.
  512. ///
  513. /// Specifies local IPv4 or IPv6 address. It is source address for received
  514. /// packet and a destination address for packet being transmitted.
  515. isc::asiolink::IOAddress remote_addr_;
  516. /// local TDP or UDP port
  517. uint16_t local_port_;
  518. /// remote TCP or UDP port
  519. uint16_t remote_port_;
  520. /// Output buffer (used during message transmission)
  521. ///
  522. /// @warning This protected member is accessed by derived
  523. /// classes directly. One of such derived classes is
  524. /// @ref perfdhcp::PerfPkt6. The impact on derived clasess'
  525. /// behavior must be taken into consideration before making
  526. /// changes to this member such as access scope restriction or
  527. /// data format change etc.
  528. isc::util::OutputBuffer buffer_out_;
  529. /// packet timestamp
  530. boost::posix_time::ptime timestamp_;
  531. // remote HW address (src if receiving packet, dst if sending packet)
  532. HWAddrPtr remote_hwaddr_;
  533. /// A callback to be called to unpack options from the packet.
  534. UnpackOptionsCallback callback_;
  535. private:
  536. /// @brief Generic method that validates and sets HW address.
  537. ///
  538. /// This is a generic method used by all modifiers of this class
  539. /// which set class members representing HW address.
  540. ///
  541. /// @param htype hardware type.
  542. /// @param hlen hardware length.
  543. /// @param hw_addr pointer to actual hardware address.
  544. /// @param [out] storage pointer to a class member to be modified.
  545. ///
  546. /// @trow isc::OutOfRange if invalid HW address specified.
  547. virtual void setHWAddrMember(const uint8_t htype, const uint8_t hlen,
  548. const std::vector<uint8_t>& hw_addr,
  549. HWAddrPtr& storage);
  550. };
  551. }; // namespace isc::dhcp
  552. }; // namespace isc
  553. #endif