Skip to content

Commit 62a3cb1

Browse files
Add pfx_table definitions from rtrlib/pfx/pfx.h
These definitions are necessary to make the documented 'advanced usage' example run without errors.
1 parent d3dc6b6 commit 62a3cb1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

rtrlib.cdef

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,56 @@ typedef void (*pfx_update_fp)(struct pfx_table *pfx_table, const struct pfx_reco
420420
*/
421421
typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
422422

423+
/**
424+
* @brief pfx_table.
425+
* @param ipv4
426+
* @param ipv6
427+
* @param update_fp
428+
* @param lock
429+
*/
430+
struct pfx_table {
431+
struct trie_node *ipv4;
432+
struct trie_node *ipv6;
433+
pfx_update_fp update_fp;
434+
...;
435+
};
436+
437+
/**
438+
* @brief Initializes the pfx_table struct.
439+
* @param[in] pfx_table pfx_table that will be initialized.
440+
* @param[in] update_fp A function pointer that will be called if a record was added or removed.
441+
*/
442+
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
443+
444+
/**
445+
* @brief Frees all memory associated with the pfx_table.
446+
* @param[in] pfx_table pfx_table that will be freed.
447+
*/
448+
void pfx_table_free(struct pfx_table *pfx_table);
449+
450+
/**
451+
* @brief Adds a pfx_record to a pfx_table.
452+
* @param[in] pfx_table pfx_table to use.
453+
* @param[in] pfx_record pfx_record that will be added.
454+
* @return PFX_SUCCESS On success.
455+
* @return PFX_ERROR On error.
456+
* @return PFX_DUPLICATE_RECORD If the pfx_record already exists.
457+
*/
458+
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
459+
460+
/**
461+
* @brief Validates the origin of a BGP-Route.
462+
* @param[in] pfx_table pfx_table to use.
463+
* @param[in] asn Autonomous system number of the Origin-AS of the route.
464+
* @param[in] prefix Announced network Prefix.
465+
* @param[in] mask_len Length of the network mask of the announced prefix.
466+
* @param[out] result Result of the validation.
467+
* @return PFX_SUCCESS On success.
468+
* @return PFX_ERROR On error.
469+
*/
470+
int pfx_table_validate(struct pfx_table *pfx_table, const uint32_t asn, const struct lrtr_ip_addr *prefix,
471+
const uint8_t mask_len, enum pfxv_state *result);
472+
423473
/**
424474
* @brief Validates the origin of a BGP-Route and returns a list of pfx_record that decided the result.
425475
* @param[in] pfx_table pfx_table to use.

0 commit comments

Comments
 (0)