1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Use vector instead of lists everywhere

This commit is contained in:
Matias Fontanini
2017-05-13 11:14:11 -07:00
parent 80f424b6b3
commit 8021112fea
16 changed files with 19 additions and 35 deletions

View File

@@ -30,7 +30,6 @@
#ifndef TINS_DHCP_H
#define TINS_DHCP_H
#include <list>
#include <vector>
#include <string>
#include "bootp.h"
@@ -170,7 +169,7 @@ public:
/**
* The type used to store the DHCP options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* \brief Extracts metadata for this protocol based on the buffer provided
@@ -436,8 +435,7 @@ public:
* If the option is not found, an option_not_found exception
* is thrown.
*
* \return std::list<ipaddress_type> Contanining the DNS servers
* provided.
* \return The list of DNS servers provided.
*/
std::vector<ipaddress_type> domain_name_servers() const;

View File

@@ -31,7 +31,6 @@
#define TINS_DHCPV6_H
#include <cstring>
#include <list>
#include "pdu.h"
#include "macros.h"
#include "endianness.h"
@@ -163,7 +162,7 @@ public:
/**
* The type used to store the DHCPv6 options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* The type used to store IP addresses.

View File

@@ -31,7 +31,6 @@
#define TINS_DNS_H
#include <stdint.h>
#include <list>
#include <vector>
#include <cstring>
#include <string>
@@ -602,8 +601,8 @@ public:
TINS_DEPRECATED(typedef query Query);
TINS_DEPRECATED(typedef resource Resource);
typedef std::list<query> queries_type;
typedef std::list<resource> resources_type;
typedef std::vector<query> queries_type;
typedef std::vector<resource> resources_type;
typedef IPv4Address address_type;
typedef IPv6Address address_v6_type;

View File

@@ -32,7 +32,6 @@
#if !defined(TINS_DOT11_DOT11_H) && defined(TINS_HAVE_DOT11)
#define TINS_DOT11_DOT11_H
#include <list>
#include "../pdu.h"
#include "../pdu_option.h"
#include "../small_uint.h"
@@ -67,7 +66,7 @@ public:
/**
* The type used to store tagged options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* \brief This PDU's flag.

View File

@@ -31,7 +31,6 @@
#define TINS_ICMP_EXTENSION_H
#include <vector>
#include <list>
#include <stdint.h>
#include "macros.h"
#include "small_uint.h"
@@ -176,7 +175,7 @@ public:
/**
* The type used to store the list of ICMP extensions in this structure
*/
typedef std::list<ICMPExtension> extensions_type;
typedef std::vector<ICMPExtension> extensions_type;
/**
* \brief Default constructor

View File

@@ -30,7 +30,6 @@
#ifndef TINS_ICMPV6_H
#define TINS_ICMPV6_H
#include <list>
#include <vector>
#include "macros.h"
#include "pdu.h"
@@ -155,7 +154,7 @@ public:
/**
* The type used to store options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* \brief The type used to store the new home agent information
@@ -548,13 +547,13 @@ public:
/*
* The type used to store all multicast address records in a packet
*/
typedef std::list<multicast_address_record> multicast_address_records_list;
typedef std::vector<multicast_address_record> multicast_address_records_list;
/*
* The type used to store all source address (from Multicast
* Listener Query messages) in a packet
*/
typedef std::list<ipaddress_type> sources_list;
typedef std::vector<ipaddress_type> sources_list;
/**
* \brief Constructs an ICMPv6 object.

View File

@@ -30,7 +30,6 @@
#ifndef TINS_IP_H
#define TINS_IP_H
#include <list>
#include "pdu.h"
#include "small_uint.h"
#include "endianness.h"
@@ -244,7 +243,7 @@ public:
/**
* The type used to store IP options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* \brief Extracts metadata for this protocol based on the buffer provided

View File

@@ -30,7 +30,6 @@
#ifndef TINS_IPV6_h
#define TINS_IPV6_h
#include <list>
#include "macros.h"
#include "pdu.h"
#include "endianness.h"
@@ -71,7 +70,7 @@ public:
/**
* The type used to store the extension headers.
*/
typedef std::list<ext_header> headers_type;
typedef std::vector<ext_header> headers_type;
/**
* The values used to identify extension headers.

View File

@@ -30,7 +30,6 @@
#ifndef TINS_IEEE8022_H
#define TINS_IEEE8022_H
#include <list>
#include <vector>
#include <stdint.h>
#include "macros.h"
@@ -399,7 +398,7 @@ private:
#endif
typedef std::vector<uint8_t> field_type;
typedef std::list<field_type> field_list;
typedef std::vector<field_type> field_list;
void write_serialization(uint8_t* buffer, uint32_t total_sz);

View File

@@ -30,7 +30,6 @@
#ifndef TINS_PPPoE_H
#define TINS_PPPoE_H
#include <list>
#include <string>
#include <vector>
#include "pdu.h"
@@ -82,7 +81,7 @@ public:
/**
* The type used to store the options.
*/
typedef std::list<tag> tags_type;
typedef std::vector<tag> tags_type;
/**
* The type used to store the Vendor-Specific tag's value.

View File

@@ -30,8 +30,6 @@
#ifndef TINS_TCP_H
#define TINS_TCP_H
#include <list>
#include <vector>
#include <stdint.h>
#include <utility>
@@ -131,7 +129,7 @@ public:
/**
* The type used to store the options.
*/
typedef std::list<option> options_type;
typedef std::vector<option> options_type;
/**
* The type used to store the sack option.

View File

@@ -35,7 +35,6 @@
using std::string;
using std::vector;
using std::list;
using std::runtime_error;
using Tins::Memory::InputMemoryStream;

View File

@@ -38,7 +38,6 @@
using std::string;
using std::memcpy;
using std::list;
using std::make_pair;
using Tins::Memory::InputMemoryStream;

View File

@@ -49,7 +49,7 @@
#include "packet_sender.h"
#include "memory_helpers.h"
using std::list;
using std::vector;
using Tins::Memory::InputMemoryStream;
using Tins::Memory::OutputMemoryStream;
@@ -212,7 +212,7 @@ void Dot11::write_serialization(uint8_t* buffer, uint32_t total_sz) {
stream.write(header_);
write_ext_header(stream);
write_fixed_parameters(stream);
for (list<option>::const_iterator it = options_.begin(); it != options_.end(); ++it) {
for (vector<option>::const_iterator it = options_.begin(); it != options_.end(); ++it) {
stream.write<uint8_t>(it->option());
stream.write<uint8_t>(it->length_field());
stream.write(it->data_ptr(), it->data_size());

View File

@@ -47,7 +47,6 @@
#include "detail/pdu_helpers.h"
#include "pdu_allocator.h"
using std::list;
using std::memcmp;
using std::vector;

View File

@@ -91,11 +91,11 @@ TEST_F(DNSTest, ConstructorFromBuffer) {
EXPECT_EQ(dns.questions_count(), 1);
EXPECT_EQ(dns.answers_count(), 1);
std::list<DNS::query> queries = dns.queries();
std::vector<DNS::query> queries = dns.queries();
ASSERT_EQ(queries.size(), 1U);
test_equals(queries.front(), DNS::query("www.example.com", DNS::A, DNS::INTERNET));
std::list<DNS::resource> answers = dns.answers();
std::vector<DNS::resource> answers = dns.answers();
ASSERT_EQ(answers.size(), 1U);
test_equals(answers.front(), DNS::resource("www.example.com", "192.168.0.1", DNS::A,
DNS::INTERNET, 0x1234));