A wrapper for the NC operations.
More...
A wrapper for the NC operations.
About
The NC contains the configuration of the node. In NASA's bpnode implementations this is done through special tables, here we just use static arrays for every configuration table.
The arrays are hidden and exposed only via the setter functions in this module, because, again, some members of configuration tables are not implemented yet on the bplib side.
The functions can only be called when a channel or contact is stopped. This means the usual lifecycle of a channel / contact is as follows:
- Configure the channel / contact with the functions in this module.
- Call BPLib_PI_AddApplication() or BPLib_CLA_ContactSetup() for a channel / contact. It can only be configured again (using functions in this module) once it has been completely torn down (step 5). Tear down from this state is possible as well.
- Call BPLib_PI_StartApplication() or BPLib_CLA_ContactStart() respectively. This makes the channel / contact active and bundles can flow through them.
- With BPLib_PI_StopApplication() or BPLib_CLA_ContactStop() respectively, the channel / contact can be stopped. This retains its configuration and it can be started again by step 3 if necessary. Bundles will not flow anymore. This is useful for contacts, when the configuration should stay the same (e.g. same network address to connect to), but the contact is currently disconnected.
- Call BPLib_PI_RemoveApplication() or BPLib_CLA_ContactTeardown(). This will tear down the channel / contact. Now goto 1 if the channel / contact should be changed, for example when a new neighbor has been discovered.
Optimizations
bplib forces many tables in the NC which are not currently implemented. These have been removed and allowed to be NULL inside of bplib. When the features for these tables get implemented in bplib, and the port is reworked they have to be added back.
In NC, like in Default FWP (Framework Proxy), there are more counter tables, which take up several KB of space. These are disabled by default and can be enable again with the bplib_include_nc_telemetry pseudomodule.
|
| enum | bplib_nc_canonical_block_t { BPLIB_PREVIOUS_NODE_BLOCK = 0
, BPLIB_BUNDLE_AGE_BLOCK = 1
, BPLIB_HOP_COUNT_BLOCK = 2
, BPLIB_PAYLOAD_BLOCK = 3
} |
| | block type indicator for bplib_channel_set_block_*() functions More...
|
| |
|
| BPLib_Status_t | bplib_riot_nc_init (BPLib_NC_ConfigPtrs_t *ConfigPtrs) |
| | Initializes bplib's NC.
|
| |
| BPLib_Status_t | bplib_channel_set_hop_limit (uint32_t channel, uint8_t limit) |
| | Set the hop limit of the channel.
|
| |
| BPLib_Status_t | bplib_channel_set_crc_type (uint32_t channel, BPLib_CRC_Type_t type) |
| | Set the CRC type of the primary block.
|
| |
| BPLib_Status_t | bplib_channel_set_service_no (uint32_t channel, uint64_t service_no) |
| | Set the local service number of the channel.
|
| |
| BPLib_Status_t | bplib_channel_set_bundle_flags (uint32_t channel, uint64_t flags) |
| | Set the bundle control flags of the primary block.
|
| |
| BPLib_Status_t | bplib_channel_set_lifetime (uint32_t channel, uint64_t lifetime) |
| | Set the lifetime of a bundle, in [ms].
|
| |
| BPLib_Status_t | bplib_channel_set_dest_eid (uint32_t channel, BPLib_EID_t dest_eid) |
| | Set the destination of bundles in the channel.
|
| |
| BPLib_Status_t | bplib_channel_set_report_to_eid (uint32_t channel, BPLib_EID_t report_eid) |
| | Set the report-to node endpoint of bundles in the channel.
|
| |
| BPLib_Status_t | bplib_channel_set_block_include (uint32_t channel, bplib_nc_canonical_block_t block, bool include) |
| | Set if a block should be part of the bundle.
|
| |
| BPLib_Status_t | bplib_channel_set_block_crc_type (uint32_t channel, bplib_nc_canonical_block_t block, BPLib_CRC_Type_t type) |
| | Set the CRC type of a canonical block.
|
| |
| BPLib_Status_t | bplib_channel_set_block_num (uint32_t channel, bplib_nc_canonical_block_t block, uint32_t num) |
| | Set the block number of a canonical block.
|
| |
| BPLib_Status_t | bplib_channel_set_block_flags (uint32_t channel, bplib_nc_canonical_block_t block, uint64_t flags) |
| | Set the canonical block flags of a canonical block.
|
| |
| BPLib_Status_t | bplib_contact_set_destinations (uint32_t contact, unsigned index, BPLib_EID_Pattern_t eid_pat) |
| | Set one reachable EID pattern for a contact.
|
| |
| BPLib_Status_t | bplib_contact_set_out_addr (uint32_t contact, const char *addr, uint16_t port) |
| | Set the out address of a contact.
|
| |
| BPLib_Status_t | bplib_contact_set_in_addr (uint32_t contact, const char *addr, uint16_t port) |
| | Set the in address of a contact.
|
| |
◆ CONFIG_BPLIB_MAX_SEQ_NUM
| #define CONFIG_BPLIB_MAX_SEQ_NUM 1000000 |
Max sequence number, after which it wraps back to 0.
Definition at line 70 of file bplib_riot_nc.h.
◆ bplib_nc_canonical_block_t
block type indicator for bplib_channel_set_block_*() functions
Definition at line 76 of file bplib_riot_nc.h.
◆ bplib_channel_set_block_crc_type()
Set the CRC type of a canonical block.
- Parameters
-
| channel | Index of the channel |
| block | Selector of a canonical block |
| type | CRC type to use |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
| BPLIB_INVALID_CONFIG_ERR | if the block parameter is invalid |
| BPLIB_INVALID_CRC_ERROR | if the CRC type is unknown |
◆ bplib_channel_set_block_flags()
Set the canonical block flags of a canonical block.
Refer to RFC 9171 for details. For example one can specify that the block has to be replicated in every fragment, or deleted when it cannot be processed.
- Parameters
-
| channel | Index of the channel |
| block | Selector of a canonical block |
| flags | Block flags to set |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
| BPLIB_INVALID_CONFIG_ERR | if the block parameter is invalid |
◆ bplib_channel_set_block_include()
Set if a block should be part of the bundle.
- Note
- Whether the BPLIB_BUNDLE_AGE_BLOCK is present depends on weather an accurate DTN time can be provided, this function has no effect.
-
The BPLIB_PAYLOAD_BLOCK can also not be turned off.
- Parameters
-
| channel | Index of the channel |
| block | Selector of a canonical block |
| include | true to include the block, false to not include it. See the description for exceptions. |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
| BPLIB_INVALID_CONFIG_ERR | if the block parameter is invalid |
◆ bplib_channel_set_block_num()
Set the block number of a canonical block.
- Note
- All canonical blocks have to have unique block numbers. Without a call of this function they default to 0.
-
The payload block has to have block number 1, which is also not changeable with this function.
- Parameters
-
| channel | Index of the channel |
| block | Selector of a canonical block |
| num | Block number to set |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
| BPLIB_INVALID_CONFIG_ERR | if the block parameter is invalid |
◆ bplib_channel_set_bundle_flags()
| BPLib_Status_t bplib_channel_set_bundle_flags |
( |
uint32_t | channel, |
|
|
uint64_t | flags ) |
Set the bundle control flags of the primary block.
Refer to RFC 9171, an example would be to prevent fragmentation or request reports.
- Parameters
-
| channel | Index of the channel |
| flags | Bundle control flags |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_channel_set_crc_type()
| BPLib_Status_t bplib_channel_set_crc_type |
( |
uint32_t | channel, |
|
|
BPLib_CRC_Type_t | type ) |
Set the CRC type of the primary block.
- Parameters
-
| channel | Index of the channel |
| type | CRC Type, see BPLib_CRC_Type_t. BPLib_CRC_Type_None is not supported here. |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
| BPLIB_INVALID_CRC_ERROR | if the CRC type is unknown |
◆ bplib_channel_set_dest_eid()
| BPLib_Status_t bplib_channel_set_dest_eid |
( |
uint32_t | channel, |
|
|
BPLib_EID_t | dest_eid ) |
Set the destination of bundles in the channel.
- Parameters
-
| channel | Index of the channel |
| dest_eid | Destination EID. |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_channel_set_hop_limit()
| BPLib_Status_t bplib_channel_set_hop_limit |
( |
uint32_t | channel, |
|
|
uint8_t | limit ) |
Set the hop limit of the channel.
This only matters if the Hop Limit block is enabled, using bplib_channel_set_block_include()
- Parameters
-
| channel | Index of the channel |
| limit | Hop limit |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_channel_set_lifetime()
| BPLib_Status_t bplib_channel_set_lifetime |
( |
uint32_t | channel, |
|
|
uint64_t | lifetime ) |
Set the lifetime of a bundle, in [ms].
Bundles in transit for longer may / will be dropped by BP nodes.
- Parameters
-
| channel | Index of the channel |
| lifetime | Lifetime in ms |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_channel_set_report_to_eid()
| BPLib_Status_t bplib_channel_set_report_to_eid |
( |
uint32_t | channel, |
|
|
BPLib_EID_t | report_eid ) |
Set the report-to node endpoint of bundles in the channel.
- Note
- This may be set to BPLIB_EID_DTN_NONE for the null endpoint.
- Parameters
-
| channel | Index of the channel |
| report_eid | Report-to EID. |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_channel_set_service_no()
| BPLib_Status_t bplib_channel_set_service_no |
( |
uint32_t | channel, |
|
|
uint64_t | service_no ) |
Set the local service number of the channel.
Bundles to this service number can then be received with BPLib_PI_Egress()
- Parameters
-
| channel | Index of the channel |
| service_no | Local service number |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CHAN_ID_ERR | if channel >= BPLIB_MAX_NUM_CHANNELS |
| BPLIB_APP_STATE_ERR | if the channel / app is not in removed state |
◆ bplib_contact_set_destinations()
| BPLib_Status_t bplib_contact_set_destinations |
( |
uint32_t | contact, |
|
|
unsigned | index, |
|
|
BPLib_EID_Pattern_t | eid_pat ) |
Set one reachable EID pattern for a contact.
Each contact has BPLIB_MAX_CONTACT_DEST_EIDS slots for EID patterns it can reach.
- Parameters
-
| contact | Index of the contact |
| index | Index of the EID pattern slot. |
| eid_pat | EID pattern, defining all EIDs that can be reached over this contact. |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CONT_ID_ERR | if contact >= BPLIB_MAX_NUM_CONTACTS |
| BPLIB_CLA_INCORRECT_STATE | if the contact is not torn down |
| BPLIB_ERROR | if index >= BPLIB_MAX_CONTACT_DEST_EIDS |
◆ bplib_contact_set_in_addr()
| BPLib_Status_t bplib_contact_set_in_addr |
( |
uint32_t | contact, |
|
|
const char * | addr, |
|
|
uint16_t | port ) |
Set the in address of a contact.
The type of address depends on the CLA. For the UDP CLA this is an IPv6 address. This address may be meaningless depending on the CLA implementation, for UDP CLA it is the address to listen on, to bind to.
- Note
- The table only holds BPLIB_MAX_IP_LENGTH (including '\0'), which might need to be increased for other / external CLAs.
- Parameters
-
| contact | Index of the contact |
| addr | CLA local address. |
| port | CLA local port |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CONT_ID_ERR | if contact >= BPLIB_MAX_NUM_CONTACTS |
| BPLIB_CLA_INCORRECT_STATE | if the contact is not torn down |
◆ bplib_contact_set_out_addr()
| BPLib_Status_t bplib_contact_set_out_addr |
( |
uint32_t | contact, |
|
|
const char * | addr, |
|
|
uint16_t | port ) |
Set the out address of a contact.
The type of address depends on the CLA. For the UDP CLA this is an IPv6 address. This is the address where bundles are sent to.
- Note
- The table only holds BPLIB_MAX_IP_LENGTH (including '\0'), which might need to be increased for other / external CLAs.
- Parameters
-
| contact | Index of the contact |
| addr | CLA destination address. |
| port | CLA destination port |
- Return values
-
| BPLIB_SUCCESS | on success |
| BPLIB_INVALID_CONT_ID_ERR | if contact >= BPLIB_MAX_NUM_CONTACTS |
| BPLIB_CLA_INCORRECT_STATE | if the contact is not torn down |
◆ bplib_riot_nc_init()
| BPLib_Status_t bplib_riot_nc_init |
( |
BPLib_NC_ConfigPtrs_t * | ConfigPtrs | ) |
|
Initializes bplib's NC.
NC means "Node Config" and contains pointers to the configuration tables. This function sets the config pointers, calls BPLib_NC_Init and returns.
- Parameters
-
| [out] | ConfigPtrs | pointers in this will be set to the config |
- Returns
- BPLIB_SUCCESS on success, forwarded from BPLib_NC_Init call.