2 * Copyright 2020 AT&T Intellectual Property
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 // Created by adi ENZEL on 2/16/20.
22 #ifndef E2_SCTPCLIENT_H
23 #define E2_SCTPCLIENT_H
29 #include <sys/socket.h>
30 #include <arpa/inet.h>
31 #include <netinet/in_systm.h>
32 #include <netinet/in.h>
36 #include <sys/epoll.h>
38 #include "oranE2/E2AP-PDU.h"
40 #include "../httpServer/HttpServer.h"
42 #include "../rmrClient/rmrClient.h"
43 #include "cxxopts/include/cxxopts.hpp"
44 #include "../base64.h"
45 #include "../mapWrapper.h"
51 using namespace Pistache;
53 #define SA struct sockaddr
56 #define SCTP_BUFFER_SIZE (64*1024)
58 typedef enum messages {
68 typedef struct SctpClient {
73 int httpBaseSocket {};
77 char delimiter[2] {'|', 0};
81 void createHttpLocalSocket(SctpClient_t &sctpClient);
83 int createEpoll(SctpClient_t &sctpClient);
85 inline static uint64_t rdtscp(uint32_t &aux) {
87 asm volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : :);
88 return (rdx << (unsigned) 32) + rax;
91 int createSctpConnction(SctpClient_t *sctpClient, const char *address, int port, bool local = true);
93 __attribute_warn_unused_result__ int createListeningTcpConnection(SctpClient_t *sctpClient);
95 int modifyEpollToRead(SctpClient_t *sctpClient, int modifiedSocket);
97 cxxopts::ParseResult parse(SctpClient_t &sctpClient, int argc, char *argv[]);
99 #endif //E2_SCTPCLIENT_H