Compare commits

..

8 Commits
master ... quic

Author SHA1 Message Date
Marcia Piccione
e66c984146 update host name of quic server 2023-04-25 13:41:09 -04:00
Marcia Piccione
fb24b899f7 update quic endpoints 2023-04-25 12:16:33 -04:00
Marcia Piccione
e04c5a106a push latest to try compiling from xmidt 2023-03-30 15:33:59 -04:00
Marcia Piccione
34cacec824 update cmake file for msquic and nghttp3 (too many issues building lightspeed) 2023-03-28 20:27:48 -04:00
Marcia Piccione
96403b76b6 update build with lightspeed just for reference... there seems to be a lot of out of date openssl stuff 2023-03-28 17:06:35 -04:00
Marcia Piccione
eb481cdd4b Merge branch 'master' into quic 2023-03-28 17:05:50 -04:00
Marcia Piccione
3077125fa9 initial commit 2023-03-24 14:39:06 -04:00
Weston Schmidt
193706c21c Release 1.1.5 2021-06-02 18:46:53 -07:00
13 changed files with 300 additions and 116 deletions

View File

@@ -16,7 +16,6 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- main
- master
jobs:
test:

View File

@@ -10,7 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix Parodus connection stuck on interface up down received together
- Update to use nopoll version 1.0.3
## [1.1.4]
## [v1.1.5]
- Add additional HTTP headers for call to Themis from Convey
- Change default branch name to `main`
## [v1.1.4]
- on connect retry, requery jwt only if it failed before
- put two timestamps in connection health file; start conn and current
- change health file update interval to 240sec
@@ -105,8 +109,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial creation
[Unreleased]: https://github.com/Comcast/parodus/compare/1.1.4...HEAD
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...1.1.4
[Unreleased]: https://github.com/Comcast/parodus/compare/v1.1.5...HEAD
[1.1.5]: https://github.com/Comcast/parodus/compare/v1.1.4...v1.1.5
[1.1.4]: https://github.com/Comcast/parodus/compare/1.1.3...v1.1.4
[1.1.3]: https://github.com/Comcast/parodus/compare/1.1.2...1.1.3
[1.1.2]: https://github.com/Comcast/parodus/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/Comcast/parodus/compare/1.0.4...1.1.1

View File

@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 3.10)
#project(parodus VERSION 1.1.15)
#project(parodus VERSION 1.1.5)
project(parodus)
include(ExternalProject)
@@ -226,6 +226,42 @@ ExternalProject_Add(cjwt
add_library(libcjwt STATIC SHARED IMPORTED)
add_dependencies(libcjwt cjwt)
# libmsh3 external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(msh3
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msh3
GIT_REPOSITORY https://github.com/nibanks/msh3.git
GIT_TAG "v0.6.0"
GIT_SUBMODULES_RECURSE true
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -G "Unix Makefiles" -DBUILD_TESTING=OFF
)
add_library(libmsh3 STATIC SHARED IMPORTED)
add_dependencies(libmsh3 msh3)
# libmsquic external dependency
#-------------------------------------------------------------------------------
# ExternalProject_Add(msquic
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msquic
# GIT_REPOSITORY https://github.com/microsoft/msquic.git
# GIT_TAG "v2.1.8"
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
# )
# add_library(libmsquic STATIC SHARED IMPORTED)
# add_dependencies(libmsquic msquic)
# # libnghttp3 external dependency
# #-------------------------------------------------------------------------------
# ExternalProject_Add(nghttp3
# PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/nghttp3
# GIT_REPOSITORY https://github.com/ngtcp2/nghttp3.git
# GIT_TAG "v0.10.0"
# CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
# )
# add_library(libnghttp3 STATIC SHARED IMPORTED)
# add_dependencies(libnghttp3 nghttp3)
if (FEATURE_DNS_QUERY)
# libucresolv external dependency
#-------------------------------------------------------------------------------

19
Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
# build stage
FROM alpine:3.12
RUN \
apk add --no-cache bsd-compat-headers linux-headers cmake autoconf make musl-dev gcc g++ openssl openssl-dev git cunit cunit-dev automake libtool util-linux-dev && \
mkdir -p build
COPY src src
COPY patches patches
COPY tests tests
COPY CMakeLists.txt .
COPY run.sh .
RUN cd build && \
cmake .. && make
CMD ["build/src/parodus"]

