9
0
Fork 0

mtp: Allocate the MTPLinkSet as a child of the BSC

In preparation of the VTY code change, make the mtp linkset
a child of the bsc.
This commit is contained in:
Holger Hans Peter Freyther 2011-02-15 11:18:38 +01:00
parent 2ff47b8606
commit 599c9a4b9a
8 changed files with 28 additions and 35 deletions

View File

@ -123,7 +123,6 @@ struct bsc_data {
int setup;
int pcap_fd;
int udp_reset_timeout;
struct llist_head links;
/* udp code */
struct mtp_udp_data udp_data;
@ -145,6 +144,9 @@ struct bsc_data {
/* isup handling */
int isup_pass;
/* MTP Links */
struct llist_head linksets;
int num_linksets;
/* inject */
int allow_inject;

View File

@ -42,13 +42,15 @@ struct rate_ctr_group;
*/
struct mtp_link_set {
struct llist_head entry;
int no;
char *name;
/* routing info.. */
int dpc, opc, sccp_opc, isup_opc;
int ni;
int spare;
const char *name;
/* internal state */
/* the MTP1 link is up */
@ -120,7 +122,6 @@ struct mtp_link {
};
struct mtp_link_set *mtp_link_set_alloc(void);
void mtp_link_set_stop(struct mtp_link_set *link);
void mtp_link_set_reset(struct mtp_link_set *link);
int mtp_link_set_data(struct mtp_link *link, struct msgb *msg);
@ -134,9 +135,6 @@ void mtp_link_block(struct mtp_link *link);
void mtp_link_unblock(struct mtp_link *link);
/* one time init function */
void mtp_link_set_init(void);
/* to be implemented for MSU sending */
void mtp_link_submit(struct mtp_link *link, struct msgb *msg);
void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *msg, int sls);
@ -158,4 +156,7 @@ void mtp_link_failure(struct mtp_link *fail);
/* internal routines */
struct msgb *mtp_msg_alloc(struct mtp_link_set *link);
/* link management */
struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc);
#endif

View File

@ -35,7 +35,7 @@ struct bsc_data *bsc_data_create()
return NULL;
}
INIT_LLIST_HEAD(&bsc->links);
INIT_LLIST_HEAD(&bsc->linksets);
bsc->dpc = 1;
bsc->opc = 0;
bsc->sccp_opc = -1;

View File

@ -106,7 +106,7 @@ struct mtp_link_set *link_init(struct bsc_data *bsc)
struct mtp_udp_link *lnk;
struct mtp_link_set *set;
set = mtp_link_set_alloc();
set = mtp_link_set_alloc(bsc);
set->name = talloc_strdup(set, "MTP");
set->dpc = bsc->dpc;
set->opc = bsc->opc;

View File

@ -85,7 +85,7 @@ static void sigint()
printf("Terminating.\n");
handled = 1;
if (bsc && bsc->setup) {
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
link_shutdown_all(set);
}
@ -175,7 +175,6 @@ int main(int argc, char **argv)
struct mtp_link_set *set;
mtp_link_set_init();
thread_init();
log_init(&log_info);
@ -222,7 +221,6 @@ int main(int argc, char **argv)
if (!set)
return -1;
llist_add(&set->entry, &bsc->links);
set->fw = &bsc->msc_forward;
bsc->msc_forward.bsc = set;

View File

