RTRlib
Loading...
Searching...
No Matches
aspa_array.h
Go to the documentation of this file.
1/*
2 * This file is part of RTRlib.
3 *
4 * This file is subject to the terms and conditions of the MIT license.
5 * See the file LICENSE in the top level directory for more details.
6 *
7 * Website: http://rtrlib.realmv6.org/
8 */
9
10#ifndef RTR_ASPA_ARRAY_H
11#define RTR_ASPA_ARRAY_H
12
13#include "../aspa.h"
14
15#include <stdbool.h>
16#include <stdint.h>
17#include <stdlib.h>
18#include <string.h>
19
27struct aspa_array {
28 uint32_t size;
29 size_t capacity;
31};
32
33// MARK: - Initialization & Deinitialization
34
40enum aspa_status aspa_array_create(struct aspa_array **array_ptr);
41
47void aspa_array_free(struct aspa_array *array, bool free_provider_arrays);
48
49// MARK: - Manipulation
50
61enum aspa_status aspa_array_insert(struct aspa_array *array, size_t index, struct aspa_record *record,
62 bool copy_providers);
63
73enum aspa_status aspa_array_append(struct aspa_array *array, struct aspa_record *record, bool copy_providers);
74
84enum aspa_status aspa_array_remove(struct aspa_array *array, size_t index, bool free_providers);
85
86// MARK: - Retrieval
87
95struct aspa_record *aspa_array_get_record(struct aspa_array *array, size_t index);
96
104struct aspa_record *aspa_array_search(struct aspa_array *array, uint32_t customer_asn);
105
113enum aspa_status aspa_array_reserve(struct aspa_array *array, size_t size);
114
115#endif // RTR_ASPA_ARRAY_H
struct aspa_record * aspa_array_search(struct aspa_array *array, uint32_t customer_asn)
Searches the given ASPA array for a record matching its customer ASN.
enum aspa_status aspa_array_create(struct aspa_array **array_ptr)
Creates an vector object.
enum aspa_status aspa_array_append(struct aspa_array *array, struct aspa_record *record, bool copy_providers)
Appends a given ASPA record to the array.
enum aspa_status aspa_array_remove(struct aspa_array *array, size_t index, bool free_providers)
Removes the record at the given index from the array.
struct aspa_record * aspa_array_get_record(struct aspa_array *array, size_t index)
Returns a reference to the record at the given index.
void aspa_array_free(struct aspa_array *array, bool free_provider_arrays)
Deletes the given ASPA array.
enum aspa_status aspa_array_insert(struct aspa_array *array, size_t index, struct aspa_record *record, bool copy_providers)
Inserts a given ASPA record into the array, preserving its order.
enum aspa_status aspa_array_reserve(struct aspa_array *array, size_t size)
Reserves some space in the array.
aspa_status
Possible return values for aspa_* functions.
Definition aspa.h:93
Struct which is similar in function to std::vector from C++.
Definition aspa_array.h:27
size_t capacity
Definition aspa_array.h:29
struct aspa_record * data
Definition aspa_array.h:30
uint32_t size
Definition aspa_array.h:28
ASPA Record Customer (Customer Autonomous Systen, CAS) authorizes a set of provider AS numbers.
Definition aspa.h:39
uint32_t customer_asn
Definition aspa.h:40