78
run.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
parodus_port=16014d
if [[ -z "${URL}" ]]; then
URL="http://petasos:6400"
fi
if [[ -z "${FIRMWARE}" ]]; then
FIRMWARE="mock-rdkb-firmware"
fi
if [[ -z "${BOOT_TIME}" ]]; then
BOOT_TIME=$(date +%s)
fi
if [[ -z "${HW_MANUFACTURER}" ]]; then
HW_MANUFACTURER="Example Inc."
fi
if [[ -z "${REBOOT_REASON}" ]]; then
REBOOT_REASON="unknown"
fi
if [[ -z "${SERIAL_NUMBER}" ]]; then
SERIAL_NUMBER="mock-rdkb-simulator"
fi
if [[ -z "${PARTNER_ID}" ]]; then
PARTNER_ID="comcast"
fi
if [[ -z "${CMAC}" ]]; then
CMAC="112233445566"
fi
if [[ -z "${TOKEN_SERVER_URL}" ]]; then
TOKEN_SERVER_URL="http://themis:6501/issue"
fi
if [[ -z "${SSL_CERT_PATH}" ]]; then
SSL_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
fi
#In this docker-compose cluster, themis has mtls disabled so
#feel free to ignore the --client-cert-path flag value
#it is required by parodus to fetch a token
if [[ -z "${CLIENT_CERT_PATH}" ]]; then
CLIENT_CERT_PATH="/etc/ssl/certs/ca-certificates.crt"
fi
# MTLS_CLIENT_* is used to authenticate with talaria.
if [[ -z "${MTLS_CLIENT_CERT_PATH}" ]]; then
MTLS_CLIENT_CERT_PATH=""
fi
if [[ -z "${MTLS_CLIENT_KEY_PATH}" ]]; then
MTLS_CLIENT_KEY_PATH=""
fi
build/src/parodus --hw-model=aker-testing \
--ssl-cert-path=$SSL_CERT_PATH \
--client-cert-path=$CLIENT_CERT_PATH \
--mtls-client-cert-path=$MTLS_CLIENT_CERT_PATH \
--mtls-client-key-path=$MTLS_CLIENT_KEY_PATH \
--hw-serial-number=$SERIAL_NUMBER \
--hw-manufacturer=$HW_MANUFACTURER \
--hw-mac=$CMAC \
--hw-last-reboot-reason=$REBOOT_REASON \
--fw-name=$FIRMWARE \
--boot-time=$BOOT_TIME \
--partner-id=$PARTNER_ID \
--parodus-local-url=tcp://127.0.0.1:$parodus_port \
--webpa-ping-timeout=60 \
--token-server-url=$TOKEN_SERVER_URL \
--webpa-backoff-max=2 \
--webpa-interface-used=eth0 \
--webpa-url=$URL \
--force-ipv4

View File

