pkt.h 24 KB

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