Commit d2bf2c2c authored by Christopher Wood's avatar Christopher Wood

Add Manifest message type to the stack CCNxMetaMessage class.

parent 20842598
......@@ -35,6 +35,7 @@
#include <ccnx/transport/common/transport_MetaMessage.h>
#include <ccnx/common/codec/ccnxCodec_TlvPacket.h>
#include <ccnx/common/ccnx_WireFormatMessage.h>
#include <ccnx/common/ccnx_Manifest.h>
CCNxMetaMessage *
ccnxMetaMessage_CreateFromInterest(const CCNxInterest *interest)
......@@ -54,6 +55,13 @@ ccnxMetaMessage_CreateFromControl(const CCNxControl *control)
return ccnxMetaMessage_Acquire((CCNxMetaMessage *) control);
}
CCNxMetaMessage *
ccnxMetaMessage_CreateFromManifest(const CCNxManifest *manifest)
{
return ccnxMetaMessage_Acquire((CCNxMetaMessage *) manifest);
}
CCNxContentObject *
ccnxMetaMessage_GetContentObject(const CCNxMetaMessage *message)
{
......@@ -78,6 +86,12 @@ ccnxMetaMessage_GetControl(const CCNxMetaMessage *message)
return (CCNxControl *) message;
}
CCNxManifest *
ccnxMetaMessage_GetManifest(const CCNxMetaMessage *message)
{
return (CCNxManifest *) message;
}
CCNxMetaMessage *
ccnxMetaMessage_Acquire(const CCNxMetaMessage *message)
{
......@@ -120,6 +134,12 @@ ccnxMetaMessage_IsControl(const CCNxMetaMessage *message)
return ccnxTlvDictionary_IsControl(message);
}
bool
ccnxMetaMessage_IsManifest(const CCNxMetaMessage *message)
{
return ccnxTlvDictionary_IsManifest(message);
}
/**
* Given an iovec encoded version of a TlvDictionary, which is what we get when we call ccnxCodecTlvPacket_DictionaryEncode(),
* linearize it into a PARCBuffer so we can treat it as a PARCBuffer.
......
......@@ -40,6 +40,7 @@
#include <ccnx/common/ccnx_Interest.h>
#include <ccnx/common/ccnx_InterestReturn.h>
#include <ccnx/common/ccnx_ContentObject.h>
#include <ccnx/common/ccnx_Manifest.h>
#include <ccnx/common/ccnx_WireFormatMessage.h>
#include <ccnx/common/internal/ccnx_TlvDictionary.h>
......@@ -110,6 +111,25 @@ CCNxMetaMessage *ccnxMetaMessage_CreateFromContentObject(const CCNxContentObject
*/
CCNxMetaMessage *ccnxMetaMessage_CreateFromControl(const CCNxControl *control);
/**
* Create a `CCNxMetaMessage` instance containing the given {@link CCNxManifest}.
*
* A new reference to the `CCNxManifest` is created.
*
* @param [in] control A pointer to a valid `CCNxManifest` instance.
*
* @return NULL The `CCNxManifest` is not valid, or memory could not be allocated.
* @return non-NULL A pointer to a `CCNxMetaMessage` instance.
*
* Example:
* @code
* {
* CCNxMetaMessage *message = ccnxMetaMessage_CreateFromManifest(manifest);
* }
* @endcode
*/
CCNxMetaMessage *ccnxMetaMessage_CreateFromManifest(const CCNxManifest *manifest);
/**
* Print a human readable representation of the given `CCNxMetaMessage` instance.
*
......@@ -267,6 +287,34 @@ bool ccnxMetaMessage_IsContentObject(const CCNxMetaMessage *message);
*/
bool ccnxMetaMessage_IsControl(const CCNxMetaMessage *message);
/**
* Determine whether a specified `CCNxMetaMessage` instance encapsulates a {@link CCNxManifest}.
*
* Returns true if the underlying message is a `CCNxManifest`.
*
* @param [in] message A pointer to a `CCNxMetaMessage` instance.
*
* @return `true` If the underlying message is a `CCNxManifest`.
* @return `false` If the underlying message is not a `CCNxManifest`.
*
* Example:
* @code
* {
* CCNxMetaMessage *message = ccnxPortal_Receive(portal, CCNxStackTimeout_Never);
*
* if (ccnxMetaMessage_IsManifest(message)) {
* CCNxManifest *control = ccnxMetaMessage_GetManifest(message);
* ...
* ccnxManifest_Release(&manifest);
* }
*
* ccnxMetaMessage_Release(&message);
* }
* @endcode
* @see `CCNxManifest`
*/
bool ccnxMetaMessage_IsManifest(const CCNxMetaMessage *message);
/**
* Release a previously acquired reference to the specified instance,
* decrementing the reference count for the instance.
......@@ -410,6 +458,35 @@ CCNxInterest *ccnxMetaMessage_GetInterestReturn(const CCNxMetaMessage *message);
*/
CCNxControl *ccnxMetaMessage_GetControl(const CCNxMetaMessage *message);
/**
* Return a new {@link CCNxManifest} instance created from the `CCNxMetaMessage`.
*
* The newly created `CCNxManifest` instance must eventually be released by calling {@link ccnxManifest_Release}().
*
* @param [in] message A pointer to a `CCNxMetaMessage` instance.
*
* @return A new `CCNxManifest` instance, which must eventually be released by calling `ccnxManifest_Release()`.
*
* Example:
* @code
* {
* CCNxMetaMessage *message = ccnxPortal_Receive(portal, CCNxStackTimeout_Never);
*
* if (ccnxMetaMessage_IsManifest(message)) {
* CCNxManifest *manifest = ccnxMetaMessage_GetManifest(message);
* ...
* ccnxManifest_Release(&manifest);
* }
*
* ccnxMetaMessage_Release(&message);
* }
* @endcode
*
* @see {@link ccnxManifest_Release}
* @see {@link ccnxMetaMessage_IsManifest}
*/
CCNxManifest *ccnxMetaMessage_GetManifest(const CCNxMetaMessage *message);
/**
* Return a new {@link CCNxMetaMessage} instance created from a wire format message
*
......
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