#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | K2B_DEACTIVATE_LEVEL 0 |
#define | K2B_CRITICAL_ERROR_LEVEL 1 |
#define | K2B_ERROR_LEVEL 2 |
#define | K2B_WARNING_LEVEL 3 |
#define | K2B_INFO_LEVEL 4 |
#define | K2B_DETAIL_LEVEL 5 |
#define | K2B_TRACE_LEVEL 6 |
Functions | |
void | k2bStartup (int inPort) |
void | k2bShutdown () |
void | k2bSetLoggingLevel (int inLoggingLevel) |
void | k2bSetLogFile (char *inLogFilePath) |
char | k2bIsLocalAddressProvidedByNetwork () |
char* | k2bGetLocalHostAddress () |
void | k2bSetTimeToLive (int inTimeToLive) |
int | k2bGetTimeToLive () |
void | k2bSetTimeToLiveCap (int inCap) |
int | k2bGetTimeToLiveCap () |
void | k2bSetLocalHostAddress (char *inAddress) |
void | k2bSetTargetNumberOfConnections (int inTarget) |
int | k2bGetTargetNumberOfConnections () |
void | k2bAddHost (char *inHostAddress, int inHostPort) |
int | k2bGetConnectedHostList (char ***outHostAddresses, int **outHostPorts) |
void | k2bSubscribeToChannel (char *inChannelName) |
void | k2bUnsubscribeFromChannel (char *inChannelName) |
int | k2bGetSubscriptionList (char ***outChannelNames) |
void | k2bInitiateBroadcast (char *inChannelName, char *inBroadcastName, char *inBroadcastComment, char *inFilePath, char *inContentType) |
void | k2bInitiateBroadcastSeries (char *inChannelName, int inNumBroadcasts, char **inBroadcastNames, char **inBroadcastComments, char **inFilePaths, char **inContentTypes) |
int | k2bGetCaughtPrebroadcasts (char ***outChannelNames, char ***outBroadcastNames, char ***outComments, char ***outContentTypes, unsigned long **outContentLengthsInBytes, char **outWantedFlags) |
void | k2bGenerateSenderKeyPair (char *inChannelName, char *inRandomSeed) |
char | k2bFetchReceiverKey (char *inChannelName, char *inKeyURL) |
char* | k2bGetSenderKeyFile (char *inChannelName) |
char* | k2bGetReceiverKeyFile (char *inChannelName) |
int | k2bGetChannelsWithSenderKeys (char ***outChannelNames) |
int | k2bGetChannelsWithReceiverKeys (char ***outChannelNames) |
int | k2bGetPendingBroadcastStatus (char ***outChannelNames, char ***outBroadcastNames, char ***outComments, char ***outContentTypes, unsigned long **outContentLengthsInBytes, float **outFractionComplete, float **outKiBPerSecond, char **outCancelFlags) |
void | k2bCancelPendingBroadcast (char *inChannelName, char *inBroadcastName) |
The API (Application Programming Interface) for interfacing with the functionality of the konspire2b reference implementation.
This API is essentially a collection of functions for controling the behavior of a konspire2b-compliant node.
All parameters of type (char *) must be \0-terminated strings. Such parameters must be destroyed by the function caller if non-const: the parameters are copied internally by the callee.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Adds a host to the local host list.
k2bAddHost( "k2b.myhost.com", 6089 ); k2bAddHost( "128.243.100.9", 6089 ); |
|
Cancels receipt of a pending broadcast.
|
|
Adds a receiver key by downloading it from a URL. The public portion of the key will be saved into the receiver key folder with the name "channelName.key".
char fetched = k2bFetchReceiverKey( "testChannel", "http://www.myserver.com/testChan.key" ); |
|
Generates a sender key pair. The private portion of the key will be saved into the sender key folder with the name "channelName.key". The public portion of the key will be saved into the receiver key folder with the name "channelName.key".
k2bGenerateSenderKeyPair( "testChannel", "sdfj fjsdf u48932 fjk83mv9 df9" ); |
|
Gets a list of caught prebroadcasts. Note that the reference implementation discards old caught Prebroadcasts, so the returned list is bounded in sized.
char **caughtChannelNames; char **caughtBroadcastNames; char **caughtComments; char **caughtContentTypes; unsigned long *caughtContentLengths; char *caughtWantedFlags; int numCaught = k2bGetCaughtPrebroadcasts( &caughtChannelNames, &caughtBroadcastNames, &caughtComments, &caughtContentTypes, &caughtContentLengths ); // process caught Prebroadcasts here ... // now destroyed returned arrays for( int i=0; i<numCaught; i++ ) { delete [] caughtChannelNames[i]; delete [] caughtBroadcastNames[i]; delete [] caughtComments[i]; delete [] caughtContentTypes[i]; } delete [] caughtChannelNames; delete [] caughtBroadcastNames; delete [] caughtComments; delete [] caughtContentTypes; delete [] caughtContentLengths; delete [] caughtWantedFlags; |
|
Gets a list of channels for which we have receiver keys.
char **channelNames; int numChannels = k2bGetChannelsWithReceiverKeys( &channelNames ); // process channel names here ... // now destroyed returned array for( int i=0; i<numChannels; i++ ) { delete [] channelNames[i]; } delete [] channelNames; |
|
Gets a list of channels for which we have sender keys.
char **channelNames; int numChannels = k2bGetChannelsWithSenderKeys( &channelNames ); // process channel names here ... // now destroyed returned array for( int i=0; i<numChannels; i++ ) { delete [] channelNames[i]; } delete [] channelNames; |
|
Gets a list of hosts that the local node is directly connected to.
char **addresses; int *ports; int numHosts = k2bGetConnectedHostList( &addresses, &ports ); // process addresses here ... // now destroyed returned arrays for( int i=0; i<numHosts; i++ ) { delete [] addresses[i]; } delete [] addresses; delete [] ports; |
|
Gets the local network address of this node. |
|
Gets the status of any broadcast in the process of being received. When these broadcasts are completely received, they will be copied into the received folder and into the appropriate channel sub-folder.
char **pendingChannelNames; char **pendingBroadcastNames; char **pendingComments; char **pendingContentTypes; unsigned long *pendingContentLengths; float *fractionComplete; float *pendingSpeeds; char *cancelFlags; int numPending = k2bGetPendingBroadcastStatus( &pendingChannelNames, &pendingBroadcastNames, &pendingComments, &pendingContentTypes, &pendingContentLengths, &fractionComplete, &pendingSpeeds, &cancelFlags ); // process pending Broadcasts here ... // now destroyed returned arrays for( int i=0; i<numPending; i++ ) { delete [] pendingChannelNames[i]; delete [] pendingBroadcastNames[i]; delete [] pendingComments[i]; delete [] pendingContentTypes[i]; } delete [] pendingChannelNames; delete [] pendingBroadcastNames; delete [] pendingComments; delete [] pendingContentTypes; delete [] pendingContentLengths; delete [] fractionComplete; delete [] pendingSpeeds; delete [] cancelFlags; |
|
Gets the path to the receiver (public) portion of a key for a channel, if it exists.
char *filePath = k2bGetReceiverKeyFile( "testChan" ); if( filePath != NULL ) { // process file path here ... // destroy file path delete [] filePath; } |
|
Gets the path to the sender (private) portion of a key for a channel, if it exists.
char *filePath = k2bGetSenderKeyFile( "testChan" ); if( filePath != NULL ) { // process file path here ... // destroy file path delete [] filePath; } |
|
Gets a list of subscribed channels.
char **channelNames; int numChannels = k2bGetSubscriptionList( &channelNames ); // process channel names here ... // now destroyed returned array for( int i=0; i<numChannels; i++ ) { delete [] channelNames[i]; } delete [] channelNames; |
|
Sets the number of connections this node is trying to maintain.
|
|
Gets the time to live for new prebroadcasts sent by this node.
|
|
Gets the cap for the time to live of forwarded prebroadcasts.
|
|
Sends a broadcast. Note: If a sender key exists for the specified channel, it will be used to sign the broadcast.
k2bInitiateBroadcast( "testChan", "testBroadcast.txt", "This is a test broadcast.", "myFiles/testMessage.txt", "text/plain" ); |
|
Sends a series of broadcasts out on the same channel, one by one. Note: If a sender key exists for the specified channel, it will be used to sign the broadcast.
int numBroadcasts = 2; char **names = new char*[ numBroadcasts ]; names[0] = "testFile1.txt"; names[2] = "testFile2.txt"; char **comments = new char*[ numBroadcasts ]; comments[0] = "The first in this series."; comments[2] = "The second in this series."; char **paths = new char*[ numBroadcasts ]; paths[0] = "myFiles/testMessage1.txt"; paths[2] = "myFiles/testMessage2.txt"; char **types = new char*[ numBroadcasts ]; types[0] = "text/plain"; types[2] = "text/plain"; k2bInitiateBroadcastSeries( "testChan", numBroadcasts, names, comments, paths, types ); delete [] names; delete [] comments; delete [] paths; delete [] types; |
|
Gets whether the local network address of this node is provided by the network system.
|
|
Sets the local network address of this node. This parameter is useful for nodes operating behind firewalls with tunnels for k2b traffic. In such cases, the address of the firewall must be specified so that other nodes outside the firewall can innitiate connections to the firewall-protected node.
|
|
Sets the file to which log messages are written. Defaults to konspire2b.log in the current working directory.
k2bSetLogFile( "test.log" ); |
|
Sets the logging level used by the reference implementation.
|
|
Sets the number of connections maintained by this node.
|
|
Sets the time to live for new prebroadcasts sent by this node.
|
|
Sets the cap for the time to live of forwarded prebroadcasts.
|
|
Halts the konspire2b reference implementation system. Should be called before exiting the program to avoid memory leaks. |
|
Constructs and starts the konspire2b reference implementation system. Must be called before calling any other API calls.
|
|
Subscribes to a channel and creates a received directory for the channel if the directory does not exist.
k2bSubscribeToChannel( "testChannel" ); |
|
Unsubscribes from a channel.
k2bUnsubscribeFromChannel( "testChannel" ); |