diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2022-06-17 17:34:53 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2022-06-17 18:15:43 +0200 |
commit | 6b458fa06072dddd26ec71ceed9b07d6061268e5 (patch) | |
tree | 53a11ccc18e0171a6969c7ce3627b6aa946f6208 /include/osmocom/pfcp | |
parent | 3b8fc0d69421654f75347d4627728aeb95f03a99 (diff) |
add generic PFCP CP peer implementation0.1.0
Will be used by osmo-hnbgw, our first PFCP Control Plane entity. The
implementation is generic enough that it can be re-used by other CP
entities.
Related: SYS#5895
Change-Id: If8c5f69f596ea6ba8bd1723f4dc57b91d3799795
Diffstat (limited to 'include/osmocom/pfcp')
-rw-r--r-- | include/osmocom/pfcp/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/pfcp/pfcp_cp_peer.h | 63 |
2 files changed, 64 insertions, 0 deletions
diff --git a/include/osmocom/pfcp/Makefile.am b/include/osmocom/pfcp/Makefile.am index 5d2db19..898113f 100644 --- a/include/osmocom/pfcp/Makefile.am +++ b/include/osmocom/pfcp/Makefile.am @@ -5,6 +5,7 @@ pfcp_HEADERS = \ pfcp_msg.h \ pfcp_proto.h \ pfcp_strs.h \ + pfcp_cp_peer.h \ $(NULL) pfcpdir = $(includedir)/osmocom/pfcp diff --git a/include/osmocom/pfcp/pfcp_cp_peer.h b/include/osmocom/pfcp/pfcp_cp_peer.h new file mode 100644 index 0000000..8c6e448 --- /dev/null +++ b/include/osmocom/pfcp/pfcp_cp_peer.h @@ -0,0 +1,63 @@ +/* + * (C) 2021-2022 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 <stdbool.h> + +#include <osmocom/core/socket.h> +#include <osmocom/core/use_count.h> +#include <osmocom/pfcp/pfcp_proto.h> + +struct osmo_fsm_inst; +struct osmo_pfcp_endpoint; +struct osmo_pfcp_cp_peer; + +typedef void (*osmo_pfcp_cp_peer_assoc_cb)(struct osmo_pfcp_cp_peer *cp_peer, bool associated); + +struct osmo_pfcp_cp_peer { + struct osmo_fsm_inst *fi; + struct osmo_pfcp_endpoint *ep; + struct osmo_sockaddr remote_addr; + uint64_t next_seid_state; + + /* If non-NULL, called whenever the peer completes a PFCP Association, and when it loses association. + * Argument associated == true means the peer has just associated; + * associated == false means the association has been lost. */ + osmo_pfcp_cp_peer_assoc_cb assoc_cb; + /* Application private data for assoc_cb, in case ep->priv does not suffice. */ + void *priv; + + struct osmo_use_count use_count; + struct osmo_use_count_entry use_count_buf[128]; +}; + +struct osmo_pfcp_cp_peer *osmo_pfcp_cp_peer_alloc(void *ctx, + struct osmo_pfcp_endpoint *ep, + const struct osmo_sockaddr *remote_addr); +int osmo_pfcp_cp_peer_associate(struct osmo_pfcp_cp_peer *cp_peer); +bool osmo_pfcp_cp_peer_is_associated(const struct osmo_pfcp_cp_peer *cp_peer); +struct osmo_pfcp_msg *osmo_pfcp_cp_peer_new_msg_tx(struct osmo_pfcp_cp_peer *cp_peer, + enum osmo_pfcp_message_type msg_type); +void osmo_pfcp_cp_peer_set_msg_ctx(struct osmo_pfcp_cp_peer *cp_peer, struct osmo_pfcp_msg *m); |