Pau Espin Pedrol | f5fbb41 | 2019-08-21 18:49:44 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <stdbool.h> |
| 5 | #include <netinet/in.h> |
| 6 | #include <arpa/inet.h> |
| 7 | |
| 8 | #include <osmocom/core/linuxlist.h> |
| 9 | #include <osmocom/core/timer.h> |
| 10 | |
| 11 | #include "../gtp/pdp.h" |
| 12 | |
| 13 | struct ggsn_ctx; |
| 14 | struct pdp_priv_t; |
| 15 | |
| 16 | struct sgsn_peer { |
| 17 | struct llist_head entry; /* to be included into ggsn_ctx */ |
| 18 | struct ggsn_ctx *ggsn; /* backpointer to ggsn_ctx */ |
| 19 | struct in_addr addr; /* Addr of the sgsn peer */ |
| 20 | unsigned int gtp_version; /* GTP version */ |
| 21 | int remote_restart_ctr; /* Last received Restart Ctr from sgsn peer, -1 == unknown */ |
| 22 | /* list of pdp contexts associated with this sgsn */ |
| 23 | struct llist_head pdp_list; |
| 24 | /* Sends echo request towards SGSN on expiration. Echo Resp is received |
| 25 | through cb_recovery2(), and echo Req timeout through |
| 26 | cb_conf(GTP_ECHO_REQ, EOF, NULL, cbp); */ |
| 27 | struct osmo_timer_list echo_timer; |
| 28 | /* Number of GTP messages in libgtp transmit queue */ |
| 29 | unsigned int tx_msgs_queued; |
| 30 | }; |
| 31 | |
| 32 | struct sgsn_peer *sgsn_peer_allocate(struct ggsn_ctx *ggsn, struct in_addr *ia, unsigned int gtp_version); |
| 33 | void sgsn_peer_add_pdp_priv(struct sgsn_peer *sgsn, struct pdp_priv_t *pdp_priv); |
| 34 | void sgsn_peer_remove_pdp_priv(struct pdp_priv_t *pdp_priv); |
| 35 | |
| 36 | void sgsn_echo_timer_start(struct sgsn_peer *sgsn); |
| 37 | void sgsn_echo_timer_stop(struct sgsn_peer *sgsn); |
| 38 | |
| 39 | void sgsn_peer_echo_resp(struct sgsn_peer *sgsn, bool timeout); |
| 40 | unsigned int sgsn_peer_drop_all_pdp(struct sgsn_peer *sgsn); |
| 41 | int sgsn_peer_handle_recovery(struct sgsn_peer *sgsn, struct pdp_t *pdp, uint8_t recovery); |
| 42 | |
| 43 | #define LOGSGSN(level, sgsn, fmt, args...) { \ |
| 44 | char _buf[INET_ADDRSTRLEN]; \ |
| 45 | LOGP(DGGSN, level, "SGSN(%s): " fmt, inet_ntop(AF_INET, &sgsn->addr, _buf, sizeof(_buf)), ## args); \ |
| 46 | } while (0) |