From b5ce49f872afa739d8df24b3a7d657fef30730ea Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 24 Jul 2018 17:42:14 +0200 Subject: cosmetic: reduce bsc_api.h Remove as much as possible from bsc_api.h. Use '#pragma once'. Tweak head comment. BSC_API_CONN_POL_{ACCEPT,REJECT}: only user is static complete_layer3(), just use a bool return value instead. msc_connected(): only used in osmo_bsc_api.c, make static there. Instead of including gsm_data.h, declare structs opaquely, include stdint.h. codec_pref_test.c used this as indirect gsm_data.h include via osmo_bsc.h, include gsm_data.h there directly. osmo_bsc.h: instead of including bsc_api.h, declare opaque structs. gsm_04_08_rr.h: declare opaque structs to replace indirect include of gsm_data.h. Change-Id: Ia9c0f9828317236048e40ec9ecf9990592e2190a --- include/osmocom/bsc/bsc_api.h | 18 ++++-------------- include/osmocom/bsc/gsm_04_08_rr.h | 13 +++++++++++++ include/osmocom/bsc/osmo_bsc.h | 3 ++- src/osmo-bsc/osmo_bsc_api.c | 21 +++++++++++---------- tests/codec_pref/codec_pref_test.c | 1 + 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/include/osmocom/bsc/bsc_api.h b/include/osmocom/bsc/bsc_api.h index dcfcc45f2..524129560 100644 --- a/include/osmocom/bsc/bsc_api.h +++ b/include/osmocom/bsc/bsc_api.h @@ -1,12 +1,10 @@ -/* GSM 08.08 like API for OpenBSC */ +/* GSM 08.08 function declarations for osmo-bsc */ -#ifndef OPENBSC_BSC_API_H -#define OPENBSC_BSC_API_H +#pragma once -#include "gsm_data.h" +#include -#define BSC_API_CONN_POL_ACCEPT 0 -#define BSC_API_CONN_POL_REJECT 1 +struct gsm_subscriber_connection; void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci); void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t chosen_encr); @@ -16,11 +14,3 @@ int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause); void bsc_cm_update(struct gsm_subscriber_connection *conn, const uint8_t *cm2, uint8_t cm2_len, const uint8_t *cm3, uint8_t cm3_len); - -int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t link_id, - bool allow_sacch); -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate); -int gsm0808_clear(struct gsm_subscriber_connection *conn); - -bool msc_connected(struct gsm_subscriber_connection *conn); -#endif diff --git a/include/osmocom/bsc/gsm_04_08_rr.h b/include/osmocom/bsc/gsm_04_08_rr.h index 63bec7af3..8f46922a7 100644 --- a/include/osmocom/bsc/gsm_04_08_rr.h +++ b/include/osmocom/bsc/gsm_04_08_rr.h @@ -1,5 +1,18 @@ #pragma once +#include + +struct amr_mode; +struct amr_multirate_conf; +struct bsc_subscr; +struct gsm48_chan_desc; +struct gsm48_pag_resp; +struct gsm_lchan; +struct gsm_meas_rep; +struct gsm_network; +struct gsm_subscriber_connection; +struct msgb; + void gsm_net_update_ctype(struct gsm_network *network); enum gsm_chan_t get_ctype_by_chreq(struct gsm_network *network, uint8_t ra); int get_reason_by_chreq(uint8_t ra, int neci); diff --git a/include/osmocom/bsc/osmo_bsc.h b/include/osmocom/bsc/osmo_bsc.h index 0e19b0bbc..bebfb2faa 100644 --- a/include/osmocom/bsc/osmo_bsc.h +++ b/include/osmocom/bsc/osmo_bsc.h @@ -2,7 +2,6 @@ #include -#include #include #define BSS_SEND_USSD 1 @@ -18,6 +17,8 @@ struct bsc_msc_data; struct gsm0808_channel_type; struct gsm0808_speech_codec_list; struct gsm_audio_support; +struct gsm_subscriber_connection; +struct gsm_bts; struct bsc_api *osmo_bsc_api(); diff --git a/src/osmo-bsc/osmo_bsc_api.c b/src/osmo-bsc/osmo_bsc_api.c index b4d080d7f..dfec19a6d 100644 --- a/src/osmo-bsc/osmo_bsc_api.c +++ b/src/osmo-bsc/osmo_bsc_api.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,7 @@ #include /* Check if we have a proper connection to the MSC */ -bool msc_connected(struct gsm_subscriber_connection *conn) +static bool msc_connected(struct gsm_subscriber_connection *conn) { /* No subscriber conn at all */ if (!conn) @@ -53,8 +54,8 @@ bool msc_connected(struct gsm_subscriber_connection *conn) return true; } -static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct bsc_msc_data *msc); +static bool complete_layer3(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_msc_data *msc); static struct osmo_cell_global_id *cgi_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { @@ -438,8 +439,8 @@ int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) return 0; } -static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct bsc_msc_data *msc) +static bool complete_layer3(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_msc_data *msc) { int con_type, rc, lu_cause; char *imsi = NULL; @@ -451,7 +452,7 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, &imsi, &con_type, &lu_cause); if (rc < 0) { bsc_maybe_lu_reject(conn, con_type, lu_cause); - return BSC_API_CONN_POL_REJECT; + return false; } /* allocate resource for a new connection */ @@ -464,7 +465,7 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, else if (ret == BSC_CON_REJECT_RF_GRACE) bsc_send_ussd_no_srv(conn, msg, msc->ussd_grace_txt); - return BSC_API_CONN_POL_REJECT; + return false; } /* TODO: also extract TMSI. We get an IMSI only when an initial L3 Complete comes in that @@ -493,12 +494,12 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, resp = gsm0808_create_layer3_2(msg, cgi_for_msc(conn->sccp.msc, conn_get_bts(conn)), NULL); if (!resp) { LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n"); - return BSC_API_CONN_POL_REJECT; + return false; } osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CONN_REQ, resp); - return BSC_API_CONN_POL_ACCEPT; + return true; } /* @@ -519,7 +520,7 @@ static int move_to_msc(struct gsm_subscriber_connection *_conn, * MSC. If it fails the caller will need to handle this * properly. */ - if (complete_layer3(_conn, msg, msc) != BSC_API_CONN_POL_ACCEPT) { + if (!complete_layer3(_conn, msg, msc)) { /* FIXME: I have not the slightest idea what move_to_msc() intends to do; during lchan * FSM introduction, I changed this and hope it is the appropriate action. I actually * assume this is unused legacy code for osmo-bsc_nat?? */ diff --git a/tests/codec_pref/codec_pref_test.c b/tests/codec_pref/codec_pref_test.c index 0f908e591..b0b9f5e95 100644 --- a/tests/codec_pref/codec_pref_test.c +++ b/tests/codec_pref/codec_pref_test.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include -- cgit v1.2.3