igpp: Add VTY config for peer
Change-Id: I62d3247104cf0439a508c9e73d611376fb767d82
This commit is contained in:
parent
82de3f6693
commit
7f22569518
|
@ -13,6 +13,8 @@
|
|||
#include <osmocom/gprs/gprs_ns2.h>
|
||||
#include <osmocom/vty/command.h>
|
||||
|
||||
#include <osmocom/gbproxy/gb_proxy_igpp.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -100,6 +102,10 @@ struct gbproxy_config {
|
|||
|
||||
/* Counter */
|
||||
struct rate_ctr_group *ctrg;
|
||||
|
||||
|
||||
/* IGPP */
|
||||
struct igpp_config igpp;
|
||||
};
|
||||
|
||||
/* One Cell within the BSS: Links BSS-side BVC to SGSN-side BVCs */
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <osmocom/core/hashtable.h>
|
||||
#include <osmocom/core/fsm.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
|
||||
#include <osmocom/netif/stream.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum igpp_pdu_type {
|
||||
|
@ -45,6 +51,7 @@ enum igpp_iei_type {
|
|||
// FIXME: Do we need this?
|
||||
IGPP_IE_TRANS_NO,
|
||||
IGPP_IE_ROLE,
|
||||
IGPP_IE_ROLE_NSE,
|
||||
IGPP_IE_NSEI,
|
||||
IGPP_IE_BVCI,
|
||||
IGPP_IE_CELL_ID,
|
||||
|
@ -57,8 +64,17 @@ enum igpp_iei_type {
|
|||
// TODO: BSSGP Features and Ext Features
|
||||
};
|
||||
|
||||
#define IGPP_ROLE_SGSN 0x01
|
||||
#define IGPP_ROLE_BSS 0x02
|
||||
/* TODO: Per NSE or per Server? */
|
||||
enum igpp_role {
|
||||
IGPP_ROLE_NONE = 0x00,
|
||||
IGPP_ROLE_PRIMARY = 0x01,
|
||||
IGPP_ROLE_SECONDARY = 0x02,
|
||||
};
|
||||
|
||||
enum igpp_role_nse {
|
||||
IGPP_ROLE_NSE_SGSN = 0x01,
|
||||
IGPP_ROLE_NSE_BSS = 0x02,
|
||||
};
|
||||
|
||||
extern const struct osmo_tlv_prot_def osmo_pdef_igpp;
|
||||
|
||||
|
@ -71,4 +87,40 @@ struct igpp_msgb_cb {
|
|||
#define IGPP_MSGB_CB(__msgb) ((struct igpp_msgb_cb *)&((__msgb)->cb[0]))
|
||||
#define msgb_igpph(__x) IGPP_MSGB_CB(__x)->igpph
|
||||
#define msgb_bssgph(__x) IGPP_MSGB_CB(__x)->bssgph
|
||||
#define msgb_bssgp_len(__x) ((__x)->tail - (uint8_t *)msgb_bssgph(__x))
|
||||
#define msgb_bssgp_len(__x) ((__x)->tail - (uint8_t *)msgb_bssgph(__x))
|
||||
|
||||
|
||||
|
||||
/* Config structs */
|
||||
|
||||
struct igpp_config {
|
||||
/* Pointer back to the gbproxy config */
|
||||
struct gbproxy_config * cfg;
|
||||
|
||||
/* default role */
|
||||
enum igpp_role default_role;
|
||||
|
||||
/* hash table of all IGPP NSEs */
|
||||
DECLARE_HASHTABLE(igpp_nses, 8);
|
||||
|
||||
/* Remote peer info IP/port */
|
||||
struct {
|
||||
const char *host;
|
||||
uint16_t port;
|
||||
} peer;
|
||||
|
||||
/* SCTP connection to the peer. default_role determines if it's
|
||||
* client or server */
|
||||
struct {
|
||||
struct osmo_stream_srv_link *srv;
|
||||
struct osmo_stream_srv *sconn;
|
||||
struct osmo_stream_cli *cconn;
|
||||
} link;
|
||||
};
|
||||
|
||||
struct igpp_nse {
|
||||
uint16_t nsei;
|
||||
struct osmo_fsm_inst *fi;
|
||||
};
|
||||
|
||||
int igpp_init_config(struct gbproxy_config *cfg);
|
|
@ -1717,5 +1717,7 @@ int gbproxy_init_config(struct gbproxy_config *cfg)
|
|||
osmo_clock_gettime(CLOCK_REALTIME, &tp);
|
||||
osmo_fsm_log_timeouts(true);
|
||||
|
||||
igpp_init_config(cfg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -245,6 +245,12 @@ static struct log_info_cat gprs_categories[] = {
|
|||
.enabled = 1,
|
||||
.color = "\033[38;5;121m"
|
||||
},
|
||||
[DIGPP] = {
|
||||
.name = "DIGPP",
|
||||
.description = "Inter-GbProxy Protocol",
|
||||
.enabled = 1,
|
||||
.color = "\033[38;5;208m"
|
||||
},
|
||||
};
|
||||
|
||||
static const struct log_info gprs_log_info = {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <osmocom/gsm/gsm48.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "osmocom/gbproxy/gb_proxy_igpp.h"
|
||||
#include <osmocom/gbproxy/gb_proxy.h>
|
||||
|
||||
#include <osmocom/vty/command.h>
|
||||
|
@ -143,6 +144,14 @@ static int config_write_gbproxy(struct vty *vty)
|
|||
vty_out(vty, " %d", r->last);
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
}
|
||||
if (g_cfg->igpp.default_role != IGPP_ROLE_NONE) {
|
||||
const char *igpp_role = "primary";
|
||||
if (g_cfg->igpp.default_role == IGPP_ROLE_SECONDARY)
|
||||
igpp_role = "secondary";
|
||||
|
||||
vty_out(vty, " igpp peer %s %u%s", g_cfg->igpp.peer.host, g_cfg->igpp.peer.port, VTY_NEWLINE);
|
||||
vty_out(vty, " igpp role %s%s", igpp_role, VTY_NEWLINE);
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -469,6 +478,42 @@ DEFUN_ATTR(cfg_gbproxy_nri_null_del,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_igpp_peer,
|
||||
cfg_igpp_peer_cmd,
|
||||
"igpp peer " VTY_IPV46_CMD " <1-65535>",
|
||||
"IGPP related configuration\n"
|
||||
"Configure IGPP peer\n"
|
||||
"IP address of peer\n"
|
||||
"Port of peer\n")
|
||||
{
|
||||
/* const char *addr_str = argv[0];
|
||||
uint16_t port = atoi(argv[1]);
|
||||
struct osmo_sockaddr_str sockaddr_str;
|
||||
struct osmo_sockaddr sockaddr;
|
||||
*/
|
||||
g_cfg->igpp.peer.host = talloc_strdup(g_cfg, argv[0]);
|
||||
g_cfg->igpp.peer.port = atoi(argv[1]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_igpp_role,
|
||||
cfg_igpp_role_cmd,
|
||||
"igpp role (primary|secondary|none)",
|
||||
"IGPP related configuration\n"
|
||||
"Configure IGPP role\n"
|
||||
"Primary\n"
|
||||
"Secondary\n")
|
||||
{
|
||||
if (!strcmp(argv[0], "primary")) {
|
||||
g_cfg->igpp.default_role = IGPP_ROLE_PRIMARY;
|
||||
} else if (!strcmp(argv[0], "secondary")) {
|
||||
g_cfg->igpp.default_role = IGPP_ROLE_SECONDARY;
|
||||
} else {
|
||||
g_cfg->igpp.default_role = IGPP_ROLE_NONE;
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void log_set_bvc_filter(struct log_target *target,
|
||||
const uint16_t *bvci)
|
||||
{
|
||||
|
@ -756,6 +801,8 @@ int gbproxy_vty_init(void)
|
|||
install_element(GBPROXY_NODE, &cfg_gbproxy_nri_bitlen_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_gbproxy_nri_null_add_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_gbproxy_nri_null_del_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_igpp_peer_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_igpp_role_cmd);
|
||||
|
||||
install_element(CONFIG_NODE, &cfg_sgsn_nsei_cmd);
|
||||
install_node(&sgsn_node, config_write_sgsn);
|
||||
|
|
Loading…
Reference in New Issue