Commit 167f3a9b authored by kfox's avatar kfox

Moved fragmentation above ethernet transport

parent 552ac0bc
......@@ -21,7 +21,7 @@ set(ATHENA_SOURCE_FILES
athenactl_About.c
athena_Control.c
athena_InterestControl.c
athena_EthernetFragmenter.c
athena_Fragmenter.c
athena_FIB.c
athena_ContentStore.c
athena_LRUContentStore.c
......@@ -39,7 +39,7 @@ set(ATHENA_HEADER_FILES
athena_ContentStoreInterface.h
athena_Control.h
athena_Ethernet.h
athena_EthernetFragmenter.h
athena_Fragmenter.h
athena_FIB.h
athena_InterestControl.h
athena_LRUContentStore.h
......@@ -60,13 +60,13 @@ set(LIBATHENA_UDP_SOURCE_FILES
)
set(LIBATHENA_ETH_SOURCE_FILES
athena_EthernetFragmenter.c
athena_Fragmenter.c
athena_TransportLinkModuleETH.c
${ATHENA_PLATFORM_MODULES}
)
set(LIBATHENA_ETHFRAGMENT_BEFS_SOURCE_FILES
athena_TransportLinkModuleETHFragmenter_BEFS.c
set(LIBATHENA_FRAGMENT_BEFS_SOURCE_FILES
athena_TransportLinkModuleFragmenter_BEFS.c
)
set(LIBATHENA_TEMPLATE_SOURCE_FILES
......@@ -94,7 +94,7 @@ source_group(Sources FILES ${ATHENA_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_TCP_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_UDP_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_ETH_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_ETHFRAGMENT_BEFS_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_FRAGMENT_BEFS_SOURCE_FILES})
source_group(Sources FILES ${LIBATHENA_TEMPLATE_SOURCE_FILES})
add_library(athena_ETH.shared SHARED ${LIBATHENA_ETH_SOURCE_FILES})
......@@ -104,12 +104,12 @@ set_target_properties(athena_ETH.shared PROPERTIES
VERSION 1.0
OUTPUT_NAME athena_ETH )
add_library(athena_ETHFragmenter_BEFS.shared SHARED ${LIBATHENA_ETHFRAGMENT_BEFS_SOURCE_FILES})
set_target_properties(athena_ETHFragmenter_BEFS.shared PROPERTIES
add_library(athena_Fragmenter_BEFS.shared SHARED ${LIBATHENA_FRAGMENT_BEFS_SOURCE_FILES})
set_target_properties(athena_Fragmenter_BEFS.shared PROPERTIES
C_STANDARD 99
SOVERSION 1
VERSION 1.0
OUTPUT_NAME athena_ETHFragmenter_BEFS )
OUTPUT_NAME athena_Fragmenter_BEFS )
add_library(athena_TEMPLATE.shared SHARED ${LIBATHENA_TEMPLATE_SOURCE_FILES})
set_target_properties(athena_TEMPLATE.shared PROPERTIES
......@@ -123,7 +123,7 @@ set(athena_libraries
athena_TCP.shared
athena_UDP.shared
athena_ETH.shared
athena_ETHFragmenter_BEFS.shared
athena_Fragmenter_BEFS.shared
athena_TEMPLATE.shared
)
......
......@@ -30,9 +30,9 @@
*/
/*
* Provide support for loadable ethernet fragmentation modules. The fragmenter library must be named
* Provide support for loadable fragmentation modules. The fragmenter library must be named
* libathena_ETHFragmenter_<name>, and must contain an initialization routine that is named
* athenaEthernetFrabmenter_<name>_Init. The init routine is provided an AthenaEthernetFragmenter
* athenaFragmenter_<name>_Init. The init routine is provided an AthenaFragmenter
* object instance that is used to maintain private instance state for the fragmentation module.
*/
#include <config.h>
......@@ -41,11 +41,10 @@
#include <dlfcn.h>
#include <errno.h>
#include <net/ethernet.h>
#include <parc/algol/parc_Object.h>
#include <ccnx/forwarder/athena/athena_TransportLinkModule.h>
#include <ccnx/forwarder/athena/athena_EthernetFragmenter.h>
#include <ccnx/forwarder/athena/athena_Fragmenter.h>
#include <ctype.h>
......@@ -59,14 +58,14 @@ _strtoupper(const char *string)
return upperCaseString;
}
#define LIBRARY_MODULE_PREFIX "libathena_ETHFragmenter_"
#define LIBRARY_MODULE_PREFIX "libathena_Fragmenter_"
#ifdef __linux__
#define LIBRARY_MODULE_SUFFIX ".so"
#else // MacOS
#define LIBRARY_MODULE_SUFFIX ".dylib"
#endif
#define METHOD_PREFIX "athenaEthernetFragmenter_"
#define METHOD_PREFIX "athenaFragmenter_"
#define INIT_METHOD_SUFFIX "_Init"
static const char *
......@@ -114,82 +113,89 @@ _nameToLibrary(const char *name)
}
static void
_destroy(AthenaEthernetFragmenter **athenaEthernetFragmenter)
_destroy(AthenaFragmenter **athenaFragmenter)
{
if ((*athenaEthernetFragmenter)->fini) {
(*athenaEthernetFragmenter)->fini(*athenaEthernetFragmenter);
if ((*athenaFragmenter)->fini) {
(*athenaFragmenter)->fini(*athenaFragmenter);
}
if ((*athenaEthernetFragmenter)->module) {
dlclose((*athenaEthernetFragmenter)->module);
if ((*athenaFragmenter)->module) {
dlclose((*athenaFragmenter)->module);
}
parcMemory_Deallocate(&((*athenaEthernetFragmenter)->moduleName));
athenaTransportLink_Release(&((*athenaEthernetFragmenter)->athenaTransportLink));
parcMemory_Deallocate(&((*athenaFragmenter)->moduleName));
athenaTransportLink_Release(&((*athenaFragmenter)->athenaTransportLink));
}
parcObject_ExtendPARCObject(AthenaEthernetFragmenter, _destroy, NULL, NULL, NULL, NULL, NULL, NULL);
parcObject_ExtendPARCObject(AthenaFragmenter, _destroy, NULL, NULL, NULL, NULL, NULL, NULL);
AthenaEthernetFragmenter *
athenaEthernetFragmenter_Create(AthenaTransportLink *athenaTransportLink, const char *fragmenterName)
AthenaFragmenter *
athenaFragmenter_Create(AthenaTransportLink *athenaTransportLink, const char *fragmenterName)
{
AthenaEthernetFragmenter *athenaEthernetFragmenter = parcObject_CreateAndClearInstance(AthenaEthernetFragmenter);
assertNotNull(athenaEthernetFragmenter, "Could not create a new fragmenter instance.");
athenaEthernetFragmenter->moduleName = parcMemory_StringDuplicate(fragmenterName, strlen(fragmenterName));
AthenaFragmenter *athenaFragmenter = parcObject_CreateAndClearInstance(AthenaFragmenter);
assertNotNull(athenaFragmenter, "Could not create a new fragmenter instance.");
athenaFragmenter->moduleName = parcMemory_StringDuplicate(fragmenterName, strlen(fragmenterName));
athenaEthernetFragmenter->athenaTransportLink = athenaTransportLink_Acquire(athenaTransportLink);
athenaFragmenter->athenaTransportLink = athenaTransportLink_Acquire(athenaTransportLink);
const char *moduleLibrary = _nameToLibrary(fragmenterName);
athenaEthernetFragmenter->module = dlopen(moduleLibrary, RTLD_NOW | RTLD_GLOBAL);
athenaFragmenter->module = dlopen(moduleLibrary, RTLD_NOW | RTLD_GLOBAL);
parcMemory_Deallocate(&moduleLibrary);
if (athenaEthernetFragmenter->module == NULL) {
athenaEthernetFragmenter_Release(&athenaEthernetFragmenter);
if (athenaFragmenter->module == NULL) {
athenaFragmenter_Release(&athenaFragmenter);
errno = ENOENT;
return NULL;
}
const char *initEntry = _nameToInitMethod(fragmenterName);
AthenaEthernetFragmenter_Init *_init = dlsym(athenaEthernetFragmenter->module, initEntry);
AthenaFragmenter_Init *_init = dlsym(athenaFragmenter->module, initEntry);
parcMemory_Deallocate(&initEntry);
if (_init == NULL) {
athenaEthernetFragmenter_Release(&athenaEthernetFragmenter);
athenaFragmenter_Release(&athenaFragmenter);
errno = EFAULT;
return NULL;
}
if (_init(athenaEthernetFragmenter) == NULL) {
athenaEthernetFragmenter_Release(&athenaEthernetFragmenter);
if (_init(athenaFragmenter) == NULL) {
athenaFragmenter_Release(&athenaFragmenter);
errno = ENODEV;
return NULL;
}
return athenaEthernetFragmenter;
return athenaFragmenter;
}
parcObject_ImplementAcquire(athenaEthernetFragmenter, AthenaEthernetFragmenter);
parcObject_ImplementAcquire(athenaFragmenter, AthenaFragmenter);
parcObject_ImplementRelease(athenaEthernetFragmenter, AthenaEthernetFragmenter);
parcObject_ImplementRelease(athenaFragmenter, AthenaFragmenter);
int
athenaEthernetFragmenter_Send(AthenaEthernetFragmenter *athenaEthernetFragmenter,
AthenaEthernet *athenaEthernet,
size_t mtu,
struct ether_header *header,
CCNxMetaMessage *ccnxMetaMessage)
PARCBuffer *
athenaFragmenter_ReceiveFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *wireFormatBuffer)
{
if (athenaEthernetFragmenter && athenaEthernetFragmenter->send) {
return athenaEthernetFragmenter->send(athenaEthernetFragmenter, athenaEthernet, mtu, header, ccnxMetaMessage);
} else {
errno = ENOENT;
return -1;
if (athenaFragmenter && athenaFragmenter->receiveFragment) {
return athenaFragmenter->receiveFragment(athenaFragmenter, wireFormatBuffer);
}
return 0;
return wireFormatBuffer;
}
PARCBuffer *
athenaEthernetFragmenter_Receive(AthenaEthernetFragmenter *athenaEthernetFragmenter, PARCBuffer *wireFormatBuffer)
// CCNxCodecEncodingBuffer *encodingBuffer = ccnxCodecEncodingBuffer_Create();
// ccnxCodecEncodingBuffer_AppendBuffer(encodingBuffer, PARCBuffer *bufferToAppend);
// NEW ccnxCodecEncodingBuffer_PrependBuffer(encodingBuffer, PARCBuffer *bufferToPrepend);
// NEW CCNxCodecEncodingBuffer *iov = ccnxCodecEncodingBuffer_Slice(encodingBuffer, offset, length);
// Optional ccnxCodecEncodingBuffer_AppendIOVec(encodingBuffer, struct iovec *vectorToAppend);
// Optional ccnxCodecEncodingBuffer_PrependIOVec(encodingBuffer, struct iovec *vectorToPrepend);
// CCNxCodecEncodingBufferIOVec *iov = ccnxCodecEncodingBuffer_CreateIOVec(encodingBuffer);
// void ccnxCodecEncodingBufferIOVec_Release(CCNxCodecEncodingBufferIOVec **iovecPtr);
// writev(STDOUT_FILENO, iov->iov, iov->iovcnt);
// ccnxCodecEncodingBufferIOVec_Release(&iov);
CCNxCodecEncodingBufferIOVec *
athenaFragmenter_CreateFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *message, size_t mtu, int fragmentNumber)
{
if (athenaEthernetFragmenter && athenaEthernetFragmenter->receive) {
return athenaEthernetFragmenter->receive(athenaEthernetFragmenter, wireFormatBuffer);
if (athenaFragmenter && athenaFragmenter->createFragment) {
return athenaFragmenter->createFragment(athenaFragmenter, message, mtu, fragmentNumber);
} else {
errno = ENOENT;
return NULL;
}
return wireFormatBuffer;
return 0;
}
......@@ -28,55 +28,55 @@
* @author Kevin Fox, Palo Alto Research Center (Xerox PARC)
* @copyright 2016, Xerox Corporation (Xerox)and Palo Alto Research Center (PARC). All rights reserved.
*/
#ifndef libathena_EthernetFragmenter
#define libathena_EthernetFragmenter
#ifndef libathena_Fragmenter
#define libathena_Fragmenter
#include <parc/algol/parc_Deque.h>
#include <ccnx/forwarder/athena/athena_Ethernet.h>
#include <ccnx/common/codec/ccnxCodec_EncodingBuffer.h>
/**
* @typedef AthenaEthernetFragmenter
* @brief Ethernet fragmenter instance private data
* @typedef AthenaFragmenter
* @brief Fragmenter instance private data
*/
typedef struct AthenaEthernetFragmenter AthenaEthernetFragmenter;
typedef struct AthenaFragmenter AthenaFragmenter;
/**
* @typedef AthenaEthernetFragmenter_Send
* @brief Ethernet fragmenter send method
* @typedef AthenaFragmenter_CreateFragment
* @brief Fragmenter create fragment method
*/
typedef int (AthenaEthernetFragmenter_Send)(AthenaEthernetFragmenter *athenaEthernetFragmenter,
AthenaEthernet *athenaEthernet,
size_t mtu, struct ether_header *etherHeader,
CCNxMetaMessage *ccnxMetaMessage);
typedef CCNxCodecEncodingBufferIOVec *(AthenaFragmenter_CreateFragment)(AthenaFragmenter *athenaFragmenter,
PARCBuffer *message,
size_t mtu, int fragmentNumber);
/**
* @typedef AthenaEthernetFragmenter_Receive
* @brief Ethernet fragmenter receive method
* @typedef AthenaFragmenter_ReceiveFragment
* @brief Fragmenter receive method
*/
typedef PARCBuffer *(AthenaEthernetFragmenter_Receive)(AthenaEthernetFragmenter *athenaEthernetFragmenter,
typedef PARCBuffer *(AthenaFragmenter_ReceiveFragment)(AthenaFragmenter *athenaFragmenter,
PARCBuffer *wireFormatBuffer);
/**
* @typedef AthenaEthernetFragmenter_Init
* @brief Ethernet fragmenter initialization method
* @typedef AthenaFragmenter_Init
* @brief Fragmenter initialization method
*/
typedef AthenaEthernetFragmenter *(AthenaEthernetFragmenter_Init)(AthenaEthernetFragmenter *athenaEthernetFragmenter);
typedef AthenaFragmenter *(AthenaFragmenter_Init)(AthenaFragmenter *athenaFragmenter);
/**
* @typedef AthenaEthernetFragmenter_Init
* @brief Ethernet fragmenter initialization method
* @typedef AthenaFragmenter_Init
* @brief Fragmenter initialization method
*/
typedef void (AthenaEthernetFragmenter_Fini)(AthenaEthernetFragmenter *athenaEthernetFragmenter);
typedef void (AthenaFragmenter_Fini)(AthenaFragmenter *athenaFragmenter);
//
// Private data for each fragmented connection
//
struct AthenaEthernetFragmenter {
struct AthenaFragmenter {
AthenaTransportLink *athenaTransportLink; // link associated with fragmenter
const char *moduleName;
void *module; // so library can be unloaded
AthenaEthernetFragmenter_Send *send;
AthenaEthernetFragmenter_Receive *receive;
AthenaEthernetFragmenter_Fini *fini;
AthenaFragmenter_CreateFragment *createFragment;
AthenaFragmenter_ReceiveFragment *receiveFragment;
AthenaFragmenter_Fini *fini;
void *fragmenterData;
};
......@@ -92,73 +92,75 @@ struct AthenaEthernetFragmenter {
* @code
* void
* {
* AthenaEthernetFragmenter *athenaEthernetFragmenter = athenaEthernetFragmenter_Create(athenaTransportLink, "BEFS");
* AthenaFragmenter *athenaFragmenter = athenaFragmenter_Create(athenaTransportLink, "BEFS");
* }
* @endcode
*/
AthenaEthernetFragmenter *athenaEthernetFragmenter_Create(AthenaTransportLink *athenaTransportLink, const char *fragmenterName);
AthenaFragmenter *athenaFragmenter_Create(AthenaTransportLink *athenaTransportLink, const char *fragmenterName);
/**
* @abstract obtain a new reference to a fragmenter instance
* @discussion
*
* @param [in] athenaEthernetFragmenter instance to acquire a reference to
* @param [in] athenaFragmenter instance to acquire a reference to
* @return pointer to new reference
*
* Example:
* @code
* void
* {
* AthenaEthernetFragmenter *newReference = athenaEthernetFragmenter_Acquire(athenaEthernetFragmenter);
* AthenaFragmenter *newReference = athenaFragmenter_Acquire(athenaFragmenter);
* }
* @endcode
*/
AthenaEthernetFragmenter *athenaEthernetFragmenter_Acquire(const AthenaEthernetFragmenter *athenaEthernetFragmenter);
AthenaFragmenter *athenaFragmenter_Acquire(const AthenaFragmenter *athenaFragmenter);
/**
* @abstract release a fragmenter reference
* @discussion
*
* @param [in] athenaEthernetFragmenter instance to release
* @param [in] athenaFragmenter instance to release
*
* Example:
* @code
* void
* {
* athenaEthernetFragmenter_Release(&athenaEthernetFragmenter);
* athenaFragmenter_Release(&athenaFragmenter);
* }
* @endcode
*/
void athenaEthernetFragmenter_Release(AthenaEthernetFragmenter **);
void athenaFragmenter_Release(AthenaFragmenter **);
/**
* @abstract send a message fragmenting it by the provided mtu size
* @discussion
*
* @param [in] athenaEthernetFragmenter
* @param [in] athenaEthernet
* @param [in] mtu
* @param [in] header
* @param [in] athenaFragmenter
* @param [in] ccnxMetaMessage
* @param [in] mtu
* @param [in] fragmentNumber
* @return 0 on success, -1 on failure with errno set to indicate failure
*
* Example:
* @code
* void
* {
* int result = athenaEthernetFragmenter_Send(athenaEthernetFragmenter, athenaEthernet, mtu, header, ccnxMetaMessage);
* // Get the first fragment from a message
* CCNxCodecEncodingBufferIOVec *ioVectorBuffer = athenaFragmenter_CreateFragment(athenaFragmenter, ccnxMetaMessage, 1200, 0);
* const struct iovec *iov = ioVectorBuffer->iov;
* size_t iovcnt = ioVectorBuffer->iovcnt;
* }
* @endcode
*/
int athenaEthernetFragmenter_Send(AthenaEthernetFragmenter *athenaEthernetFragmenter,
AthenaEthernet *athenaEthernet, size_t mtu,
struct ether_header *header, CCNxMetaMessage *ccnxMetaMessage);
CCNxCodecEncodingBufferIOVec *athenaFragmenter_CreateFragment(AthenaFragmenter *athenaFragmenter,
PARCBuffer *message,
size_t mtu, int fragmentNumber);
/**
* @abstract construct a message from received fragments
* @discussion
*
* @param [in] athenaEthernetFragmenter
* @param [in] athenaFragmenter
* @param [in] wireFormatBuffer
* @return pointer to reassembled message,
* NULL if waiting for more fragments,
......@@ -168,11 +170,11 @@ int athenaEthernetFragmenter_Send(AthenaEthernetFragmenter *athenaEthernetFragme
* @code
* void
* {
* PARCBuffer *wireFormatBuffer = athenaEthernetFragmenter_Receive(athenaEthernetFragmenter, inputWireFormatBuffer);
* PARCBuffer *wireFormatBuffer = athenaFragmenter_ReceiveFragment(athenaFragmenter, inputWireFormatBuffer);
* }
* @endcode
*/
PARCBuffer *athenaEthernetFragmenter_Receive(AthenaEthernetFragmenter *athenaEthernetFragmenter,
PARCBuffer *athenaFragmenter_ReceiveFragment(AthenaFragmenter *athenaFragmenter,
PARCBuffer *wireFormatBuffer);
#endif // libathena_EthernetFragmenter
#endif // libathena_Fragmenter
......@@ -28,8 +28,8 @@
* @author Kevin Fox, Palo Alto Research Center (Xerox PARC)
* @copyright 2016, Xerox Corporation (Xerox)and Palo Alto Research Center (PARC). All rights reserved.
*/
#ifndef libathena_EthernetFragmenter_BEFS_h
#define libathena_EthernetFragmenter_BEFS_h
#ifndef libathena_Fragmenter_BEFS_h
#define libathena_Fragmenter_BEFS_h
/*
* Fragmenter module supporting point to point fragmentation that is documented in:
......@@ -91,5 +91,5 @@ typedef struct hopbyhop_header {
*/
#define _hopByHopHeader_GetIFlag(header) ((header)->blob[0] & IMASK)
AthenaEthernetFragmenter *athenaEthernetFragmenter_BEFS_Init(AthenaEthernetFragmenter *athenaEthernetFragmenter);
#endif // libathena_EthernetFragmenter_BEFS_h
AthenaFragmenter *athenaFragmenter_BEFS_Init(AthenaFragmenter *athenaFragmenter);
#endif // libathena_Fragmenter_BEFS_h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment