2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-04-03 05:49:12 -07:00
|
|
|
/******************************************************************************
|
|
|
|
* File: netsource.h
|
|
|
|
*
|
|
|
|
* Description: Network socket source.
|
|
|
|
* Supports reading binary data from a TCP or UDP socket.
|
|
|
|
*
|
|
|
|
* Reference:
|
|
|
|
*****************************************************************************/
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#ifndef SRSRAN_NETSOURCE_H
|
|
|
|
#define SRSRAN_NETSOURCE_H
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
2019-12-16 07:04:22 -08:00
|
|
|
#include <stdbool.h>
|
2014-03-03 11:09:26 -08:00
|
|
|
#include <stdint.h>
|
2019-12-16 07:04:22 -08:00
|
|
|
#include <stdio.h>
|
2014-03-03 11:09:26 -08:00
|
|
|
#include <stdlib.h>
|
2019-12-16 07:04:22 -08:00
|
|
|
#include <sys/socket.h>
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/config.h"
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
typedef enum { SRSRAN_NETSOURCE_UDP, SRSRAN_NETSOURCE_TCP } srsran_netsource_type_t;
|
2015-01-08 18:28:05 -08:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
/* Low-level API */
|
2021-03-19 03:45:56 -07:00
|
|
|
typedef struct SRSRAN_API {
|
2019-12-16 07:04:22 -08:00
|
|
|
int sockfd;
|
|
|
|
int connfd;
|
|
|
|
struct sockaddr_in servaddr;
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran_netsource_type_t type;
|
2019-12-16 07:04:22 -08:00
|
|
|
struct sockaddr_in cliaddr;
|
2021-03-19 03:45:56 -07:00
|
|
|
} srsran_netsource_t;
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API int
|
|
|
|
srsran_netsource_init(srsran_netsource_t* q, const char* address, uint16_t port, srsran_netsource_type_t type);
|
2014-12-26 15:36:32 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API void srsran_netsource_free(srsran_netsource_t* q);
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API int srsran_netsource_set_nonblocking(srsran_netsource_t* q);
|
2014-12-26 15:36:32 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API int srsran_netsource_read(srsran_netsource_t* q, void* buffer, int nof_bytes);
|
2014-12-26 15:36:32 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API int srsran_netsource_write(srsran_netsource_t* q, void* buffer, int nbytes);
|
2019-09-13 06:29:49 -07:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
SRSRAN_API int srsran_netsource_set_timeout(srsran_netsource_t* q, uint32_t microseconds);
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#endif // SRSRAN_NETSOURCE_H
|