@ -112,7 +112,7 @@ static void sigint()
printf("Terminating.\n");
handled = 1;
if (bsc && bsc->setup) {
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
link_shutdown_all(set);
}
exit(0);
@ -182,7 +182,7 @@ static struct mtp_link_set *find_link_set(struct bsc_data *bsc,
{
struct mtp_link_set *set;
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
if (strncmp(buf, set->name, len) == 0)
return set;
@ -308,7 +308,6 @@ int main(int argc, char **argv)
struct mtp_link_set *m2ua_set;
struct mtp_m2ua_link *lnk;
mtp_link_set_init();
thread_init();
log_init(&log_info);
@ -356,9 +355,8 @@ int main(int argc, char **argv)
set = link_init(bsc);
if (!set)
return -1;
llist_add(&set->entry, &bsc->links);
m2ua_set = mtp_link_set_alloc();
m2ua_set = mtp_link_set_alloc(bsc);
m2ua_set->dpc = 92;
m2ua_set->opc = 9;
m2ua_set->sccp_opc = 9;
@ -367,7 +365,6 @@ int main(int argc, char **argv)
m2ua_set->bsc = bsc;
m2ua_set->pcap_fd = bsc->pcap_fd;
m2ua_set->name = talloc_strdup(m2ua_set, "M2UA");
llist_add(&m2ua_set->entry, &bsc->links);
/* setup things */
set->pass_all_isup = bsc->isup_pass;

View File

@ -33,8 +33,6 @@
#include <string.h>
static void *tall_mtp_ctx = NULL;
static int mtp_int_submit(struct mtp_link_set *link, int pc, int sls, int type, const uint8_t *data, unsigned int length);
void mtp_link_submit(struct mtp_link *link, struct msgb *msg)
@ -185,23 +183,17 @@ static struct msgb *mtp_sccp_alloc_scmg(struct mtp_link_set *link,
return out;
}
void mtp_link_set_init(void)
struct mtp_link_set *mtp_link_set_alloc(struct bsc_data *bsc)
{
tall_mtp_ctx = talloc_named_const(NULL, 1, "mtp-link");
}
struct mtp_link_set *mtp_link_set_alloc(void)
{
static int linkset_no = 0;
struct mtp_link_set *link;
link = talloc_zero(tall_mtp_ctx, struct mtp_link_set);
link = talloc_zero(bsc, struct mtp_link_set);
if (!link)
return NULL;
link->ctrg = rate_ctr_group_alloc(link,
mtp_link_set_rate_ctr_desc(),
linkset_no++);
bsc->num_linksets + 1);
if (!link->ctrg) {
LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n");
return NULL;
@ -211,6 +203,9 @@ struct mtp_link_set *mtp_link_set_alloc(void)
link->ni = MTP_NI_NATION_NET;
INIT_LLIST_HEAD(&link->links);
link->no = bsc->num_linksets++;
llist_add(&link->entry, &bsc->linksets);
return link;
}

View File

@ -266,7 +266,7 @@ DEFUN(cfg_isup_pass, cfg_isup_pass_cmd,
bsc->isup_pass = atoi(argv[0]);
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
set->pass_all_isup = bsc->isup_pass;
return CMD_SUCCESS;
@ -291,7 +291,7 @@ DEFUN(show_stats, show_stats_cmd,
{
struct mtp_link_set *set;
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
dump_stats(vty, set);
return CMD_SUCCESS;
@ -330,7 +330,7 @@ DEFUN(show_linksets, show_linksets_cmd,
{
struct mtp_link_set *set;
llist_for_each_entry(set, &bsc->links, entry)
llist_for_each_entry(set, &bsc->linksets, entry)
dump_state(vty, set);
return CMD_SUCCESS;
}
@ -365,7 +365,7 @@ DEFUN(show_slc, show_slc_cmd,
struct mtp_link_set *set = NULL;
int i;
set = find_link_set(&bsc->links, argv[0]);
set = find_link_set(&bsc->linksets, argv[0]);
if (!set) {
vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE);
@ -392,7 +392,7 @@ DEFUN(pcap_set, pcap_set_cmd,
{
struct mtp_link_set *set = NULL;
set = find_link_set(&bsc->links, argv[0]);
set = find_link_set(&bsc->linksets, argv[0]);
if (!set) {
vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE);
@ -420,7 +420,7 @@ DEFUN(pcap_set_stop, pcap_set_stop_cmd,
{
struct mtp_link_set *set = NULL;
set = find_link_set(&bsc->links, argv[0]);
set = find_link_set(&bsc->linksets, argv[0]);
if (!set) {
vty_out(vty, "Failed to find linkset.%s", VTY_NEWLINE);
@ -436,7 +436,7 @@ DEFUN(pcap_set_stop, pcap_set_stop_cmd,
#define FIND_LINK(vty, type, nr) ({ \
struct mtp_link_set *set = NULL; \
struct mtp_link *link = NULL, *tmp; \
set = find_link_set(&bsc->links, type); \
set = find_link_set(&bsc->linksets, type); \
if (!set) { \
vty_out(vty, "Unknown linkset %s.%s", type, VTY_NEWLINE); \
return CMD_WARNING; \