Fix #582, ENABLE_PGM_TRANSPORT removed, RRH related removed
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#include "UTIL/LOG/log.h"
|
||||
|
||||
#include "multicast_link.h"
|
||||
#include "pgm_link.h"
|
||||
|
||||
char rx_bufferP[BYPASS_RX_BUFFER_SIZE];
|
||||
unsigned int num_bytesP = 0;
|
||||
@@ -49,10 +48,6 @@ static unsigned int byte_tx_count;
|
||||
unsigned int Master_list_rx;
|
||||
static uint64_t seq_num_tx = 0;
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
extern unsigned int pgm_would_block;
|
||||
#endif
|
||||
|
||||
mapping transport_names[] = {
|
||||
{"WAIT PM TRANSPORT INFO", EMU_TRANSPORT_INFO_WAIT_PM},
|
||||
{"WAIT SM TRANSPORT INFO", EMU_TRANSPORT_INFO_WAIT_SM},
|
||||
@@ -60,9 +55,6 @@ mapping transport_names[] = {
|
||||
{"ENB_TRANSPORT INFO", EMU_TRANSPORT_INFO_ENB},
|
||||
{"UE TRANSPORT INFO", EMU_TRANSPORT_INFO_UE},
|
||||
{"RELEASE TRANSPORT INFO", EMU_TRANSPORT_INFO_RELEASE},
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
{"NACK TRANSPORT INFO", EMU_TRANSPORT_NACK},
|
||||
#endif
|
||||
{NULL, -1}
|
||||
};
|
||||
|
||||
@@ -77,9 +69,6 @@ void init_bypass (void)
|
||||
pthread_mutex_init (&emul_low_mutex, NULL);
|
||||
pthread_cond_init (&emul_low_cond, NULL);
|
||||
emul_low_mutex_var = 1;
|
||||
#endif
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
pgm_oai_init(oai_emulation.info.multicast_ifname);
|
||||
#endif
|
||||
bypass_init (emul_tx_handler, emul_rx_handler);
|
||||
}
|
||||
@@ -318,20 +307,12 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
|
||||
frame, next_slot, is_master);
|
||||
|
||||
#if defined(ENABLE_NEW_MULTICAST)
|
||||
# if defined(ENABLE_PGM_TRANSPORT)
|
||||
num_bytesP = pgm_recv_msg(oai_emulation.info.multicast_group,
|
||||
(uint8_t *)&rx_bufferP[0], sizeof(rx_bufferP),
|
||||
frame, next_slot);
|
||||
|
||||
DevCheck(num_bytesP > 0, num_bytesP, 0, 0);
|
||||
# else
|
||||
|
||||
if (multicast_link_read_data_from_sock(is_master) == 1) {
|
||||
/* We got a timeout */
|
||||
return -1;
|
||||
}
|
||||
|
||||
# endif
|
||||
#else
|
||||
pthread_mutex_lock(&emul_low_mutex);
|
||||
|
||||
@@ -359,10 +340,6 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
|
||||
num_bytesP, map_int_to_str(transport_names, messg->Message_type),
|
||||
messg->master_id,
|
||||
messg->seq_num);
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
|
||||
if (messg->Message_type != EMU_TRANSPORT_NACK)
|
||||
#endif
|
||||
DevCheck4((messg->frame == frame) && (messg->subframe == (next_slot>>1)),
|
||||
messg->frame, frame, messg->subframe, next_slot>>1);
|
||||
|
||||
@@ -405,20 +382,6 @@ int bypass_rx_data(unsigned int frame, unsigned int last_slot,
|
||||
Master_list_rx = oai_emulation.info.master_list;
|
||||
LOG_E(EMU, "RX EMU_TRANSPORT_INFO_RELEASE\n");
|
||||
break;
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
|
||||
case EMU_TRANSPORT_NACK:
|
||||
if (messg->failing_master_id == oai_emulation.info.master_id) {
|
||||
/* We simply re-send the last message */
|
||||
pgm_link_send_msg(oai_emulation.info.multicast_group,
|
||||
(uint8_t *)bypass_tx_buffer, byte_tx_count);
|
||||
} else {
|
||||
/* Sleep awhile till other peers have recovered data */
|
||||
usleep(500);
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
LOG_E(EMU, "[MAC][BYPASS] ERROR RX UNKNOWN MESSAGE\n");
|
||||
@@ -483,13 +446,6 @@ void bypass_signal_mac_phy(unsigned int frame, unsigned int last_slot,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
void bypass_tx_nack(unsigned int frame, unsigned int next_slot)
|
||||
{
|
||||
bypass_tx_data(NACK_TRANSPORT, frame, next_slot);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int next_slot)
|
||||
{
|
||||
@@ -519,26 +475,6 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
|
||||
byte_tx_count = sizeof (bypass_msg_header_t) + sizeof (
|
||||
bypass_proto2multicast_header_t);
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
|
||||
if (Type == NACK_TRANSPORT) {
|
||||
int i;
|
||||
messg->Message_type = EMU_TRANSPORT_NACK;
|
||||
|
||||
for (i = 0; i < oai_emulation.info.nb_master; i++) {
|
||||
/* Skip our id */
|
||||
if (i == oai_emulation.info.master_id)
|
||||
continue;
|
||||
|
||||
if ((Master_list_rx & (1 << i)) == 0) {
|
||||
messg->failing_master_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_T(EMU,"[TX_DATA] NACK TRANSPORT\n");
|
||||
} else
|
||||
#endif
|
||||
if (Type == WAIT_PM_TRANSPORT) {
|
||||
messg->Message_type = EMU_TRANSPORT_INFO_WAIT_PM;
|
||||
LOG_T(EMU,"[TX_DATA] WAIT SYNC PM TRANSPORT\n");
|
||||
@@ -630,13 +566,8 @@ void bypass_tx_data(emu_transport_info_t Type, unsigned int frame, unsigned int
|
||||
((bypass_proto2multicast_header_t *) bypass_tx_buffer)->size = byte_tx_count -
|
||||
sizeof (bypass_proto2multicast_header_t);
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
pgm_link_send_msg(oai_emulation.info.multicast_group,
|
||||
(uint8_t *)bypass_tx_buffer, byte_tx_count);
|
||||
#else
|
||||
multicast_link_write_sock(oai_emulation.info.multicast_group,
|
||||
bypass_tx_buffer, byte_tx_count);
|
||||
#endif
|
||||
|
||||
LOG_D(EMU, "Frame %d, subframe %d (%d): Sent %d bytes [%s] with master_id %d and seq %"PRIuMAX"\n",
|
||||
frame, next_slot>>1, next_slot,byte_tx_count, map_int_to_str(transport_names, Type),
|
||||
|
||||
@@ -41,9 +41,6 @@ typedef enum emu_transport_info_e {
|
||||
EMU_TRANSPORT_INFO_ENB,
|
||||
EMU_TRANSPORT_INFO_UE,
|
||||
EMU_TRANSPORT_INFO_RELEASE
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
,EMU_TRANSPORT_NACK
|
||||
#endif
|
||||
} emu_transport_info_t;
|
||||
|
||||
#define WAIT_PM_TRANSPORT 1
|
||||
@@ -52,9 +49,6 @@ typedef enum emu_transport_info_e {
|
||||
#define ENB_TRANSPORT 4
|
||||
#define UE_TRANSPORT 5
|
||||
#define RELEASE_TRANSPORT 6
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
# define NACK_TRANSPORT 7
|
||||
#endif
|
||||
|
||||
#define WAIT_SYNC_TRANSPORT 1
|
||||
#define SYNCED_TRANSPORT 2
|
||||
|
||||
@@ -40,49 +40,17 @@
|
||||
#include "UTIL/LOG/log.h"
|
||||
#include "UTIL/LOG/vcd_signal_dumper.h"
|
||||
|
||||
#include "pgm_link.h"
|
||||
|
||||
extern unsigned int Master_list_rx;
|
||||
|
||||
extern unsigned char NB_INST;
|
||||
//#define DEBUG_CONTROL 1
|
||||
//#define DEBUG_EMU 1
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
extern unsigned int pgm_would_block;
|
||||
#endif
|
||||
|
||||
void emu_transport_sync(void)
|
||||
{
|
||||
LOG_D(EMU, "Entering EMU transport SYNC is primary master %d\n",
|
||||
oai_emulation.info.is_primary_master);
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
|
||||
if (oai_emulation.info.is_primary_master == 0) {
|
||||
bypass_tx_data(WAIT_SM_TRANSPORT,0,0);
|
||||
// just wait to recieve the master 0 msg
|
||||
Master_list_rx = oai_emulation.info.master_list - 1;
|
||||
bypass_rx_data(0,0,0,1);
|
||||
} else {
|
||||
bypass_rx_data(0,0,0,0);
|
||||
bypass_tx_data(WAIT_PM_TRANSPORT,0,0);
|
||||
}
|
||||
|
||||
if (oai_emulation.info.master_list != 0) {
|
||||
bypass_tx_data(SYNC_TRANSPORT,0,0);
|
||||
bypass_rx_data(0,0,0,0);
|
||||
|
||||
// i received the sync from all secondary masters
|
||||
if (emu_rx_status == SYNCED_TRANSPORT) {
|
||||
emu_tx_status = SYNCED_TRANSPORT;
|
||||
}
|
||||
|
||||
LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (oai_emulation.info.is_primary_master == 0) {
|
||||
retry:
|
||||
bypass_tx_data(WAIT_SM_TRANSPORT,0,0);
|
||||
@@ -115,8 +83,6 @@ retry2:
|
||||
LOG_D(EMU,"TX secondary master SYNC_TRANSPORT state \n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
LOG_D(EMU, "Leaving EMU transport SYNC is primary master %d\n",
|
||||
oai_emulation.info.is_primary_master);
|
||||
}
|
||||
@@ -154,9 +120,6 @@ void emu_transport(unsigned int frame, unsigned int last_slot,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
pgm_would_block = 0;
|
||||
#endif
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(
|
||||
VCD_SIGNAL_DUMPER_FUNCTIONS_EMU_TRANSPORT, VCD_FUNCTION_OUT);
|
||||
}
|
||||
|
||||
@@ -314,9 +314,7 @@ void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
|
||||
LOG_I(EMU, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
|
||||
(multicast_if == NULL) ? "not specified" : multicast_if, multicast_group,
|
||||
rx_handler);
|
||||
#if !defined(ENABLE_PGM_TRANSPORT)
|
||||
multicast_link_init ();
|
||||
#endif
|
||||
#if ! defined(ENABLE_NEW_MULTICAST)
|
||||
LOG_D(EMU, "[MULTICAST] multicast link start thread\n");
|
||||
|
||||
|
||||
@@ -1,417 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
|
||||
*
|
||||
* 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.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file pgm_link.c
|
||||
* \brief implementation a warpper for openpgm for reliable multicast transmission
|
||||
* \author Navid Nikaein and S. Roux
|
||||
* \date 2013 - 2014
|
||||
* \version 1.0
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
|
||||
#include <pgm/pgm.h>
|
||||
|
||||
#include "assertions.h"
|
||||
|
||||
#include "pgm_link.h"
|
||||
#include "multicast_link.h"
|
||||
|
||||
#include "UTIL/OCG/OCG.h"
|
||||
#include "UTIL/OCG/OCG_extern.h"
|
||||
|
||||
#include "UTIL/LOG/log.h"
|
||||
|
||||
// #define ENABLE_PGM_DEBUG
|
||||
|
||||
typedef struct {
|
||||
pgm_sock_t *sock;
|
||||
uint16_t port;
|
||||
uint8_t rx_buffer[40000];
|
||||
} pgm_multicast_group_t;
|
||||
|
||||
pgm_multicast_group_t pgm_multicast_group[MULTICAST_LINK_NUM_GROUPS];
|
||||
|
||||
static
|
||||
int pgm_create_socket(int index, const char *if_addr);
|
||||
|
||||
unsigned int pgm_would_block = 1;
|
||||
|
||||
#if defined(ENABLE_PGM_DEBUG)
|
||||
static void
|
||||
log_handler (
|
||||
const int log_level,
|
||||
const char* message,
|
||||
void* closure
|
||||
)
|
||||
{
|
||||
printf("%s\n", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
int pgm_oai_init(char *if_addr)
|
||||
{
|
||||
pgm_error_t* pgm_err = NULL;
|
||||
|
||||
memset(pgm_multicast_group, 0,
|
||||
MULTICAST_LINK_NUM_GROUPS * sizeof(pgm_multicast_group_t));
|
||||
|
||||
#if defined(ENABLE_PGM_DEBUG)
|
||||
pgm_messages_init();
|
||||
pgm_min_log_level = PGM_LOG_LEVEL_DEBUG;
|
||||
pgm_log_mask = 0xFFF;
|
||||
|
||||
pgm_log_set_handler(log_handler, NULL);
|
||||
#endif
|
||||
|
||||
if (!pgm_init(&pgm_err)) {
|
||||
LOG_E(EMU, "Unable to start PGM engine: %s\n", pgm_err->message);
|
||||
pgm_error_free (pgm_err);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return pgm_create_socket(oai_emulation.info.multicast_group, if_addr);
|
||||
}
|
||||
|
||||
int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length,
|
||||
unsigned int frame, unsigned int next_slot)
|
||||
{
|
||||
size_t num_bytes = 0;
|
||||
int status = 0;
|
||||
pgm_error_t* pgm_err = NULL;
|
||||
struct pgm_sockaddr_t from;
|
||||
socklen_t fromlen = sizeof(from);
|
||||
uint32_t timeout = 0;
|
||||
int flags = 0;
|
||||
|
||||
if (pgm_would_block == 0) {
|
||||
flags = MSG_DONTWAIT;
|
||||
}
|
||||
|
||||
DevCheck((group <= MULTICAST_LINK_NUM_GROUPS) && (group >= 0),
|
||||
group, MULTICAST_LINK_NUM_GROUPS, 0);
|
||||
|
||||
#ifdef DEBUG_EMU
|
||||
LOG_I(EMU, "[PGM] Entering recv function for group %d\n", group);
|
||||
#endif
|
||||
|
||||
do {
|
||||
status = pgm_recvfrom(pgm_multicast_group[group].sock,
|
||||
buffer,
|
||||
length,
|
||||
flags,
|
||||
&num_bytes,
|
||||
&from,
|
||||
&fromlen,
|
||||
&pgm_err);
|
||||
|
||||
if (PGM_IO_STATUS_NORMAL == status) {
|
||||
#ifdef DEBUG_EMU
|
||||
LOG_D(EMU, "[PGM] Received %d bytes for group %d\n", num_bytes, group);
|
||||
#endif
|
||||
return num_bytes;
|
||||
} else if (PGM_IO_STATUS_TIMER_PENDING == status) {
|
||||
if (pgm_would_block == 0) {
|
||||
/* We sleep for 50 usec */
|
||||
usleep(50);
|
||||
|
||||
timeout ++;
|
||||
|
||||
if (timeout == (1000000 / 50)) {
|
||||
LOG_W(EMU, "[PGM] A packet has been lost -> ask for retransmit\n");
|
||||
/* If we do not receive a packet after 10000usec
|
||||
* -> send a NACK */
|
||||
bypass_tx_nack(frame, next_slot);
|
||||
timeout = 0;
|
||||
}
|
||||
}
|
||||
} else if (PGM_IO_STATUS_RESET == status) {
|
||||
LOG_W(EMU, "[PGM] Got session reset\n");
|
||||
} else {
|
||||
#ifdef DEBUG_EMU
|
||||
LOG_D(EMU, "[PGM] Got status %d\n", status);
|
||||
#endif
|
||||
|
||||
if (pgm_err) {
|
||||
LOG_E(EMU, "[PGM] recvform failed: %s", pgm_err->message);
|
||||
pgm_error_free (pgm_err);
|
||||
pgm_err = NULL;
|
||||
}
|
||||
}
|
||||
} while(status != PGM_IO_STATUS_NORMAL);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pgm_link_send_msg(int group, uint8_t *data, uint32_t len)
|
||||
{
|
||||
int status;
|
||||
size_t bytes_written = 0;
|
||||
|
||||
do {
|
||||
status = pgm_send(pgm_multicast_group[group].sock, data, len, &bytes_written);
|
||||
} while(status == PGM_IO_STATUS_WOULD_BLOCK);
|
||||
|
||||
if (status != PGM_IO_STATUS_NORMAL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
static
|
||||
int pgm_create_socket(int index, const char *if_addr)
|
||||
{
|
||||
struct pgm_addrinfo_t* res = NULL;
|
||||
pgm_error_t* pgm_err = NULL;
|
||||
sa_family_t sa_family = AF_INET;
|
||||
int udp_encap_port = 46014 + index;
|
||||
int max_tpdu = 1500;
|
||||
int sqns = 100;
|
||||
int port = 0;
|
||||
struct pgm_sockaddr_t addr;
|
||||
int blocking = 1;
|
||||
int multicast_loop = 0;
|
||||
int multicast_hops = 0;
|
||||
int dscp, i;
|
||||
|
||||
port = udp_encap_port;
|
||||
|
||||
/* Use PGM */
|
||||
udp_encap_port = 0;
|
||||
|
||||
LOG_D(EMU, "[PGM] Preparing socket for group %d and address %s\n",
|
||||
index, if_addr);
|
||||
|
||||
if (!pgm_getaddrinfo(if_addr, NULL, &res, &pgm_err)) {
|
||||
LOG_E(EMU, "Parsing network parameter: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
|
||||
if (udp_encap_port) {
|
||||
LOG_I(EMU, "[PGM] Creating PGM/UDP socket for encapsulated port %d\n",
|
||||
udp_encap_port);
|
||||
|
||||
if (!pgm_socket (&pgm_multicast_group[index].sock, sa_family,
|
||||
SOCK_SEQPACKET, IPPROTO_UDP, &pgm_err)) {
|
||||
LOG_E(EMU, "[PGM] Socket: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_UDP_ENCAP_UCAST_PORT, &udp_encap_port,
|
||||
sizeof(udp_encap_port));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_UDP_ENCAP_MCAST_PORT, &udp_encap_port,
|
||||
sizeof(udp_encap_port));
|
||||
} else {
|
||||
LOG_I(EMU, "[PGM] Creating PGM/IP socket\n");
|
||||
|
||||
if (!pgm_socket(&pgm_multicast_group[index].sock, sa_family,
|
||||
SOCK_SEQPACKET, IPPROTO_PGM, &pgm_err)) {
|
||||
LOG_E(EMU, "Creating PGM/IP socket: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Use RFC 2113 tagging for PGM Router Assist */
|
||||
const int no_router_assist = 0;
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_IP_ROUTER_ALERT, &no_router_assist,
|
||||
sizeof(no_router_assist));
|
||||
}
|
||||
|
||||
// pgm_drop_superuser();
|
||||
|
||||
{
|
||||
/* set PGM parameters */
|
||||
const int recv_only = 0,
|
||||
passive = 0,
|
||||
peer_expiry = pgm_secs (300),
|
||||
spmr_expiry = pgm_msecs (250),
|
||||
nak_bo_ivl = pgm_msecs (10),
|
||||
nak_rpt_ivl = pgm_secs (2),
|
||||
nak_rdata_ivl = pgm_secs (2),
|
||||
nak_data_retries = 50,
|
||||
nak_ncf_retries = 50,
|
||||
ambient_spm = pgm_secs(30);
|
||||
const int heartbeat_spm[] = {
|
||||
pgm_msecs (100),
|
||||
pgm_msecs (100),
|
||||
pgm_msecs (100),
|
||||
pgm_msecs (100),
|
||||
pgm_msecs (1300),
|
||||
pgm_secs (7),
|
||||
pgm_secs (16),
|
||||
pgm_secs (25),
|
||||
pgm_secs (30)
|
||||
};
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_RECV_ONLY, &recv_only, sizeof(recv_only));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_PASSIVE, &passive, sizeof(passive));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_MTU, &max_tpdu, sizeof(max_tpdu));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_RXW_SQNS, &sqns, sizeof(sqns));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_PEER_EXPIRY, &peer_expiry, sizeof(peer_expiry));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_SPMR_EXPIRY, &spmr_expiry, sizeof(spmr_expiry));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_NAK_BO_IVL, &nak_bo_ivl, sizeof(nak_bo_ivl));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_NAK_RPT_IVL, &nak_rpt_ivl, sizeof(nak_rpt_ivl));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_NAK_RDATA_IVL, &nak_rdata_ivl, sizeof(nak_rdata_ivl));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_NAK_DATA_RETRIES, &nak_data_retries, sizeof(nak_data_retries));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_NAK_NCF_RETRIES, &nak_ncf_retries, sizeof(nak_ncf_retries));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_AMBIENT_SPM, &ambient_spm, sizeof(ambient_spm));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_HEARTBEAT_SPM, &heartbeat_spm, sizeof(heartbeat_spm));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_TXW_SQNS, &sqns, sizeof(sqns));
|
||||
}
|
||||
|
||||
/* create global session identifier */
|
||||
memset (&addr, 0, sizeof(addr));
|
||||
/* sa_port should be in host byte order */
|
||||
addr.sa_port = port;
|
||||
addr.sa_addr.sport = DEFAULT_DATA_SOURCE_PORT + index;
|
||||
|
||||
if (!pgm_gsi_create_from_hostname(&addr.sa_addr.gsi, &pgm_err)) {
|
||||
LOG_E(EMU, "[PGM] Creating GSI: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
|
||||
LOG_D(EMU, "[PGM] Created GSI %s\n", pgm_tsi_print(&addr.sa_addr));
|
||||
|
||||
/* assign socket to specified address */
|
||||
{
|
||||
struct pgm_interface_req_t if_req;
|
||||
memset (&if_req, 0, sizeof(if_req));
|
||||
if_req.ir_interface = res->ai_recv_addrs[0].gsr_interface;
|
||||
if_req.ir_scope_id = 0;
|
||||
|
||||
if (AF_INET6 == sa_family) {
|
||||
struct sockaddr_in6 sa6;
|
||||
memcpy (&sa6, &res->ai_recv_addrs[0].gsr_group, sizeof(sa6));
|
||||
if_req.ir_scope_id = sa6.sin6_scope_id;
|
||||
}
|
||||
|
||||
if (!pgm_bind3(pgm_multicast_group[index].sock, &addr, sizeof(addr),
|
||||
&if_req, sizeof(if_req), /* tx interface */
|
||||
&if_req, sizeof(if_req), /* rx interface */
|
||||
&pgm_err)) {
|
||||
LOG_E(EMU, "[PGM] Error: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
}
|
||||
|
||||
/* join IP multicast groups */
|
||||
{
|
||||
struct group_req req;
|
||||
struct sockaddr_in addr_in;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
/* Interface index */
|
||||
req.gr_interface = res->ai_recv_addrs[0].gsr_interface;
|
||||
|
||||
addr_in.sin_family = AF_INET;
|
||||
addr_in.sin_port = htons(port);
|
||||
|
||||
for (i = 0; i < MULTICAST_LINK_NUM_GROUPS; i++) {
|
||||
addr_in.sin_addr.s_addr = inet_addr(multicast_group_list[i]);
|
||||
memcpy(&req.gr_group, &addr_in, sizeof(addr_in));
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_JOIN_GROUP, &req,
|
||||
sizeof(struct group_req));
|
||||
}
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_SEND_GROUP, &req,
|
||||
sizeof(struct group_req));
|
||||
}
|
||||
|
||||
pgm_freeaddrinfo(res);
|
||||
res = NULL;
|
||||
|
||||
/* set IP parameters */
|
||||
multicast_hops = 64;
|
||||
dscp = 0x2e << 2; /* Expedited Forwarding PHB for network elements, no ECN. */
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_MULTICAST_LOOP, &multicast_loop, sizeof(multicast_loop));
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM,
|
||||
PGM_MULTICAST_HOPS, &multicast_hops, sizeof(multicast_hops));
|
||||
|
||||
if (AF_INET6 != sa_family)
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_TOS,
|
||||
&dscp, sizeof(dscp));
|
||||
|
||||
pgm_setsockopt(pgm_multicast_group[index].sock, IPPROTO_PGM, PGM_NOBLOCK,
|
||||
&blocking, sizeof(blocking));
|
||||
|
||||
if (!pgm_connect(pgm_multicast_group[index].sock, &pgm_err)) {
|
||||
LOG_E(EMU, "[PGM] Connecting socket: %s\n", pgm_err->message);
|
||||
goto err_abort;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_abort:
|
||||
|
||||
if (NULL != pgm_multicast_group[index].sock) {
|
||||
pgm_close(pgm_multicast_group[index].sock, FALSE);
|
||||
pgm_multicast_group[index].sock = NULL;
|
||||
}
|
||||
|
||||
if (NULL != res) {
|
||||
pgm_freeaddrinfo(res);
|
||||
res = NULL;
|
||||
}
|
||||
|
||||
if (NULL != pgm_err) {
|
||||
pgm_error_free(pgm_err);
|
||||
pgm_err = NULL;
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
|
||||
*
|
||||
* 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.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#ifndef PGM_LINK_H_
|
||||
#define PGM_LINK_H_
|
||||
|
||||
/* Define prototypes only if enabled */
|
||||
#if defined(ENABLE_PGM_TRANSPORT)
|
||||
void bypass_tx_nack(unsigned int frame, unsigned int next_slot);
|
||||
|
||||
int pgm_oai_init(char *if_name);
|
||||
|
||||
int pgm_recv_msg(int group, uint8_t *buffer, uint32_t length,
|
||||
unsigned int frame, unsigned int next_slot);
|
||||
|
||||
int pgm_link_send_msg(int group, uint8_t *data, uint32_t len);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* PGM_LINK_H_ */
|
||||
Reference in New Issue
Block a user