wrong usage of extern declaration in C files, instead of headers, and fix hidden bugs by this wrong extern declaration duplication

Signed-off-by: Laurent THOMAS <laurent.thomas@open-cells.com>
This commit is contained in:
Laurent THOMAS
2026-05-21 15:53:40 +02:00
committed by Robert Schmidt
parent d8d4480b93
commit 3e6e6f0d27
43 changed files with 140 additions and 127 deletions

View File

@@ -15,25 +15,19 @@ This header file must be included */
#ifndef OPT_H_
#define OPT_H_
#ifndef sys_include
#define sys_include
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#endif
#ifndef project_include
#define project_include
#include "common/utils/LOG/log.h"
#include "PHY/defs_RU.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include "common/utils/LOG/log.h"
#include "PHY/defs_RU.h"
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
@@ -97,6 +91,7 @@ typedef enum radio_type_e {
extern int opt_enabled;
typedef struct {
bool nr;
int type;
int direction;
uint8_t *pdu_buffer;
unsigned int pdu_buffer_size;

View File

@@ -269,7 +269,7 @@ int opt_create_listener_socket(char *ip_address, uint16_t port) {
* 5. run ./oasim -a -P0 -n 30 | grep OPT
*/
/* Add framing header to MAC PDU and send. */
static void SendFrame(guint8 radioType, ws_trace_t *t)
static void SendFrame(ws_trace_t *t)
{
unsigned char frameBuffer[16000];
unsigned int frameOffset;
@@ -281,7 +281,7 @@ static void SendFrame(guint8 radioType, ws_trace_t *t)
frameOffset += strlen(MAC_LTE_START_STRING);
/******************************************************************************/
/* Now write out fixed fields (the mandatory elements of struct mac_lte_info) */
frameBuffer[frameOffset++] = radioType;
frameBuffer[frameOffset++] = t->type;
frameBuffer[frameOffset++] = t->direction;
frameBuffer[frameOffset++] = t->rntiType;
/*************************************/
@@ -393,7 +393,7 @@ static void SendFrame(guint8 radioType, ws_trace_t *t)
}
}
static void SendFrameNR(guint8 radioType, ws_trace_t *t)
static void SendFrameNR(ws_trace_t *t)
{
unsigned char frameBuffer[32000];
unsigned int frameOffset;
@@ -405,7 +405,7 @@ static void SendFrameNR(guint8 radioType, ws_trace_t *t)
frameOffset += strlen(MAC_NR_START_STRING);
/******************************************************************************/
/* Now write out fixed fields (the mandatory elements of struct mac_lte_info) */
frameBuffer[frameOffset++] = radioType;
frameBuffer[frameOffset++] = t->type;
frameBuffer[frameOffset++] = t->direction;
frameBuffer[frameOffset++] = t->rntiType;
/*************************************/
@@ -466,14 +466,12 @@ static void SendFrameNR(guint8 radioType, ws_trace_t *t)
}
#include <common/ran_context.h>
extern RAN_CONTEXT_t RC;
#include <openair1/PHY/phy_extern_ue.h>
#include "openair1/PHY/defs_eNB.h"
/* Remote serveraddress (where Wireshark is running) */
void trace_pdu_implementation(ws_trace_t *t)
{
int radioType = FDD_RADIO;
LOG_D(OPT,
"sending packet to wireshark: direction=%s, size: %d, ueid: %d, rnti: %x, frame/sf: %d.%d\n",
t->direction ? "DL" : "UL",
@@ -483,18 +481,6 @@ void trace_pdu_implementation(ws_trace_t *t)
t->sysFrame,
t->subframe);
if (t->nr) {
radioType = TDD_RADIO;
} else {
if (RC.eNB && RC.eNB[0][0] != NULL)
radioType = RC.eNB[0][0]->frame_parms.frame_type == FDD ? FDD_RADIO : TDD_RADIO;
else if (PHY_vars_UE_g && PHY_vars_UE_g[0][0] != NULL)
radioType = PHY_vars_UE_g[0][0]->frame_parms.frame_type == FDD ? FDD_RADIO : TDD_RADIO;
else {
LOG_E(OPT, "not a 4G eNB neither a 4G UE!!! \n");
}
}
switch (opt_type) {
case OPT_WIRESHARK:
if (g_socksd == -1)
@@ -515,9 +501,9 @@ void trace_pdu_implementation(ws_trace_t *t)
}
if (t->nr)
SendFrameNR(radioType, t);
SendFrameNR(t);
else
SendFrame(radioType, t);
SendFrame(t);
}
/*---------------------------------------------------*/