aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc/osmo_bsc_api.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-05 11:02:28 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-15 20:06:48 +0100
commit46c5ab3624c0008b9eec0a1f6eed4f99dbc11211 (patch)
tree1141778bb0cfc991c1ca26a8991f8292ce003618 /openbsc/src/bsc/osmo_bsc_api.c
parente46f1d6cc48a0f3a7a78ac5e79da373475258baf (diff)
bsc: Reduce duplication with a macro.
Diffstat (limited to 'openbsc/src/bsc/osmo_bsc_api.c')
-rw-r--r--openbsc/src/bsc/osmo_bsc_api.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/openbsc/src/bsc/osmo_bsc_api.c b/openbsc/src/bsc/osmo_bsc_api.c
index 5a0385686..0fe6bd2c8 100644
--- a/openbsc/src/bsc/osmo_bsc_api.c
+++ b/openbsc/src/bsc/osmo_bsc_api.c
@@ -36,18 +36,20 @@
return ret; \
}
+#define queue_msg_or_return(resp) \
+ if (!resp) { \
+ LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n"); \
+ return; \
+ } \
+ bsc_queue_for_msc(conn, resp);
+
static void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci)
{
struct msgb *resp;
return_when_not_connected(conn);
resp = gsm0808_create_sapi_reject(dlci);
- if (!resp) {
- LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n");
- return;
- }
-
- bsc_queue_for_msc(conn, resp);
+ queue_msg_or_return(resp);
}
static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
@@ -58,12 +60,7 @@ static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
LOGP(DMSC, LOGL_DEBUG, "CIPHER MODE COMPLETE from MS, forwarding to MSC\n");
resp = gsm0808_create_cipher_complete(msg, chosen_encr);
- if (!resp) {
- LOGP(DMSC, LOGL_ERROR, "Creating the response failed.\n");
- return;
- }
-
- bsc_queue_for_msc(conn, resp);
+ queue_msg_or_return(resp);
}
static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
@@ -78,12 +75,7 @@ static void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, st
return_when_not_connected(conn);
resp = gsm0808_create_dtap(msg, link_id);
- if (!resp) {
- LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n");
- return;
- }
-
- bsc_queue_for_msc(conn, resp);
+ queue_msg_or_return(resp);
}
static void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_cause,
@@ -95,12 +87,7 @@ static void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_
resp = gsm0808_create_assignment_completed(rr_cause, chosen_channel,
encr_alg_id, speech_model);
- if (!resp) {
- LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n");
- return;
- }
-
- bsc_queue_for_msc(conn, resp);
+ queue_msg_or_return(resp);
}
static void bsc_assign_fail(struct gsm_subscriber_connection *conn,
@@ -110,12 +97,7 @@ static void bsc_assign_fail(struct gsm_subscriber_connection *conn,
return_when_not_connected(conn);
resp = gsm0808_create_assignment_failure(cause, rr_cause);
- if (!resp) {
- LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n");
- return;
- }
-
- bsc_queue_for_msc(conn, resp);
+ queue_msg_or_return(resp);
}
static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause)