Dedicated TUN interfaces for eMBMS oaitun_enm1 (eNB) <-> oaitun_uem1 (UE)

	ACKNOWLEDGEMENT:
 	1. This commit was developed at Vicomtech (https://www.vicomtech.org) under UE project CDN-X-ALL: "CDN edge-cloud computing for efficient cache and reliable streaming aCROSS Aggregated unicast-multicast LinkS"
 	2. Project funded by Fed4FIRE+ OC5 (https://www.fed4fire.eu)
Signed-off-by: default avatarjavier.morgade@ieee.org <javier.morgade@ieee.org>
parent 65133d4e
...@@ -58,6 +58,8 @@ struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; ...@@ -58,6 +58,8 @@ struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)};
int nas_sock_fd[MAX_MOBILES_PER_ENB]; int nas_sock_fd[MAX_MOBILES_PER_ENB];
int nas_sock_mbms_fd[8];
struct msghdr nas_msg_tx; struct msghdr nas_msg_tx;
struct msghdr nas_msg_rx; struct msghdr nas_msg_rx;
...@@ -92,6 +94,64 @@ static int tun_alloc(char *dev) { ...@@ -92,6 +94,64 @@ static int tun_alloc(char *dev) {
return fd; return fd;
} }
int netlink_init_mbms_tun(char *ifprefix, int num_if) {
int ret;
char ifname[64];
int i= num_if-1;
sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1);
nas_sock_mbms_fd[i] = tun_alloc(ifname);
if (nas_sock_mbms_fd[i] == -1) {
printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno));
exit(1);
}
printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd[i]);
ret = fcntl(nas_sock_mbms_fd[i],F_SETFL,O_NONBLOCK);
if (ret == -1) {
printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno));
if (LINK_ENB_PDCP_TO_IP_DRIVER) {
exit(1);
}
}
memset(&nas_src_addr, 0, sizeof(nas_src_addr));
nas_src_addr.nl_family = AF_NETLINK;
nas_src_addr.nl_pid = 1;//getpid(); /* self pid */
nas_src_addr.nl_groups = 0; /* not in mcast groups */
ret = bind(nas_sock_mbms_fd[i], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr));
memset(&nas_dest_addr, 0, sizeof(nas_dest_addr));
nas_dest_addr.nl_family = AF_NETLINK;
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
nas_dest_addr.nl_groups = 0; /* unicast */
// TX PART
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
/* Fill the netlink message header */
nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD);
nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */
nas_nlh_tx->nlmsg_flags = 0;
nas_iov_tx.iov_base = (void *)nas_nlh_tx;
nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len;
memset(&nas_msg_tx,0,sizeof(nas_msg_tx));
nas_msg_tx.msg_name = (void *)&nas_dest_addr;
nas_msg_tx.msg_namelen = sizeof(nas_dest_addr);
nas_msg_tx.msg_iov = &nas_iov_tx;
nas_msg_tx.msg_iovlen = 1;
// RX PART
memset(&nas_msg_rx,0,sizeof(nas_msg_rx));
nas_msg_rx.msg_name = (void *)&nas_src_addr;
nas_msg_rx.msg_namelen = sizeof(nas_src_addr);
nas_msg_rx.msg_iov = &nas_iov_rx;
nas_msg_rx.msg_iovlen = 1;
return 1;
}
int netlink_init_tun(char *ifprefix, int num_if) { int netlink_init_tun(char *ifprefix, int num_if) {
int ret; int ret;
char ifname[64]; char ifname[64];
......
...@@ -63,5 +63,6 @@ void clear_eNB_transport_info(uint8_t); ...@@ -63,5 +63,6 @@ void clear_eNB_transport_info(uint8_t);
void clear_UE_transport_info(uint8_t); void clear_UE_transport_info(uint8_t);
int netlink_init(void); int netlink_init(void);
int netlink_init_tun(char *ifsuffix, int num_if); int netlink_init_tun(char *ifsuffix, int num_if);
int netlink_init_mbms_tun(char *ifsuffix, int num_if);
#endif /* EMU_PROTO_H_ */ #endif /* EMU_PROTO_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment