RTRlib
Loading...
Searching...
No Matches
aspa_array.h File Reference
#include "../aspa.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  aspa_array
 Struct which is similar in function to std::vector from C++. More...
 

Functions

enum aspa_status aspa_array_create (struct aspa_array **array_ptr)
 Creates an vector object.
 
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_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_recordaspa_array_get_record (struct aspa_array *array, size_t index)
 Returns a reference to the record at the given index.
 
struct aspa_recordaspa_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_reserve (struct aspa_array *array, size_t size)
 Reserves some space in the array.
 

Function Documentation

◆ aspa_array_append()

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.

Parameters
arrayThe ASPA array that will hold the new record.
recordThe record that will be appended to the array.
copy_providersA boolean value indicating whether the array should copy the record's providers before appending the record.
Returns
ASPA_SUCCESS if the operation succeeds, ASPA_ERROR if it fails.

◆ aspa_array_create()

enum aspa_status aspa_array_create ( struct aspa_array **  array_ptr)

Creates an vector object.

Parameters
[in,out]array_ptrPointer to a variable that will hold a reference to the newly created array.
Returns
ASPA_SUCCESS if the operation succeeds, ASPA_ERROR if it fails.

◆ aspa_array_free()

void aspa_array_free ( struct aspa_array array,
bool  free_provider_arrays 
)

Deletes the given ASPA array.

Parameters
arrayASPA array which will be deleted
free_provider_arraysA boolean value determining whether each record's provider array should be deallocated.

◆ aspa_array_get_record()

struct aspa_record * aspa_array_get_record ( struct aspa_array array,
size_t  index 
)

Returns a reference to the record at the given index.

Parameters
arrayASPA array
indexThe index in the ASPA array.
Returns
A reference to the aspa_record if found, NULL otherwise.

◆ aspa_array_insert()

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.

Parameters
arrayThe ASPA array that will hold the new record.
indexThe index at which the new record will be stored.
recordThe new record.
copy_providersA boolean value indicating whether the array should copy the record's providers before inserting the record.
Returns
ASPA_SUCCESS if the operation succeeds, ASPA_ERROR if it fails.

◆ aspa_array_remove()

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.

Parameters
arrayThe array to remove the record from.
indexThe record's index.
free_providersA boolean value determining whether to free the existing record's provider array.
Returns
ASPA_SUCCESS if the operation succeeds, ASPA_RECORD_NOT_FOUND if the record's index doesn't exist, ASPA_ERROR otherwise.

◆ aspa_array_reserve()

enum aspa_status aspa_array_reserve ( struct aspa_array array,
size_t  size 
)

Reserves some space in the array.

Parameters
arrayThe array to remove the record from.
sizethe number of object that should definetly fit into the array
Returns
ASPA_SUCCESS if the operation succeeds ASPA_ERROR otherwise.

◆ aspa_array_search()

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.

Parameters
arrayThe array to search.
customer_asnCustomer ASN
Returns
A reference to the aspa_record if found, NULL otherwise.