Loading...
Searching...
No Matches
NC (Node Config) wrapper

A wrapper for the NC operations. More...

Detailed Description

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:

  1. Configure the channel / contact with the functions in this module.
  2. 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.
  3. Call BPLib_PI_StartApplication() or BPLib_CLA_ContactStart() respectively. This makes the channel / contact active and bundles can flow through them.
  4. 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.
  5. 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.

Files

file  bplib_riot_nc.h
 A wrapper for the NC operations.
 

Macros

#define CONFIG_BPLIB_MAX_SEQ_NUM   1000000
 Max sequence number, after which it wraps back to 0.
 

Enumerations

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...
 

Functions

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.
 

Macro Definition Documentation

◆ 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.

Enumeration Type Documentation

◆ bplib_nc_canonical_block_t

block type indicator for bplib_channel_set_block_*() functions

Definition at line 76 of file bplib_riot_nc.h.

Function Documentation

◆ bplib_channel_set_block_crc_type()

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.

Parameters
channelIndex of the channel
blockSelector of a canonical block
typeCRC type to use
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif the channel / app is not in removed state
BPLIB_INVALID_CONFIG_ERRif the block parameter is invalid
BPLIB_INVALID_CRC_ERRORif the CRC type is unknown

◆ bplib_channel_set_block_flags()

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.

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
channelIndex of the channel
blockSelector of a canonical block
flagsBlock flags to set
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif the channel / app is not in removed state
BPLIB_INVALID_CONFIG_ERRif the block parameter is invalid

◆ bplib_channel_set_block_include()

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.

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
channelIndex of the channel
blockSelector of a canonical block
includetrue to include the block, false to not include it. See the description for exceptions.
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif the channel / app is not in removed state
BPLIB_INVALID_CONFIG_ERRif the block parameter is invalid

◆ bplib_channel_set_block_num()

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.

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
channelIndex of the channel
blockSelector of a canonical block
numBlock number to set
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif the channel / app is not in removed state
BPLIB_INVALID_CONFIG_ERRif 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
channelIndex of the channel
flagsBundle control flags
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
channelIndex of the channel
typeCRC Type, see BPLib_CRC_Type_t. BPLib_CRC_Type_None is not supported here.
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif the channel / app is not in removed state
BPLIB_INVALID_CRC_ERRORif 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
channelIndex of the channel
dest_eidDestination EID.
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
channelIndex of the channel
limitHop limit
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
channelIndex of the channel
lifetimeLifetime in ms
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
channelIndex of the channel
report_eidReport-to EID.
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
channelIndex of the channel
service_noLocal service number
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CHAN_ID_ERRif channel >= BPLIB_MAX_NUM_CHANNELS
BPLIB_APP_STATE_ERRif 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
contactIndex of the contact
indexIndex of the EID pattern slot.
eid_patEID pattern, defining all EIDs that can be reached over this contact.
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CONT_ID_ERRif contact >= BPLIB_MAX_NUM_CONTACTS
BPLIB_CLA_INCORRECT_STATEif the contact is not torn down
BPLIB_ERRORif 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
contactIndex of the contact
addrCLA local address.
portCLA local port
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CONT_ID_ERRif contact >= BPLIB_MAX_NUM_CONTACTS
BPLIB_CLA_INCORRECT_STATEif 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
contactIndex of the contact
addrCLA destination address.
portCLA destination port
Return values
BPLIB_SUCCESSon success
BPLIB_INVALID_CONT_ID_ERRif contact >= BPLIB_MAX_NUM_CONTACTS
BPLIB_CLA_INCORRECT_STATEif 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]ConfigPtrspointers in this will be set to the config
Returns
BPLIB_SUCCESS on success, forwarded from BPLib_NC_Init call.