blob: ceea4051b8f5e29cdb9ce61b498dde937d504fcb [file] [log] [blame]
Pau Espin Pedrole5c89982021-05-03 18:16:42 +02001#pragma once
2
3#include <netinet/in.h>
4
5#include <osmocom/core/linuxlist.h>
6#include <osmocom/core/timer.h>
7#include <osmocom/gprs/protocol/gsm_24_301.h>
8
9struct gsn_t;
10
11struct mme_rim_route {
12 struct llist_head list; /* item in struct sgsn_mme_ctx */
13 struct osmo_eutran_tai tai;
14};
15
16struct sgsn_mme_ctx {
17 struct llist_head list; /* item in sgsn_mme_ctxts */
18 struct llist_head routes; /* list of struct mme_rim_route */
19 struct sgsn_instance *sgsn; /* backpointer */
20 char *name;
21 struct in_addr remote_addr;
22
23 /* is it the default route for outgoing message? are all incoming messages accepted? */
24 bool default_route;
25};
26struct sgsn_mme_ctx *sgsn_mme_ctx_alloc(struct sgsn_instance *sgsn, const char *name);
27struct sgsn_mme_ctx *sgsn_mme_ctx_find_alloc(struct sgsn_instance *sgsn, const char *name);
28void sgsn_mme_ctx_free(struct sgsn_mme_ctx *mme);
29
30struct sgsn_mme_ctx *sgsn_mme_ctx_by_name(const struct sgsn_instance *sgsn, const char *name);
31struct sgsn_mme_ctx *sgsn_mme_ctx_by_addr(const struct sgsn_instance *sgsn, const struct in_addr *addr);
32struct sgsn_mme_ctx *sgsn_mme_ctx_by_route(const struct sgsn_instance *sgsn, const struct osmo_eutran_tai *tai);
33struct sgsn_mme_ctx *sgsn_mme_ctx_by_default_route(const struct sgsn_instance *sgsn);
34
35void sgsn_mme_ctx_route_add(struct sgsn_mme_ctx *mme, const struct osmo_eutran_tai *tai);
36void sgsn_mme_ctx_route_del(struct sgsn_mme_ctx *mme, const struct osmo_eutran_tai *tai);
37
38#define LOGMME(mme, cat, level, fmt, args...) { \
39 char _buf[INET_ADDRSTRLEN]; \
40 LOGP(cat, level, "MME(%s:%s): " fmt, (mme)->name, inet_ntop(AF_INET, &(mme)->remote_addr, _buf, sizeof(_buf)), ## args); \
41 } while (0)