mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-upf.git
synced 2025-10-23 08:12:03 +00:00
cosmetic: reduce dup in tunnel struct definitions
Use a common struct upf_tun_ep and struct upf_tun for both tunend and tunmap definitions, with a nicer local / remote sub-structuring. Change-Id: I07866e2acbeb74914e1fd6f66839a5a8ae247b1e
This commit is contained in:
@@ -7,5 +7,6 @@ noinst_HEADERS = \
|
||||
upf_gtp.h \
|
||||
upf_gtpu_echo.h \
|
||||
upf_nft.h \
|
||||
upf_tun.h \
|
||||
up_gtp_action.h \
|
||||
$(NULL)
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include <osmocom/core/select.h>
|
||||
#include <osmocom/core/logging.h>
|
||||
|
||||
#include <osmocom/upf/upf_tun.h>
|
||||
|
||||
#define LOG_GTP_DEV(DEV, LEVEL, FMT, ARGS...) \
|
||||
LOGP(DGTP, LEVEL, "%s: " FMT, upf_gtp_dev_to_str_c(OTC_SELECT, (DEV)), ##ARGS)
|
||||
|
||||
@@ -58,12 +60,7 @@ struct upf_gtp_dev {
|
||||
/* Description of a GTP encapsulation / decapsulation.
|
||||
* The active state to operate the GTP kernel module accordingly is kept in struct upf_gtp_tunend. */
|
||||
struct upf_tunend {
|
||||
struct {
|
||||
struct osmo_sockaddr gtp_local_addr;
|
||||
uint32_t local_teid;
|
||||
struct osmo_sockaddr gtp_remote_addr;
|
||||
uint32_t remote_teid;
|
||||
} access;
|
||||
struct upf_tun access;
|
||||
struct {
|
||||
struct osmo_sockaddr ue_local_addr;
|
||||
} core;
|
||||
|
@@ -25,23 +25,16 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <osmocom/core/socket.h>
|
||||
#include <osmocom/upf/upf_tun.h>
|
||||
|
||||
struct upf_nft_tun {
|
||||
struct upf_tun tun;
|
||||
uint32_t chain_id;
|
||||
};
|
||||
|
||||
struct upf_tunmap {
|
||||
struct {
|
||||
struct osmo_sockaddr gtp_local_addr;
|
||||
uint32_t local_teid;
|
||||
struct osmo_sockaddr gtp_remote_addr;
|
||||
uint32_t remote_teid;
|
||||
uint32_t chain_id;
|
||||
} access;
|
||||
struct {
|
||||
struct osmo_sockaddr gtp_local_addr;
|
||||
uint32_t local_teid;
|
||||
struct osmo_sockaddr gtp_remote_addr;
|
||||
uint32_t remote_teid;
|
||||
uint32_t chain_id;
|
||||
} core;
|
||||
struct upf_nft_tun access;
|
||||
struct upf_nft_tun core;
|
||||
};
|
||||
|
||||
int upf_nft_tunmap_to_str_buf(char *buf, size_t buflen, const struct upf_tunmap *tunmap);
|
||||
|
38
include/osmocom/upf/upf_tun.h
Normal file
38
include/osmocom/upf/upf_tun.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Author: Neels Janosch Hofmeyr <nhofmeyr@sysmocom.de>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <osmocom/core/socket.h>
|
||||
|
||||
struct upf_tun_ep {
|
||||
struct osmo_sockaddr addr;
|
||||
uint32_t teid;
|
||||
};
|
||||
|
||||
struct upf_tun {
|
||||
struct upf_tun_ep local;
|
||||
struct upf_tun_ep remote;
|
||||
};
|
Reference in New Issue
Block a user