diff options
author | Michele Papalini <micpapal+fdio@cisco.com> | 2017-02-24 08:00:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2017-02-24 08:00:13 +0000 |
commit | 6d4b6878ceff22f9ec8d8e9423214f9666007472 (patch) | |
tree | fa27e0c747676519cb87ff8448bfed62fce5009d /libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h | |
parent | f28308bd99381ef5f1e178e2e1f870f245e35873 (diff) | |
parent | d18ae43123fcd7604d1c36a1ec8450dbe6071824 (diff) |
Merge "Initial commit: ccnxlibs." into ccnxlibs/master
Diffstat (limited to 'libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h')
-rw-r--r-- | libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h b/libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h new file mode 100644 index 00000000..feecfac9 --- /dev/null +++ b/libccnx-transport-rta/ccnx/transport/transport_rta/commands/rta_CommandDestroyProtocolStack.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file rta_CommandDestroyProtocolStack.h + * @brief Represents a command to destroy a protocol stack + * + * Used to construct an RtaCommand object that is passed to rtaTransport_PassCommand() or _rtaTransport_SendCommandToFramework() + * to send a command from the API's thread of execution to the Transport's thread of execution. + * + */ +#ifndef Libccnx_rta_CommandDestroyProtocolStack_h +#define Libccnx_rta_CommandDestroyProtocolStack_h + +struct rta_command_destroyprotocolstack; +typedef struct rta_command_destroyprotocolstack RtaCommandDestroyProtocolStack; + +/** + * Creates a DestroyProtocolStack command object + * + * Creates a DestroyProtocolStack command object used to signal the RTA framework to + * destroy a protocol stack and all connections in it. + * + * @param [in] stackId The ID used to create the protocol stack. + * + * @return non-null An allocated object + * @return null An error + * + * Example: + * @code + * void foo(RTATransport *transport) + * { + * int stackId = nextStackIdNumber(); + * CCNxStackConfig *config = ccnxStackConfig_Create(); + * + * RtaCommandCreateProtocolStack *createStack = rtaCommandCreateProtocolStack_Create(stackId, config); + * RtaCommand *command = rtaCommand_CreateCreateProtocolStack(createStack); + * _rtaTransport_SendCommandToFramework(transport, command); + * rtaCommand_Release(&command); + * rtaCommandCreateProtocolStack_Release(&createStack); + * + * // ... do work ... + * + * RtaCommandDestroyProtocolStack *destroyStack = rtaCommandDestroyProtocolStack_Create(stackId); + * command = rtaCommand_CreateDestroyProtocolStack(destroyStack); + * _rtaTransport_SendCommandToFramework(transport, command); + * rtaCommand_Release(&command); + * rtaCommandDestroyProtocolStack_Release(&destroyStack); + * ccnxStackConfig_Release(&config); + * } + * @endcode + */ +RtaCommandDestroyProtocolStack *rtaCommandDestroyProtocolStack_Create(int stackId); + +/** + * Increase the number of references to a `RtaCommandDestroyProtocolStack`. + * + * Note that new `RtaCommandDestroyProtocolStack` is not created, + * only that the given `RtaCommandDestroyProtocolStack` reference count is incremented. + * Discard the reference by invoking `rtaCommandDestroyProtocolStack_Release`. + * + * @param [in] destroyStack The RtaCommandDestroyProtocolStack to reference. + * + * @return non-null A reference to `destroyStack`. + * @return null An error + * + * Example: + * @code + * { + * CCNxStackConfig *config = ccnxStackConfig_Create(); + * RtaCommandDestroyProtocolStack *destroyStack = rtaCommandCreateProtocolStack_Create(stackId, config); + * RtaCommandDestroyProtocolStack *second = rtaCommandDestroyProtocolStack_Acquire(destroyStack); + * + * // release order does not matter + * rtaCommandDestroyProtocolStack_Release(&destroyStack); + * rtaCommandDestroyProtocolStack_Release(&second); + * ccnxStackConfig_Release(&config); + * } + * @endcode + */ +RtaCommandDestroyProtocolStack *rtaCommandDestroyProtocolStack_Acquire(const RtaCommandDestroyProtocolStack *destroyStack); + +/** + * Release a previously acquired reference to the specified instance, + * decrementing the reference count for the instance. + * + * The pointer to the instance is set to NULL as a side-effect of this function. + * + * If the invocation causes the last reference to the instance to be released, + * the instance is deallocated and the instance's implementation will perform + * additional cleanup and release other privately held references. + * + * @param [in,out] closePtr A pointer to the object to release, will return NULL'd. + * + * Example: + * @code + * { + * RtaCommandDestroyProtocolStack *destroyStack = rtaCommandDestroyProtocolStack_Create(stackId); + * RtaCommand *command = rtaCommand_CreateDestroyProtocolStack(destroyStack); + * _rtaTransport_SendCommandToFramework(transport, command); + * rtaCommand_Release(&command); + * rtaCommandDestroyProtocolStack(&destroyStack); + * } + * @endcode + */ +void rtaCommandDestroyProtocolStack_Release(RtaCommandDestroyProtocolStack **destroyStackPtr); + +/** + * Returns the Stack ID of the destroy stack command + * + * Returns the Stack ID parameter. + * + * @param [in] destroyStack An allocated RtaCommandDestroyProtocolStack + * + * @return integer The value passed to rtaCommandDestroyProtocolStack_Create(). + * + * Example: + * @code + * { + * int stackId = 7; + * RtaCommandDestroyProtocolStack *destroyStack = rtaCommandDestroyProtocolStack_Create(stackId); + * int testValue = rtaCommandDestroyProtocolStack_GetStackId(destroyStack); + * assertTrue(testValue == stackId, "Wrong value got %d expected %d", testValue, stackId); + * rtaCommandDestroyProtocolStack(&destroyStack); + * } + * @endcode + */ +int rtaCommandDestroyProtocolStack_GetStackId(const RtaCommandDestroyProtocolStack *destroyStack); +#endif // Libccnx_rta_CommandDestroyProtocolStack_h |