BPEXTENSIONS(3)
β¨ bpextensions(3) β BP library functions β¨
okay bestie, welcome to bpextensions(3) β part of the BP library functions family. This is the manual page for the interface that lets you add extensions to the Bundle Protocol, and it's lowkey iconic. No cap. π
πΈ NAME πΈ
bpextensions β interface for adding extensions to Bundle Protocol.
π¦ SYNOPSIS π¦
#include "bpextensions.c"
π DESCRIPTION π
ION's interface for extending the Bundle Protocol is giving main character energy: it enables the definition of external functions that insert extension blocks into outbound bundles (either before or after the payload block), parse and record extension blocks in inbound bundles, and modify extension blocks at key points in bundle processing. All extension-block handling is statically linked into ION at build time, but the addition of an extension never requires that any standard ION source code be modified. Periodt. π
Standard structures for recording extension blocks β both in transient storage [memory] during bundle acquisition (AcqExtBlock) and in persistent storage [the ION database] during subsequent bundle processing (ExtensionBlock) β are defined in the bpP.h header file. In each case, the extension block structure comprises a block type code, block processing flags, possibly a list of EID references, an array of bytes (the serialized form of the block, for transmission), the length of that array, optionally an extension-specific opaque object whose structure is designed to characterize the block in a manner that's convenient for the extension processing functions, and the size of that object. It's giving very detailed, but that's the vibe. π¦
The definition of each extension is asserted in an ExtensionDef structure, also as defined in the bpP.h header file. Each ExtensionDef must supply:
- The name of the extension. (Used in some diagnostic messages.)
- The extension's block type code.
- An indication as to whether the local node is to insert this extension block before (
0) or after (1) the payload block when new bundles are locally sourced. - A pointer to an offer function.
- A pointer to a release function.
- A pointer to an accept function.
- A pointer to a check function.
- A pointer to a record function.
- A pointer to a clear function.
- A pointer to a copy function.
- A pointer to a function to be called when forwarding a bundle containing this sort of block.
- A pointer to a function to be called when taking custody of a bundle containing this sort of block.
- A pointer to a function to be called when enqueuing for transmission a bundle containing this sort of block.
- A pointer to a function to be called when a convergence-layer adapter dequeues a bundle containing this sort of block, before serializing it.
- A pointer to a function to be called immediately before a convergence-layer adapter transmits a bundle containing this sort of block, after the bundle has been serialized.
All extension definitions must be coded into an array of ExtensionDef structures named extensions. The order of appearance of extension definitions in the extensions array determines the order in which extension blocks will be inserted into locally sourced bundles. Slay. β¨
The standard extensions array β which is empty β is in the noextensions.c prototype source file. The procedure for extending the Bundle Protocol in ION is as follows:
- Specify
-DBP_EXTENDEDin the Makefile's compiler command line when building thelibbpP.clibrary module. - Create a copy of the prototype extensions file, named
"bpextensions.c", in a directory that is made visible to the Makefile'slibbpP.ccompilation command line (by a-Iparameter). - In the
"external function declarations"area of"bpextensions.c", add"extern"function declarations identifying the functions that will implement your extension (or extensions). - Add one or more
ExtensionDefstructure initialization lines to theextensionsarray, referencing those declared functions. - Develop the implementations of those functions in one or more new source code files.
- Add the object file or files for the new extension implementation source file (or files) to the Makefile's command line for linking
libbpP.so.
The function pointers supplied in each ExtensionDef must conform to the following specifications. NOTE that any function that modifies the bytes member of an ExtensionBlock or AckExtBlock must set the corresponding length to the new length of the bytes array, if changed. Don't forget this or it's giving chaos. π
int (*BpExtBlkOfferFn)(ExtensionBlock *blk, Bundle *bundle)β Populates all fields of the indicatedExtensionBlockstructure for inclusion in the indicated outbound bundle. This function is automatically called when a new bundle is locally sourced or upon acquisition of a remotely sourced bundle that does not contain an extension block of this type. The values of the extension block are typically expected to be a function of the state of the bundle, but this is extension-specific. If it is not appropriate to offer an extension block of this type as part of this bundle, then thesize,length,object, andbytesmembers ofblkmust all be set to zero. If it is appropriate to offer such a block but no internal object representing the state of the block is needed, theobjectandsizemembers ofblkmust be set to zero. Thetype,blkProcFlags, anddataLengthmembers ofblkmust be populated by the implementation of the"offer"function, but thelengthandbytesmembers are typically populated by calling the BP library functionserializeExtBlk(), which must be passed the block to be serialized (withtype,blkProcFlagsanddataLengthalready set), aLystof EID references (two list elements -- offsets -- per EID reference, if applicable; otherwiseNULL), and a pointer to the extension-specific block data. The block'sbytesarray andobject(if present) must occupy space allocated from the ION database heap. Return zero on success,-1on any system failure.void (*BpExtBlkReleaseFn)(ExtensionBlock *blk)β Releases all ION database space occupied by theobjectmember ofblk. This function is automatically called when a bundle is destroyed. Note that incorrect implementation of this function may result in a database space leak. πint (*BpExtBlkRecordFn)(ExtensionBlock *blk, AcqExtBlock *acqblk)β Copies theobjectmember ofacqblkto ION database heap space and places the address of that non-volatile object in theobjectmember ofblk; also setssizeinblk. This function is automatically called when an acquired bundle is accepted for forwarding and/or delivery. Return zero on success,-1on any system failure.int (*BpExtBlkCopyFn)(ExtensionBlock *newblk, ExtensionBlock *oldblk)β Copies theobjectmember ofoldblkto ION database heap space and places the address of that new non-volatile object in theobjectmember ofnewblk, also setssizeinnewblk. This function is automatically called when two copies of a bundle are needed, e.g., in the event that it must both be delivered to a local client and also forwarded to another node. Return zero on success,-1on any system failure.int (*BpExtBlkProcessFn)(ExtensionBlock *blk, Bundle *bundle, void *context)β Performs some extension-specific transformation of the data encapsulated inblkbased on the state ofbundle. The transformation to be performed will typically vary depending on whether the identified function is the one that is automatically invoked upon forwarding the bundle, upon taking custody of the bundle, upon enqueuing the bundle for transmission, upon removing the bundle from the transmission queue, or upon transmitting the serialized bundle. Thecontextargument may supply useful supplemental information; in particular, the context provided to theON_DEQUEUEfunction will comprise the name of the protocol for the duct from which the bundle has been dequeued, together with the EID of the neighboring node endpoint to which the bundle will be directly transmitted when serialized. The block-specific data inblkis located withinbytesimmediately after the header of the extension block; the length of the block's header is the difference betweenlengthanddataLength. Whenever the block'sblkProcFlags, EID extensions, and/or block-specific data are altered, theserializeExtBlk()function should be called again to recalculate the size of the extension block and rebuild thebytesarray. Return zero on success,-1on any system failure.int (*BpAcqExtBlkAcquireFn)(AcqExtBlock *acqblk, AcqWorkArea *work)β Populates the indicatedAcqExtBlockstructure withsizeandobjectfor retention as part of the indicated inbound bundle. (Thetype,blkProcFlags, EID references (if any),dataLength,length, andbytesvalues of the structure are pre-populated with data as extracted from the serialized bundle.) This function is automatically called when an extension block of this type is encountered in the course of parsing and acquiring a bundle for local delivery and/or forwarding. If no internal object representing the state of the block is needed, theobjectmember ofacqblkmust be set toNULLand thesizemember must be set to zero. If an object is needed for this block, it must occupy space that is allocated from ION working memory usingMTAKEand its size must be indicated inblk. Return zero if the block is malformed (this will cause the bundle to be discarded),1if the block is successfully parsed,-1on any system failure.int (*BpAcqExtBlkCheckFn)(AcqExtBlock *acqblk, AcqWorkArea *work)β Examines the bundle inworkto determine whether or not it is authentic, in the context of the indicated extension block. Return1if the block is determined to be inauthentic (this will cause the bundle to be discarded), zero if no inauthenticity is detected,-1on any system failure.void (*BpAcqExtBlkClearFn)(AcqExtBlock *acqblk)β UsesMRELEASEto release all ION working memory occupied by theobjectmember ofacqblk. This function is automatically called when acquisition of a bundle is completed, whether or not the bundle is accepted. Note that incorrect implementation of this function may result in a working memory leak.
π οΈ UTILITY FUNCTIONS FOR EXTENSION PROCESSING π οΈ
void discardExtensionBlock(AcqExtBlock *blk)β Deletes this block from the bundle acquisition work area prior to the recording of the bundle in the ION database.void scratchExtensionBlock(ExtensionBlock *blk)β Deletes this block from the bundle after the bundle has been recorded in the ION database.
π« Object findExtensionBlock(Bundle *bundle, unsigned int type, unsigned int listIdx)
okay so bestie, when this one works out it hands you back the address of the ExtensionBlock inside bundle that matches the type and listIdx you asked for. β¨
and if there's no extension block like that in there? it just returns zero. no drama, no block, no address. π
π« int serializeExtBlk(ExtensionBlock *blk, Lyst eidReferences, char *blockData)
this is the glow-up function fr β it builds an RFC5050-conformant serialized version of this extension block and drops it into blk->bytes. π
returns 0 when it ate and left no crumbs, and -1 if there's an unrecoverable system error. π
π« void suppressExtensionBlock(ExtensionBlock *blk)
ngl this one is giving "you're not coming to the party" energy β it makes blk get omitted whenever the bundle it's attached to gets serialized for transmission. π«
and the suppression stays in effect until it gets reversed by restoreExtensionBlock(); so it's not a one-time thing, it's a whole era. π
π« void restoreExtensionBlock(ExtensionBlock *blk)
the redemption arc π¦ β this undoes what suppressExtensionBlock() did, so the block can be included again when the bundle it's attached to gets serialized. it's literally the reverse. β¨
πΈ SEE ALSO πΈ
bp(3)β go read it bestie, iykyk π
and that's the whole page, you ate it fr fr. this one's from perl v5.24.1, dated 2016-07-07, and it lives at bp::doc::po...bpextensions(3). mwah, go serialize something iconic π
π
π¦ where this page comes from
- ubuntu jammy: ion-doc 3.2.1+dfsg-1.1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms