link_sets: Move the submit for SCCP/ISUP into a function pointer
In the preparation of supporting multiple link_sets types the
send routines are accessed through function pointers now.
diff --git a/include/linkset.h b/include/linkset.h
index 1385cf1..00dddf0 100644
--- a/include/linkset.h
+++ b/include/linkset.h
@@ -45,6 +45,11 @@
void (*on_sccp) (struct mtp_link_set *set, struct msgb *msg, int sls);
void (*on_isup) (struct mtp_link_set *set, struct msgb *msg, int sls);
+ /*
+ * Sending routines
+ */
+ int (*submit_sccp) (struct mtp_link_set *set, int sls, const uint8_t *data, unsigned int len);
+ int (*submit_isup) (struct mtp_link_set *set, int sls, const uint8_t *data, unsigned int len);
/**
* Routing is very limited. We can only forward to one
@@ -102,8 +107,6 @@
void mtp_link_set_reset(struct mtp_link_set *set);
int mtp_link_set_data(struct mtp_link *link, struct msgb *msg);
int mtp_link_handle_data(struct mtp_link *link, struct msgb *msg);
-int mtp_link_set_submit_sccp_data(struct mtp_link_set *set, int sls, const uint8_t *data, unsigned int length);
-int mtp_link_set_submit_isup_data(struct mtp_link_set *set, int sls, const uint8_t *data, unsigned int length);
void mtp_link_set_init_slc(struct mtp_link_set *set);
diff --git a/src/isup.c b/src/isup.c
index f9ea0ae..614d7d4 100644
--- a/src/isup.c
+++ b/src/isup.c
@@ -133,7 +133,7 @@
if (!resp)
return -1;
- mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
+ set->submit_isup(set, sls, resp->l2h, msgb_l2len(resp));
msgb_free(resp);
return 0;
}
@@ -157,7 +157,7 @@
if (!resp)
return -1;
- mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
+ set->submit_isup(set, sls, resp->l2h, msgb_l2len(resp));
msgb_free(resp);
return 0;
}
@@ -172,7 +172,7 @@
if (!resp)
return -1;
- mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
+ set->submit_isup(set, sls, resp->l2h, msgb_l2len(resp));
msgb_free(resp);
return 0;
}
@@ -200,7 +200,7 @@
out = msgb_put(resp, size);
memcpy(out, data, size);
- mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
+ set->submit_isup(set, sls, resp->l2h, msgb_l2len(resp));
msgb_free(resp);
return 0;
}
@@ -212,7 +212,7 @@
resp = isup_simple_alloc(cic, msg_type);
if (!resp)
return -1;
- mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
+ set->submit_isup(set, sls, resp->l2h, msgb_l2len(resp));
msgb_free(resp);
return 0;
}
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 1b6ca0e..263d156 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -511,7 +511,8 @@
return rc;
}
-int mtp_link_set_submit_sccp_data(struct mtp_link_set *set, int sls, const uint8_t *data, unsigned int length)
+static int mtp_link_set_submit_sccp_data(struct mtp_link_set *set, int sls,
+ const uint8_t *data, unsigned int length)
{
if (!set->sccp_up) {
@@ -668,6 +669,10 @@
llist_add_tail(&set->entry, &bsc->linksets);
+ /* implemenentation pointers */
+ set->submit_sccp = mtp_link_set_submit_sccp_data;
+ set->submit_isup = mtp_link_set_submit_isup_data;
+
return set;
}
diff --git a/src/sccp_state.c b/src/sccp_state.c
index 616167f..c016385 100644
--- a/src/sccp_state.c
+++ b/src/sccp_state.c
@@ -133,7 +133,7 @@
cr = (struct sccp_connection_request *) inpt->l2h;
msg = create_sccp_refuse(&cr->source_local_reference);
if (msg) {
- mtp_link_set_submit_sccp_data(set, sls, msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg);
}
return;
@@ -153,7 +153,7 @@
LOGP(DINP, LOGL_DEBUG, "Sending a release request now.\n");
msg = create_sccp_rlsd(&con->dst_ref, &con->src_ref);
if (msg) {
- mtp_link_set_submit_sccp_data(set, con->sls, msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, con->sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg);
}
return;
@@ -217,7 +217,7 @@
}
++app->reset_count;
- mtp_link_set_submit_sccp_data(set, -1, msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, -1, msg->l2h, msgb_l2len(msg));
msgb_free(msg);
osmo_timer_schedule(&app->reset_timeout, 20, 0);
}
@@ -276,7 +276,7 @@
continue;
/* wait for the clear commands */
- mtp_link_set_submit_sccp_data(set, con->sls, msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, con->sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg);
}
@@ -304,7 +304,7 @@
if (!msg)
return;
- mtp_link_set_submit_sccp_data(set, sls, msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg);
}
@@ -498,7 +498,7 @@
LOGP(DINP, LOGL_DEBUG, "Sending RLSD for 0x%x the %d time.\n",
sccp_src_ref_to_int(&con->src_ref), con->rls_tries);
- mtp_link_set_submit_sccp_data(set, con->sls, rlsd->l2h, msgb_l2len(rlsd));
+ set->submit_sccp(set, con->sls, rlsd->l2h, msgb_l2len(rlsd));
msgb_free(rlsd);
}
@@ -523,7 +523,7 @@
0x00, 0x01, 0x31
};
- mtp_link_set_submit_sccp_data(set, sls, reset_ack, sizeof(reset_ack));
+ set->submit_sccp(set, sls, reset_ack, sizeof(reset_ack));
}
void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg)
@@ -543,8 +543,8 @@
if (msc->app->forward_only) {
if (!set->sccp_up)
return;
- mtp_link_set_submit_sccp_data(set, -1,
- msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, -1,
+ msg->l2h, msgb_l2len(msg));
} else {
struct sccp_parse_result result;
int rc;
@@ -574,8 +574,8 @@
bss_rewrite_header_to_bsc(msg, set->opc, set->dpc);
/* we can not forward it right now */
- mtp_link_set_submit_sccp_data(set, sls,
- msg->l2h, msgb_l2len(msg));
+ set->submit_sccp(set, sls,
+ msg->l2h, msgb_l2len(msg));
}
}
}
diff --git a/src/ss7_application.c b/src/ss7_application.c
index 49f005d..cdb100f 100644
--- a/src/ss7_application.c
+++ b/src/ss7_application.c
@@ -38,7 +38,7 @@
struct mtp_link_set *other;
other = set->app->route_src.set == set ?
set->app->route_dst.set : set->app->route_src.set;
- mtp_link_set_submit_sccp_data(other, sls, _msg->l2h, msgb_l2len(_msg));
+ set->submit_sccp(other, sls, _msg->l2h, msgb_l2len(_msg));
}
static void forward_isup_stp(struct mtp_link_set *set, struct msgb *msg, int sls)
@@ -47,7 +47,7 @@
other = set->app->route_src.set == set ?
set->app->route_dst.set : set->app->route_src.set;
isup_scan_for_reset(set->app, msg);
- mtp_link_set_submit_isup_data(other, sls, msg->l3h, msgb_l3len(msg));
+ set->submit_isup(other, sls, msg->l3h, msgb_l3len(msg));
}
static void on_link_set_sccp(struct mtp_link_set *set, struct msgb *_msg, int sls)