Pau Espin Pedrol | e5c8998 | 2021-05-03 18:16:42 +0200 | [diff] [blame] | 1 | #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 | |
| 9 | struct gsn_t; |
| 10 | |
| 11 | struct mme_rim_route { |
| 12 | struct llist_head list; /* item in struct sgsn_mme_ctx */ |
| 13 | struct osmo_eutran_tai tai; |
| 14 | }; |
| 15 | |
| 16 | struct 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 | }; |
| 26 | struct sgsn_mme_ctx *sgsn_mme_ctx_alloc(struct sgsn_instance *sgsn, const char *name); |
| 27 | struct sgsn_mme_ctx *sgsn_mme_ctx_find_alloc(struct sgsn_instance *sgsn, const char *name); |
| 28 | void sgsn_mme_ctx_free(struct sgsn_mme_ctx *mme); |
| 29 | |
| 30 | struct sgsn_mme_ctx *sgsn_mme_ctx_by_name(const struct sgsn_instance *sgsn, const char *name); |
| 31 | struct sgsn_mme_ctx *sgsn_mme_ctx_by_addr(const struct sgsn_instance *sgsn, const struct in_addr *addr); |
| 32 | struct sgsn_mme_ctx *sgsn_mme_ctx_by_route(const struct sgsn_instance *sgsn, const struct osmo_eutran_tai *tai); |
| 33 | struct sgsn_mme_ctx *sgsn_mme_ctx_by_default_route(const struct sgsn_instance *sgsn); |
| 34 | |
| 35 | void sgsn_mme_ctx_route_add(struct sgsn_mme_ctx *mme, const struct osmo_eutran_tai *tai); |
| 36 | void 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) |