nas_config()/netlink_init_tun(): use entire interface name (prefix)

Instead of implicitly using a hardcoded prefix "oaitun_" interface
name, move that out to the callers of these functions to make it clear.
The ID still remains outside.

The "sister functions" nas_config_mbms()/netlink_init_tun_mbms() will do
the same change in the next commit.
This commit is contained in:
Robert Schmidt
2024-08-02 15:29:36 +02:00
parent 983ee2794d
commit 5acfa47325
9 changed files with 27 additions and 26 deletions
@@ -126,14 +126,15 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ...,
return 1;
}
int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, ...,
int netlink_init_tun(const char *ifprefix, int num_if, int id)
{
int ret;
char ifname[64];
int begx = (id == 0) ? 0 : id - 1;
int endx = (id == 0) ? num_if : id;
for (int i = begx; i < endx; i++) {
sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1);
sprintf(ifname, "%s%d", ifprefix, i + 1);
nas_sock_fd[i] = tun_alloc(ifname);
if (nas_sock_fd[i] == -1) {
+1 -1
View File
@@ -31,7 +31,7 @@
#ifndef EMU_PROTO_H_
#define EMU_PROTO_H_
int netlink_init_tun(char *ifsuffix, int num_if, int id);
int netlink_init_tun(const char *ifprefix, int num_if, int id);
int netlink_init_mbms_tun(char *ifsuffix, int id);
#endif /* EMU_PROTO_H_ */