From d18ae43123fcd7604d1c36a1ec8450dbe6071824 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 23 Feb 2017 20:44:26 +0100 Subject: Initial commit: ccnxlibs. Change-Id: I1b376527a7dd01a6b9e083a6cb646955902f45c0 Signed-off-by: Luca Muscariello --- .../transport_rta/core/rta_Framework_private.h | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 libccnx-transport-rta/ccnx/transport/transport_rta/core/rta_Framework_private.h (limited to 'libccnx-transport-rta/ccnx/transport/transport_rta/core/rta_Framework_private.h') diff --git a/libccnx-transport-rta/ccnx/transport/transport_rta/core/rta_Framework_private.h b/libccnx-transport-rta/ccnx/transport/transport_rta/core/rta_Framework_private.h new file mode 100644 index 00000000..ffc386c5 --- /dev/null +++ b/libccnx-transport-rta/ccnx/transport/transport_rta/core/rta_Framework_private.h @@ -0,0 +1,163 @@ +/* + * 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_Framework_private.h + * @brief <#Brief Description#> + * + * <#Detailed Description#> + * + */ +#ifndef Libccnx_rta_Framework_private_h +#define Libccnx_rta_Framework_private_h + +#include +#include +#include + +#include "rta_ProtocolStack.h" +#include "rta_Connection.h" +#include "rta_Framework_Services.h" + +#include "rta_ConnectionTable.h" + +#include +#include +#include +#include + +// the router's wrapped time frquency is 1 msec +#define WTHZ 1000 +#define FC_MSEC_PER_TICK (1000 / WTHZ) +#define FC_USEC_PER_TICK (1000000 / WTHZ) +#define MSEC_TO_TICKS(msec) ((msec < FC_MSEC_PER_TICK) ? 1 : msec / FC_MSEC_PER_TICK) + +// =================================================== + +typedef struct framework_protocol_holder { + RtaProtocolStack *stack; + uint64_t kv_hash; + int stack_id; + + TAILQ_ENTRY(framework_protocol_holder) list; +} FrameworkProtocolHolder; + + +struct rta_framework { + PARCRingBuffer1x1 *commandRingBuffer; + PARCNotifier *commandNotifier; + PARCEvent *commandEvent; + + //struct event_config *cfg; + int udp_socket; + + PARCEventScheduler *base; + + PARCEventSignal *signal_int; + PARCEventSignal *signal_usr1; + PARCEventTimer *tick_event; + PARCEvent *udp_event; + PARCEventTimer *transmit_statistics_event; + PARCEventSignal *signal_pipe; + + struct timeval starttime; + ticks clock_ticks; // at WTHZ + + // used by seed48 and nrand48 + unsigned short seed[3]; + + pthread_t thread; + + unsigned connid_next; + + // operations that modify global state need + // to be locked. + pthread_mutex_t status_mutex; + pthread_cond_t status_cv; + RtaFrameworkStatus status; + + // signals from outside control thread to event scheduler + // that it should exit its event loop. This does + // not need to be protected in mutex (its not + // a condition variable). We check for this + // inside the HZ timer callback. + bool killme; + + // A list of all our in-use protocol stacks + TAILQ_HEAD(, framework_protocol_holder) protocols_head; + + RtaConnectionTable *connectionTable; + + RtaLogger *logger; +}; + +int rtaFramework_CloseConnection(RtaFramework *framework, RtaConnection *connection); + +/** + * Lock the frameworks state machine status + * + * Will block until the state machine status is locked + * + * @param [in] framework An allocated framework + * + * Example: + * @code + * <#example#> + * @endcode + */ +void rta_Framework_LockStatus(RtaFramework *framework); + +/** + * Unlock the state mahcines status + * + * Will assert if we do not currently hold the lock + * + * @param [in] framework An allocated framework + * + * Example: + * @code + * <#example#> + * @endcode + */ +void rta_Framework_UnlockStatus(RtaFramework *framework); + +/** + * Wait on the state machine's condition variable to be signaled + * + * <#Paragraphs Of Explanation#> + * + * @param [in] framework An allocated framework + * + * Example: + * @code + * <#example#> + * @endcode + */ +void rta_Framework_WaitStatus(RtaFramework *framework); + +/** + * Broadcast on the state machine's condition variable (signal it) + * + * <#Paragraphs Of Explanation#> + * + * @param [in] framework An allocated framework + * + * Example: + * @code + * <#example#> + * @endcode + */ +void rta_Framework_BroadcastStatus(RtaFramework *framework); +#endif -- cgit 1.2.3-korg