@@ -711,53 +711,6 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
return 0;
}
void free_cfg(ParodusCfg *cfg)
{
if(cfg != NULL)
{
if (cfg->mtls_client_cert_path != NULL )
{
free(cfg->mtls_client_cert_path);
cfg->mtls_client_cert_path = NULL;
}
if(cfg->connection_health_file != NULL)
{
free(cfg->connection_health_file);
cfg->connection_health_file = NULL;
}
if(cfg->token_server_url != NULL)
{
free(cfg->token_server_url );
cfg->token_server_url = NULL;
}
if(cfg->mtls_client_key_path != NULL)
{
free(cfg->mtls_client_key_path);
cfg->mtls_client_key_path = NULL;
}
if(cfg->client_cert_path != NULL)
{
free(cfg->client_cert_path);
cfg->client_cert_path = NULL;
}
if(cfg->crud_config_file != NULL)
{
free(cfg->crud_config_file);
cfg->crud_config_file = NULL;
}
if(cfg->close_reason_file != NULL)
{
free(cfg->close_reason_file);
cfg->close_reason_file = NULL;
}
if(cfg->cloud_disconnect != NULL)
{
free(cfg->cloud_disconnect);
cfg->cloud_disconnect = NULL;
}
}
}
void setDefaultValuesToCfg(ParodusCfg *cfg)
{
if(cfg == NULL)

View File

@@ -135,7 +135,7 @@ void loadParodusCfg(ParodusCfg * config,ParodusCfg *cfg);
* or -1 if error
*/
int parseCommandLine(int argc,char **argv,ParodusCfg * cfg);
void free_cfg(ParodusCfg *cfg);
void setDefaultValuesToCfg(ParodusCfg *cfg);
// Accessor for the global config structure.
ParodusCfg *get_parodus_cfg(void);

View File

@@ -231,9 +231,6 @@ void createSocketConnection(void (* initKeypress)())
nopoll_ctx_unref(ctx);
nopoll_cleanup_library();
curl_global_cleanup();
clear_metadata();
rdk_logger_deinit();
free_server_list(&server_list);
}
void shutdownSocketConnection(char *reason) {

138
src/connection_http3.cpp Normal file
View File

@@ -0,0 +1,138 @@
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
--*/
#include "msh3.hpp"
#include <vector>
#include <cstring>
using namespace std;
char * host = "nginx";
//char * path = "/api/v2/devices"
char * path = "/"
struct Arguments {
const char* Host { host };
MsH3Addr Address {443};
vector<const char*> Paths {path};
bool Unsecure { true };
bool Print { true };
uint32_t Count { 1 };
} Args;
void MSH3_CALL HeaderReceived(struct MsH3Request* , const MSH3_HEADER* Header) {
if (Args.Print) {
fwrite(Header->Name, 1, Header->NameLength, stdout);
printf(":");
fwrite(Header->Value, 1, Header->ValueLength, stdout);
printf("\n");
}
}
bool MSH3_CALL DataReceived(struct MsH3Request* , uint32_t* Length, const uint8_t* Data) {
if (Args.Print) fwrite(Data, 1, *Length, stdout);
return true;
}
void MSH3_CALL Complete(struct MsH3Request* Request, bool Aborted, uint64_t AbortError) {
const uint32_t Index = (uint32_t)(size_t)Request->AppContext;
if (Args.Print) printf("\n");
if (Aborted) printf("Request %u aborted: 0x%llx\n", Index, (long long unsigned)AbortError);
else printf("Request %u complete\n", Index);
}
void ParseArgs(int argc, char **argv) {
if (argc < 2 || !strcmp(argv[1], "-?") || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
printf("usage: %s <server[:port]> [options...]\n"
" -c, --count <num> The number of times to query each path (def=1)\n"
" -h, --help Prints this help text\n"
" -p, --path <path(s)> The paths to query\n"
" -u, --unsecure Allows unsecure connections\n"
" -v, --verbose Enables verbose output\n"
" -V, --version Prints out the version\n",
argv[0]);
exit(-1);
}
// Parse the server[:port] argument.
Args.Host = argv[1];
char *port = strrchr(argv[1], ':');
if (port) {
*port = 0; port++;
Args.Address.SetPort((uint16_t)atoi(port));
}
// Parse options.
for (int i = 2; i < argc; ++i) {
if (!strcmp(argv[i], "--count") || !strcmp(argv[i], "-c")) {
if (++i >= argc) { printf("Missing count value\n"); exit(-1); }
Args.Count = (uint32_t)atoi(argv[i]);
} else if (!strcmp(argv[i], "--path") || !strcmp(argv[i], "-p")) {
if (++i >= argc) { printf("Missing path value(s)\n"); exit(-1); }
char* Path = (char*)argv[i];
do {
char* End = strchr(Path, ',');
if (End) *End = 0;
Args.Paths.push_back(Path);
if (!End) break;
Path = End + 1;
} while (true);
} else if (!strcmp(argv[i], "--unsecure") || !strcmp(argv[i], "-u")) {
Args.Unsecure = true;
} else if (!strcmp(argv[i], "--verbose") || !strcmp(argv[i], "-v")) {
Args.Print = true;
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) {
uint32_t Version[4]; MsH3Version(Version);
printf("Using msh3 v%u.%u.%u.%u\n", Version[0], Version[1], Version[2], Version[3]);
}
}
if (Args.Paths.empty()) {
Args.Paths.push_back("/");
}
}
int MSH3_CALL init(int argc, char **argv) {
ParseArgs(argc, argv);
MSH3_HEADER Headers[] = {
{ ":method", 7, "GET", 3 },
{ ":path", 5, Args.Paths[0], strlen(Args.Paths[0]) },
{ ":scheme", 7, "https", 5 },
{ ":authority", 10, Args.Host, strlen(Args.Host) },
{ "user-agent", 10, "curl/7.82.0-DEV", 15 },
{ "accept", 6, "*/*", 3 },
};
const size_t HeadersCount = sizeof(Headers)/sizeof(MSH3_HEADER);
MsH3Api Api;
if (Api.IsValid()) {
MsH3Connection Connection(Api, Args.Host, Args.Address, Args.Unsecure);
if (Connection.IsValid()) {
for (auto Path : Args.Paths) {
printf("HTTP/3 GET https://%s%s\n", Args.Host, Path);
Headers[1].Value = Path;
Headers[1].ValueLength = strlen(Path);
for (uint32_t i = 0; i < Args.Count; ++i) {
auto Request = new (std::nothrow) MsH3Request(Connection, Headers, HeadersCount, MSH3_REQUEST_FLAG_FIN, (void*)(size_t)(i+1), HeaderReceived, DataReceived, Complete, CleanUpAutoDelete);
if (!Request || !Request->IsValid()) {
printf("Request %u failed to start\n", i+1);
break;
}
}
}
Connection.ShutdownComplete.Wait();
}
}
return 0;
}

View File

@@ -111,6 +111,7 @@ int main( int argc, char **argv)
ParodusCfg *cfg;
ParodusInfo ("RAND_MAX is %ld (0x%lx)\n", RAND_MAX, RAND_MAX);
ParodusInfo("TEST PRINT");
srandom (getpid());
/* TODO not ideal, but it fixes a more major problem for now. */
@@ -131,7 +132,7 @@ int main( int argc, char **argv)
curl_global_init(CURL_GLOBAL_DEFAULT);
createSocketConnection( NULL);
free_cfg(cfg);
return 0;
}

