libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
icmpv6.h
1 /*
2  * Copyright (c) 2016, Matias Fontanini
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef TINS_ICMPV6_H
31 #define TINS_ICMPV6_H
32 
33 #include <list>
34 #include <vector>
35 #include "macros.h"
36 #include "pdu.h"
37 #include "ipv6_address.h"
38 #include "pdu_option.h"
39 #include "endianness.h"
40 #include "small_uint.h"
41 #include "hw_address.h"
42 #include "small_uint.h"
43 #include "icmp_extension.h"
44 #include "cxxstd.h"
45 
46 namespace Tins {
47 namespace Memory {
48 
49 class InputMemoryStream;
50 class OutputMemoryStream;
51 
52 } // memory
53 
58 class TINS_API ICMPv6 : public PDU {
59 public:
63  static const PDU::PDUType pdu_flag = PDU::ICMPv6;
64 
68  enum Types {
69  DEST_UNREACHABLE = 1,
70  PACKET_TOOBIG = 2,
71  TIME_EXCEEDED = 3,
72  PARAM_PROBLEM = 4,
73  ECHO_REQUEST = 128,
74  ECHO_REPLY = 129,
75  MGM_QUERY = 130,
76  MGM_REPORT = 131,
77  MGM_REDUCTION = 132,
78  ROUTER_SOLICIT = 133,
79  ROUTER_ADVERT = 134,
80  NEIGHBOUR_SOLICIT = 135,
81  NEIGHBOUR_ADVERT = 136,
82  REDIRECT = 137,
83  ROUTER_RENUMBER = 138,
84  NI_QUERY = 139,
85  NI_REPLY = 140,
86  MLD2_REPORT = 143,
87  DHAAD_REQUEST = 144,
88  DHAAD_REPLY = 145,
89  MOBILE_PREFIX_SOLICIT = 146,
90  MOBILE_PREFIX_ADVERT = 147,
91  CERT_PATH_SOLICIT = 148,
92  CERT_PATH_ADVERT = 149,
93  MULTICAST_ROUTER_ADVERT = 151,
94  MULTICAST_ROUTER_SOLICIT = 152,
95  MULTICAST_ROUTER_TERMINATE = 153,
96  RPL_CONTROL_MSG = 155
97  };
98 
102  enum OptionTypes {
103  SOURCE_ADDRESS = 1,
104  TARGET_ADDRESS,
105  PREFIX_INFO,
106  REDIRECT_HEADER,
107  MTU,
108  NBMA_SHORT_LIMIT,
109  ADVERT_INTERVAL,
110  HOME_AGENT_INFO,
111  S_ADDRESS_LIST,
112  T_ADDRESS_LIST,
113  CGA,
114  RSA_SIGN,
115  TIMESTAMP,
116  NONCE,
117  TRUST_ANCHOR,
118  CERTIFICATE,
119  IP_PREFIX,
120  NEW_ROUTER_PREFIX,
121  LINK_ADDRESS,
122  NAACK,
123  MAP = 23,
124  ROUTE_INFO,
125  RECURSIVE_DNS_SERV,
126  RA_FLAGS_EXT,
127  HANDOVER_KEY_REQ,
128  HANDOVER_KEY_REPLY,
129  HANDOVER_ASSIST_INFO,
130  MOBILE_NODE_ID,
131  DNS_SEARCH_LIST,
132  PROXY_SIGNATURE,
133  ADDRESS_REG,
134  SIXLOWPAN_CONTEXT,
135  AUTHORITATIVE_BORDER_ROUTER,
136  CARD_REQUEST = 138,
137  CARD_REPLY
138  };
139 
144 
149 
154 
158  typedef std::list<option> options_type;
159 
164  typedef std::vector<uint16_t> new_ha_info_type;
165 
169  struct addr_list_type {
170  typedef std::vector<ipaddress_type> addresses_type;
171 
172  uint8_t reserved[6];
173  addresses_type addresses;
174 
175  addr_list_type(const addresses_type& addresses = addresses_type())
176  : addresses(addresses) {
177  std::fill(reserved, reserved + sizeof(reserved), 0);
178  }
179 
180  static addr_list_type from_option(const option& opt);
181  };
182 
186  typedef std::vector<uint8_t> nonce_type;
187 
191  typedef std::pair<uint16_t, uint32_t> mtu_type;
192 
197  struct naack_type {
198  uint8_t code, status;
199  uint8_t reserved[4];
200 
201  naack_type(uint8_t code = 0, uint8_t status = 0)
202  : code(code), status(status) {
203  std::fill(reserved, reserved + 4, 0);
204  }
205 
206  static naack_type from_option(const option& opt);
207  };
208 
212  struct lladdr_type {
213  typedef std::vector<uint8_t> address_type;
214 
215  uint8_t option_code;
216  address_type address;
217 
224  lladdr_type(uint8_t option_code = 0,
225  const address_type& address = address_type())
226  : option_code(option_code), address(address) {
227 
228  }
229 
239  lladdr_type(uint8_t option_code, const hwaddress_type& address)
240  : option_code(option_code), address(address.begin(), address.end()) {
241 
242  }
243 
244  static lladdr_type from_option(const option& opt);
245  };
246 
251  uint8_t prefix_len;
252  small_uint<1> A, L;
253  uint32_t valid_lifetime,
254  preferred_lifetime,
255  reserved2;
256  ipaddress_type prefix;
257 
258  prefix_info_type(uint8_t prefix_len = 0,
259  small_uint<1> A = 0,
260  small_uint<1> L = 0,
261  uint32_t valid_lifetime = 0,
262  uint32_t preferred_lifetime = 0,
263  const ipaddress_type& prefix = ipaddress_type())
264  : prefix_len(prefix_len), A(A), L(L), valid_lifetime(valid_lifetime),
265  preferred_lifetime(preferred_lifetime), reserved2(0), prefix(prefix) { }
266 
267  static prefix_info_type from_option(const option& opt);
268  };
269 
273  struct rsa_sign_type {
274  typedef std::vector<uint8_t> signature_type;
275 
276  uint8_t key_hash[16];
277  signature_type signature;
278 
297  template <typename RAIterator, typename ForwardIterator>
298  rsa_sign_type(RAIterator hash, ForwardIterator start, ForwardIterator end)
299  : signature(start, end) {
300  std::copy(hash, hash + sizeof(key_hash), key_hash);
301  }
302 
315  template <typename RAIterator>
316  rsa_sign_type(RAIterator hash, const signature_type& sign)
317  : signature(sign) {
318  std::copy(hash, hash + sizeof(key_hash), key_hash);
319  }
320 
327  std::fill(key_hash, key_hash + sizeof(key_hash), 0);
328  }
329 
330  static rsa_sign_type from_option(const option& opt);
331  };
332 
336  struct ip_prefix_type {
337  uint8_t option_code, prefix_len;
338  ipaddress_type address;
339 
340  ip_prefix_type(uint8_t option_code = 0,
341  uint8_t prefix_len = 0,
342  const ipaddress_type& address = ipaddress_type())
343  : option_code(option_code), prefix_len(prefix_len), address(address)
344  {}
345 
346  static ip_prefix_type from_option(const option& opt);
347  };
348 
352  struct map_type {
353  small_uint<4> dist, pref;
354  small_uint<1> r;
355  uint32_t valid_lifetime;
356  ipaddress_type address;
357 
358  map_type(small_uint<4> dist = 0,
359  small_uint<4> pref = 0,
360  small_uint<1> r = 0,
361  uint32_t valid_lifetime = 0,
362  const ipaddress_type& address = ipaddress_type())
363  : dist(dist), pref(pref), r(r), valid_lifetime(valid_lifetime),
364  address(address) { }
365 
366  static map_type from_option(const option& opt);
367  };
368 
373  typedef std::vector<uint8_t> prefix_type;
374 
375  uint8_t prefix_len;
376  small_uint<2> pref;
377  uint32_t route_lifetime;
378  prefix_type prefix;
379 
380  route_info_type(uint8_t prefix_len = 0,
381  small_uint<2> pref = 0,
382  uint32_t route_lifetime = 0,
383  const prefix_type& prefix = prefix_type())
384  : prefix_len(prefix_len), pref(pref), route_lifetime(route_lifetime),
385  prefix(prefix) { }
386 
387  static route_info_type from_option(const option& opt);
388  };
389 
394  typedef std::vector<ipaddress_type> servers_type;
395 
396  uint32_t lifetime;
397  servers_type servers;
398 
399  recursive_dns_type(uint32_t lifetime = 0,
400  const servers_type& servers = servers_type())
401  : lifetime(lifetime), servers(servers) {}
402 
403  static recursive_dns_type from_option(const option& opt);
404  };
405 
410  typedef std::vector<uint8_t> key_type;
411 
412  small_uint<4> AT;
413  key_type key;
414 
416  const key_type& key = key_type())
417  : AT(AT), key(key) { }
418 
419  static handover_key_req_type from_option(const option& opt);
420  };
421 
426  uint16_t lifetime;
427 
428  handover_key_reply_type(uint16_t lifetime = 0,
429  small_uint<4> AT = 0,
430  const key_type& key = key_type())
431  : handover_key_req_type(AT, key), lifetime(lifetime) { }
432 
433  static handover_key_reply_type from_option(const option& opt);
434  };
435 
440  typedef std::vector<uint8_t> hai_type;
441 
442  uint8_t option_code;
443  hai_type hai;
444 
445  handover_assist_info_type(uint8_t option_code=0,
446  const hai_type& hai = hai_type())
447  : option_code(option_code), hai(hai) { }
448 
449  static handover_assist_info_type from_option(const option& opt);
450  };
451 
456  typedef std::vector<uint8_t> mn_type;
457 
458  uint8_t option_code;
459  mn_type mn;
460 
461  mobile_node_id_type(uint8_t option_code=0,
462  const mn_type& mn = mn_type())
463  : option_code(option_code), mn(mn) { }
464 
465  static mobile_node_id_type from_option(const option& opt);
466  };
467 
472  typedef std::vector<std::string> domains_type;
473 
474  uint32_t lifetime;
475  domains_type domains;
476 
477  dns_search_list_type(uint32_t lifetime = 0,
478  const domains_type& domains = domains_type())
479  : lifetime(lifetime), domains(domains) { }
480 
481  static dns_search_list_type from_option(const option& opt);
482  };
483 
487  struct timestamp_type {
488  uint8_t reserved[6];
489  uint64_t timestamp;
490 
491  timestamp_type(uint64_t timestamp = 0)
492  : timestamp(timestamp) {
493  std::fill(reserved, reserved + sizeof(reserved), 0);
494  }
495 
496  static timestamp_type from_option(const option& opt);
497  };
498 
503  uint8_t limit, reserved1;
504  uint32_t reserved2;
505 
506  shortcut_limit_type(uint8_t limit = 0)
507  : limit(limit), reserved1(), reserved2() {
508 
509  }
510 
511  static shortcut_limit_type from_option(const option& opt);
512  };
513 
518  uint16_t reserved;
519  uint32_t interval;
520 
521  new_advert_interval_type(uint32_t interval = 0)
522  : reserved(), interval(interval) {
523 
524  }
525 
526  static new_advert_interval_type from_option(const option& opt);
527  };
528 
533  typedef std::vector<ipaddress_type> sources_type;
534  typedef std::vector<uint8_t> aux_data_type;
535 
536  multicast_address_record(uint8_t type = 0) : type(type) { }
537 
538  multicast_address_record(const uint8_t* buffer, uint32_t total_sz);
539  void serialize(uint8_t* buffer, uint32_t total_sz) const;
540  uint32_t size() const;
541 
542  uint8_t type;
543  ipaddress_type multicast_address;
544  sources_type sources;
545  aux_data_type aux_data;
546  };
547 
548  /*
549  * The type used to store all multicast address records in a packet
550  */
551  typedef std::list<multicast_address_record> multicast_address_records_list;
552 
553  /*
554  * The type used to store all source address (from Multicast
555  * Listener Query messages) in a packet
556  */
557  typedef std::list<ipaddress_type> sources_list;
558 
567  ICMPv6(Types tp = ECHO_REQUEST);
568 
580  ICMPv6(const uint8_t* buffer, uint32_t total_sz);
581 
582  // Getters
583 
588  Types type() const {
589  return static_cast<Types>(header_.type);
590  }
591 
596  uint8_t code() const {
597  return header_.code;
598  }
599 
604  uint16_t checksum() const {
605  return Endian::be_to_host(header_.cksum);
606  }
607 
612  uint16_t identifier() const {
613  return Endian::be_to_host(header_.u_echo.identifier);
614  }
615 
620  uint16_t sequence() const {
621  return Endian::be_to_host(header_.u_echo.sequence);
622  }
623 
628  small_uint<1> override() const {
629  return header_.u_nd_advt.override;
630  }
631 
637  return header_.u_nd_advt.solicited;
638  }
639 
645  return header_.u_nd_advt.router;
646  }
647 
652  uint8_t hop_limit() const {
653  return header_.u_nd_ra.hop_limit;
654  }
655 
660  uint16_t maximum_response_code() const {
661  return Endian::be_to_host(header_.u_echo.identifier);
662  }
663 
669  return header_.u_nd_ra.router_pref;
670  }
671 
677  return header_.u_nd_ra.home_agent;
678  }
679 
685  return header_.u_nd_ra.other;
686  }
687 
693  return header_.u_nd_ra.managed;
694  }
695 
700  uint16_t router_lifetime() const {
701  return Endian::be_to_host(header_.u_nd_ra.router_lifetime);
702  }
703 
708  uint32_t reachable_time() const {
709  return Endian::be_to_host(reach_time_);
710  }
711 
716  uint32_t retransmit_timer() const {
717  return Endian::be_to_host(retrans_timer_);
718  }
719 
724  const ipaddress_type& target_addr() const {
725  return target_address_;
726  }
727 
732  const ipaddress_type& dest_addr() const {
733  return dest_address_;
734  }
735 
744  return multicast_address_;
745  }
746 
751  const options_type& options() const {
752  return options_;
753  }
754 
760  uint8_t length() const {
761  return header_.rfc4884.length;
762  }
763 
767  const multicast_address_records_list& multicast_address_records() const {
768  return multicast_records_;
769  }
770 
777  const sources_list& sources() const {
778  return sources_;
779  }
780 
788  return mlqm_.supress;
789  }
790 
797  small_uint<3> qrv() const {
798  return mlqm_.qrv;
799  }
800 
807  uint8_t qqic() const {
808  return mlqm_.qqic;
809  }
810 
811  // Setters
812 
817  void type(Types new_type);
818 
823  void code(uint8_t new_code);
824 
829  void checksum(uint16_t new_cksum);
830 
835  void identifier(uint16_t new_identifier);
836 
841  void sequence(uint16_t new_sequence);
842 
847  void override(small_uint<1> new_override);
848 
853  void solicited(small_uint<1> new_solicited);
854 
859  void router(small_uint<1> new_router);
860 
865  void hop_limit(uint8_t new_hop_limit);
866 
871  void maximum_response_code(uint16_t maximum_response_code);
872 
877  void router_pref(small_uint<2> new_router_pref);
878 
883  void home_agent(small_uint<1> new_home_agent);
884 
889  void other(small_uint<1> new_other);
890 
895  void managed(small_uint<1> new_managed);
896 
901  void router_lifetime(uint16_t new_router_lifetime);
902 
907  void target_addr(const ipaddress_type& new_target_addr);
908 
913  void dest_addr(const ipaddress_type& new_dest_addr);
914 
922  void multicast_addr(const ipaddress_type& new_multicast_addr);
923 
928  void reachable_time(uint32_t new_reachable_time);
929 
934  void retransmit_timer(uint32_t new_retrans_timer);
935 
941  void multicast_address_records(const multicast_address_records_list& records);
942 
948  void sources(const sources_list& new_sources);
949 
955  void supress(small_uint<1> value);
956 
962  void qrv(small_uint<3> value);
963 
969  void qqic(uint8_t value);
970 
976  PDUType pdu_type() const { return pdu_flag; }
977 
983  bool has_target_addr() const {
984  return type() == NEIGHBOUR_SOLICIT ||
985  type() == NEIGHBOUR_ADVERT ||
986  type() == REDIRECT;
987  }
988 
994  bool has_dest_addr() const {
995  return type() == REDIRECT;
996  }
997 
1006  void add_option(const option& option);
1007 
1008  #if TINS_IS_CXX11
1009 
1017  internal_add_option(option);
1018  options_.push_back(std::move(option));
1019  }
1020  #endif
1021 
1031  bool remove_option(OptionTypes type);
1032 
1039  uint32_t header_size() const;
1040 
1048  uint32_t trailer_size() const;
1049 
1056  return extensions_;
1057  }
1058 
1065  return extensions_;
1066  }
1067 
1071  bool has_extensions() const {
1072  return !extensions_.extensions().empty();
1073  }
1074 
1090  void use_length_field(bool value);
1091 
1099  bool matches_response(const uint8_t* ptr, uint32_t total_sz) const;
1100 
1110  const option* search_option(OptionTypes type) const;
1111 
1115  ICMPv6* clone() const {
1116  return new ICMPv6(*this);
1117  }
1118 
1128  void use_mldv2(bool value);
1129 
1130  // ****************************************************************
1131  // Option setters
1132  // ****************************************************************
1133 
1139  void source_link_layer_addr(const hwaddress_type& addr);
1140 
1146  void target_link_layer_addr(const hwaddress_type& addr);
1147 
1153  void prefix_info(prefix_info_type info);
1154 
1160  void redirect_header(const byte_array& data);
1161 
1167  void mtu(const mtu_type& value);
1168 
1174  void shortcut_limit(const shortcut_limit_type& value);
1175 
1181  void new_advert_interval(const new_advert_interval_type& value);
1182 
1188  void new_home_agent_info(const new_ha_info_type& value);
1189 
1195  void source_addr_list(const addr_list_type& value);
1196 
1202  void target_addr_list(const addr_list_type& value);
1203 
1209  void rsa_signature(const rsa_sign_type& value);
1210 
1216  void timestamp(const timestamp_type& value);
1217 
1223  void nonce(const nonce_type& value);
1224 
1230  void ip_prefix(const ip_prefix_type& value);
1231 
1237  void link_layer_addr(lladdr_type value);
1238 
1244  void naack(const naack_type& value);
1245 
1251  void map(const map_type& value);
1252 
1258  void route_info(const route_info_type& value);
1259 
1265  void recursive_dns_servers(const recursive_dns_type& value);
1266 
1272  void handover_key_request(const handover_key_req_type& value);
1273 
1279  void handover_key_reply(const handover_key_reply_type& value);
1280 
1286  void handover_assist_info(const handover_assist_info_type& value);
1287 
1293  void mobile_node_identifier(const mobile_node_id_type& value);
1294 
1300  void dns_search_list(const dns_search_list_type& value);
1301 
1302  // ****************************************************************
1303  // Option getters
1304  // ****************************************************************
1305 
1312  hwaddress_type source_link_layer_addr() const;
1313 
1320  hwaddress_type target_link_layer_addr() const;
1321 
1328  prefix_info_type prefix_info() const;
1329 
1336  byte_array redirect_header() const;
1337 
1344  mtu_type mtu() const;
1345 
1352  shortcut_limit_type shortcut_limit() const;
1353 
1360  new_advert_interval_type new_advert_interval() const;
1361 
1368  new_ha_info_type new_home_agent_info() const;
1369 
1376  addr_list_type source_addr_list() const;
1377 
1384  addr_list_type target_addr_list() const;
1385 
1392  rsa_sign_type rsa_signature() const;
1393 
1400  timestamp_type timestamp() const;
1401 
1408  nonce_type nonce() const;
1409 
1416  ip_prefix_type ip_prefix() const;
1417 
1424  lladdr_type link_layer_addr() const;
1425 
1433  naack_type naack() const;
1434 
1441  map_type map() const;
1442 
1449  route_info_type route_info() const;
1450 
1457  recursive_dns_type recursive_dns_servers() const;
1458 
1465  handover_key_req_type handover_key_request() const;
1466 
1473  handover_key_reply_type handover_key_reply() const;
1474 
1481  handover_assist_info_type handover_assist_info() const;
1482 
1489  mobile_node_id_type mobile_node_identifier() const;
1490 
1497  dns_search_list_type dns_search_list() const;
1498 private:
1499  TINS_BEGIN_PACK
1500  struct icmp6_header {
1501  uint8_t type;
1502  uint8_t code;
1503  uint16_t cksum;
1504  union {
1505  struct {
1506  uint16_t identifier;
1507  uint16_t sequence;
1508  } u_echo;
1509 
1510  struct {
1511  #if TINS_IS_LITTLE_ENDIAN
1512  uint32_t reserved:5,
1513  override:1,
1514  solicited:1,
1515  router:1,
1516  reserved2:24;
1517  #else
1518  uint32_t router:1,
1519  solicited:1,
1520  override:1,
1521  reserved:29;
1522  #endif
1523  } u_nd_advt;
1524  struct {
1525  uint8_t hop_limit;
1526  #if TINS_IS_LITTLE_ENDIAN
1527  uint8_t reserved:3,
1528  router_pref:2,
1529  home_agent:1,
1530  other:1,
1531  managed:1;
1532  #else
1533  uint8_t managed:1,
1534  other:1,
1535  home_agent:1,
1536  router_pref:2,
1537  reserved:3;
1538  #endif
1539  uint16_t router_lifetime;
1540  } u_nd_ra;
1541  struct {
1542  uint8_t length;
1543  uint8_t unused[3];
1544  } rfc4884;
1545  // Multicast Listener Report Message (mld2)
1546  struct {
1547  uint16_t reserved;
1548  uint16_t record_count;
1549  } mlrm2;
1550  };
1551  } TINS_END_PACK;
1552 
1553  TINS_BEGIN_PACK
1554  struct multicast_listener_query_message_fields {
1555  uint8_t reserved:4,
1556  supress:1,
1557  qrv:3;
1558  uint8_t qqic;
1559  } TINS_END_PACK;
1560 
1561  void internal_add_option(const option& option);
1562  void write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent);
1563  bool has_options() const;
1564  void write_option(const option& opt, Memory::OutputMemoryStream& stream);
1565  void parse_options(Memory::InputMemoryStream& stream);
1566  void add_addr_list(uint8_t type, const addr_list_type& value);
1567  addr_list_type search_addr_list(OptionTypes type) const;
1568  options_type::const_iterator search_option_iterator(OptionTypes type) const;
1569  options_type::iterator search_option_iterator(OptionTypes type);
1570  void try_parse_extensions(Memory::InputMemoryStream& stream);
1571  bool are_extensions_allowed() const;
1572  uint32_t get_adjusted_inner_pdu_size() const;
1573  uint8_t get_option_padding(uint32_t data_size);
1574 
1575  template <template <typename> class Functor>
1576  const option* safe_search_option(OptionTypes opt, uint32_t size) const {
1577  const option* option = search_option(opt);
1578  if (!option || Functor<uint32_t>()(option->data_size(), size)) {
1579  throw option_not_found();
1580  }
1581  return option;
1582  }
1583 
1584  template <typename T>
1585  T search_and_convert(OptionTypes type) const {
1586  const option* opt = search_option(type);
1587  if (!opt) {
1588  throw option_not_found();
1589  }
1590  return opt->to<T>();
1591  }
1592 
1593  icmp6_header header_;
1594  ipaddress_type target_address_;
1595  ipaddress_type dest_address_;
1596  ipaddress_type multicast_address_;
1597  options_type options_;
1598  uint32_t options_size_;
1599  uint32_t reach_time_, retrans_timer_;
1600  multicast_address_records_list multicast_records_;
1601  multicast_listener_query_message_fields mlqm_;
1602  sources_list sources_;
1603  ICMPExtensionsStructure extensions_;
1604  bool use_mldv2_;
1605 };
1606 
1607 } // Tins
1608 
1609 #endif // TINS_ICMPV6_H
Definition: icmpv6.h:487
rsa_sign_type(RAIterator hash, const signature_type &sign)
Constructs a rsa_sign_type object.
Definition: icmpv6.h:316
uint16_t identifier() const
Getter for the identifier field.
Definition: icmpv6.h:612
PDUType pdu_type() const
Getter for the PDU's type.
Definition: icmpv6.h:976
const sources_list & sources() const
Getter for the multicast address records field.
Definition: icmpv6.h:777
rsa_sign_type()
Default constructs a rsa_sign_type.
Definition: icmpv6.h:326
uint32_t reachable_time() const
Getter for the reachable_time field.
Definition: icmpv6.h:708
Definition: icmpv6.h:273
OptionTypes
Definition: icmpv6.h:102
std::vector< uint8_t > byte_array
Definition: pdu.h:46
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:128
std::vector< uint16_t > new_ha_info_type
The type used to store the new home agent information option data.
Definition: icmpv6.h:164
Definition: icmpv6.h:393
Definition: icmpv6.h:409
uint32_t retransmit_timer() const
Getter for the retransmit_timer field.
Definition: icmpv6.h:716
small_uint< 2 > router_pref() const
Getter for the router_pref field.
Definition: icmpv6.h:668
Definition: icmpv6.h:502
bool has_target_addr() const
Checks whether this ICMPv6 object has a target_addr field.
Definition: icmpv6.h:983
Types type() const
Getter for the type field.
Definition: icmpv6.h:588
bool has_dest_addr() const
Checks whether this ICMPv6 object has a target_addr field.
Definition: icmpv6.h:994
Definition: icmpv6.h:250
const ipaddress_type & target_addr() const
Getter for the target address field.
Definition: icmpv6.h:724
Represents a PDU option field.
Definition: pdu_option.h:320
small_uint< 1 > managed() const
Getter for the managed field.
Definition: icmpv6.h:692
Definition: icmpv6.h:455
std::pair< uint16_t, uint32_t > mtu_type
Definition: icmpv6.h:191
Types
Definition: icmpv6.h:68
std::vector< uint8_t > nonce_type
Definition: icmpv6.h:186
uint16_t checksum() const
Getter for the cksum field.
Definition: icmpv6.h:604
Definition: icmpv6.h:471
Definition: icmpv6.h:336
Represents an ICMPv6 PDU.
Definition: icmpv6.h:58
small_uint< 1 > supress() const
Getter for the Suppress Router-Side Processing field.
Definition: icmpv6.h:787
const multicast_address_records_list & multicast_address_records() const
Getter for the multicast address records field.
Definition: icmpv6.h:767
The type used to store the neighbour advertisement acknowledgement option data.
Definition: icmpv6.h:197
std::list< option > options_type
Definition: icmpv6.h:158
uint16_t sequence() const
Getter for the sequence field.
Definition: icmpv6.h:620
const ipaddress_type & multicast_addr() const
Getter for the multicast address field.
Definition: icmpv6.h:743
rsa_sign_type(RAIterator hash, ForwardIterator start, ForwardIterator end)
Constructs a rsa_sign_type object.
Definition: icmpv6.h:298
uint16_t router_lifetime() const
Getter for the router_lifetime field.
Definition: icmpv6.h:700
small_uint< 3 > qrv() const
Getter for the Querier's Robustnes Variable field.
Definition: icmpv6.h:797
void add_option(option &&option)
Adds an ICMPv6 option.
Definition: icmpv6.h:1016
ICMPExtensionsStructure & extensions()
Getter for the extensions field.
Definition: icmpv6.h:1064
uint8_t length() const
Getter for the length field.
Definition: icmpv6.h:760
small_uint< 1 > other() const
Getter for the other field.
Definition: icmpv6.h:684
HWAddress< 6 > hwaddress_type
Definition: icmpv6.h:148
Definition: icmpv6.h:169
lladdr_type(uint8_t option_code=0, const address_type &address=address_type())
Definition: icmpv6.h:224
const options_type & options() const
Getter for the ICMPv6 options.
Definition: icmpv6.h:751
small_uint< 1 > router() const
Getter for the router field.
Definition: icmpv6.h:644
const ipaddress_type & dest_addr() const
Getter for the destination address field.
Definition: icmpv6.h:732
Definition: ipv6_address.h:44
const ICMPExtensionsStructure & extensions() const
Getter for the extensions field.
Definition: icmpv6.h:1055
PDUOption< uint8_t, ICMPv6 > option
Definition: icmpv6.h:153
Class that represents an ICMP extensions structure.
Definition: icmp_extension.h:162
Definition: icmpv6.h:352
IPv6Address ipaddress_type
Definition: icmpv6.h:143
bool has_extensions() const
Indicates whether this object contains ICMP extensions.
Definition: icmpv6.h:1071
The type used to store the link layer address option data.
Definition: icmpv6.h:212
Definition: icmpv6.h:372
small_uint< 1 > home_agent() const
Getter for the home_agent field.
Definition: icmpv6.h:676
Base class for protocol data units.
Definition: pdu.h:108
uint16_t maximum_response_code() const
Getter for the maximum response code field.
Definition: icmpv6.h:660
uint8_t hop_limit() const
Getter for the hop limit field.
Definition: icmpv6.h:652
small_uint< 1 > solicited() const
Getter for the solicited field.
Definition: icmpv6.h:636
lladdr_type(uint8_t option_code, const hwaddress_type &address)
Constructor taking an option code and hwaddress_type.
Definition: icmpv6.h:239
ICMPv6 * clone() const
Definition: icmpv6.h:1115
uint8_t qqic() const
Getter for the Querier's Query Interval Code field.
Definition: icmpv6.h:807
uint8_t code() const
Getter for the code field.
Definition: icmpv6.h:596