View File

@@ -110,11 +110,6 @@ void packMetaData()
ParodusError("Failed to encode metadata\n");
}
}
void clear_metadata(){
if(metadataPack != NULL)
free(metadataPack);
}
/*
* @brief To handle UpStream messages which is received from nanomsg server socket

View File

@@ -59,7 +59,6 @@ int subscribeCurrentActiveInterfaceEvent();
UpStreamMsg * get_global_UpStreamMsgQ(void);
pthread_cond_t *get_global_nano_con(void);
pthread_mutex_t *get_global_nano_mut(void);
void clear_metadata();
#ifdef __cplusplus
}

View File

@@ -31,7 +31,6 @@
#include "config.h"
#include "time.h"
#include "heartBeat.h"
#include "close_retry.h"
static pthread_t processThreadId = 0;
static unsigned int XmidtQsize = 0;
@@ -71,22 +70,6 @@ bool highQosValueCheck(int qos)
return false;
}
//To handle high priority low qos message to confirm send success and ignore cloud ack.
bool higherPriorityLowQosCheck(int qos)
{
if(qos > 20 && qos < 25)
{
ParodusInfo("The low qos msg with higher priority\n");
return true;
}
else
{
ParodusPrint("The qos is not higher priority low qos\n");
}
return false;
}
XmidtMsg * get_global_xmidthead(void)
{
XmidtMsg *tmp = NULL;
@@ -139,9 +122,9 @@ void decrement_XmidtQsize()
int checkCloudConn()
{
int ret = 1;
if (get_close_retry() || !cloud_status_is_online ())
if (!cloud_status_is_online ())
{
ParodusInfo("close_retry is in progress or cloud status is not online, wait till connection up\n");
ParodusInfo("cloud status is not online, wait till connection up\n");
int rv;
struct timespec ts;
@@ -231,15 +214,8 @@ int xmidtQOptmize()
{
if(get_XmidtQsize() > 0 && get_XmidtQsize() == get_parodus_cfg()->max_queue_size)
{
if(higherPriorityLowQosCheck(tempMsg->u.event.qos))
{
ParodusInfo("Skip max queue size delete for qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
}
else
{
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
del = 2;
}
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
del = 2;
}
}
}
@@ -770,9 +746,10 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
while(sendRetStatus) //If SendMessage is failed condition
{
ParodusError("sendXmidtEventToServer is Failed\n");
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
if(highQosValueCheck(qos))
{
ParodusPrint("The event is having high qos retry again, wait till connection is Up\n");
ParodusPrint("The event is having high qos retry again\n");
ParodusInfo("Wait till connection is Up\n");
rv = checkCloudConn();
if(rv == 2)
{
@@ -780,7 +757,7 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
break;
}
ParodusInfo("Received cloud status signal proceed to retry\n");
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
}
else
{
@@ -820,26 +797,13 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
}
else
{
if(higherPriorityLowQosCheck(qos))
{
ParodusInfo("Higher priority low qos send success, ignore cloud ack\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
printSendMsgData(errorMsg, notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
ParodusPrint("update state to DELETE\n");
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
}
else
{
ParodusInfo("Low qos event, send success callback and delete\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
ParodusPrint("statusMsg is %s\n",errorMsg);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
//print_xmidMsg_list();
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
}
ParodusInfo("Low qos event, send success callback and delete\n");
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
ParodusPrint("statusMsg is %s\n",errorMsg);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
//print_xmidMsg_list();
updateXmidtState(msgnode, DELETE);
print_xmidMsg_list();
}
}
@@ -1667,7 +1631,7 @@ void checkMaxQandOptimize(XmidtMsg *xmdMsg)
wrp_msg_t * tempMsg = temp->msg;
qos = tempMsg->u.event.qos;
ParodusPrint("qos is %d\n", qos);
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
if(highQosValueCheck(qos))
{
ParodusPrint("High qos msg, skip delete\n");
}