mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 04:53:24 +00:00
Compare commits
206 Commits
on-waves/0
...
on-waves/0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99743fb7ec | ||
|
|
a2a42a7561 | ||
|
|
ebd57da87d | ||
|
|
b0ee082bb0 | ||
|
|
81f6a4c0bf | ||
|
|
3978de52c1 | ||
|
|
7faf692cb7 | ||
|
|
0cf25d5154 | ||
|
|
08db178271 | ||
|
|
936d8c1b64 | ||
|
|
3170305e56 | ||
|
|
0f3490dd03 | ||
|
|
61e5e7bd8b | ||
|
|
f7b06fbe0c | ||
|
|
45403b1804 | ||
|
|
6782cea4bf | ||
|
|
ec7ecab66f | ||
|
|
d1287e379b | ||
|
|
3fb44f3e61 | ||
|
|
d48bfe0e93 | ||
|
|
41cdaf520d | ||
|
|
f94418a129 | ||
|
|
88b299ca24 | ||
|
|
58a2758e78 | ||
|
|
be3fdc2c6e | ||
|
|
6a8d765334 | ||
|
|
adebbfdfa7 | ||
|
|
afccfb9380 | ||
|
|
0f7a8258f0 | ||
|
|
2aa7f10939 | ||
|
|
37ba5b3e35 | ||
|
|
9f63d2b4ad | ||
|
|
d21b5de8c0 | ||
|
|
12b63716e2 | ||
|
|
184961ea3e | ||
|
|
a9ec86029f | ||
|
|
d1b19f3308 | ||
|
|
33f531fd12 | ||
|
|
b051b3b161 | ||
|
|
479a3aa707 | ||
|
|
fd2a877e25 | ||
|
|
53f797305f | ||
|
|
691b40e834 | ||
|
|
e511d54dd0 | ||
|
|
6edf7b9a51 | ||
|
|
e4045679a8 | ||
|
|
52ae9a461b | ||
|
|
5bd9493257 | ||
|
|
c92fd5d9d3 | ||
|
|
01cf14d679 | ||
|
|
840447e2bf | ||
|
|
3f7586d571 | ||
|
|
b74a9f13e5 | ||
|
|
bbc2c6e765 | ||
|
|
7e3724ad18 | ||
|
|
569dccf947 | ||
|
|
89a378e9aa | ||
|
|
4a78c7b250 | ||
|
|
c71013091a | ||
|
|
4b1cde10fe | ||
|
|
0f5a2345d1 | ||
|
|
ae81ff95ea | ||
|
|
e5981edf6a | ||
|
|
93cc16ae4f | ||
|
|
119a1976f5 | ||
|
|
c53c2ab524 | ||
|
|
32423500f6 | ||
|
|
c3a6a1dbe5 | ||
|
|
f4f090ee36 | ||
|
|
2a554bfcc4 | ||
|
|
a12dea66ca | ||
|
|
ec59bb04df | ||
|
|
4417f7f477 | ||
|
|
39563af27c | ||
|
|
242faaafd1 | ||
|
|
f77c0cd428 | ||
|
|
4103a3e5b9 | ||
|
|
4aca7f621f | ||
|
|
507d536ce8 | ||
|
|
cb618c7980 | ||
|
|
3c0702d3c5 | ||
|
|
caf24567d1 | ||
|
|
1d34c6ac5a | ||
|
|
1506f8e465 | ||
|
|
f044c585e2 | ||
|
|
6d17dd1314 | ||
|
|
38e9c82114 | ||
|
|
7cb6867ea3 | ||
|
|
d8138c43a1 | ||
|
|
46d9b94477 | ||
|
|
4f705b9f99 | ||
|
|
c592e697ce | ||
|
|
39608dc045 | ||
|
|
5fda90816f | ||
|
|
1803818092 | ||
|
|
439bb828f9 | ||
|
|
a06fea020d | ||
|
|
4511d891dd | ||
|
|
da0586a838 | ||
|
|
2c57232489 | ||
|
|
ad9f7830fb | ||
|
|
57ba7e3093 | ||
|
|
6ba3bcbbc6 | ||
|
|
ebb6b99c63 | ||
|
|
e08253a3f7 | ||
|
|
5e86095364 | ||
|
|
a7c144888d | ||
|
|
7897c4446b | ||
|
|
ff9e09b2bc | ||
|
|
ecf5cc294d | ||
|
|
82126763a7 | ||
|
|
a380c89a9c | ||
|
|
bedaf5da64 | ||
|
|
2b08aa35a6 | ||
|
|
c24632930a | ||
|
|
f140348eff | ||
|
|
b5de1b0781 | ||
|
|
b022cc3b8e | ||
|
|
e8396c9663 | ||
|
|
941839b300 | ||
|
|
23a0e46f11 | ||
|
|
cb8fd6e99e | ||
|
|
bb110f91e8 | ||
|
|
3ba36d5b57 | ||
|
|
bda581963d | ||
|
|
8d9833ef83 | ||
|
|
2ba40afc36 | ||
|
|
e66bea8ad7 | ||
|
|
e8a9f471ef | ||
|
|
e0ec326867 | ||
|
|
2d425059af | ||
|
|
135f797a37 | ||
|
|
f8eff2e4b5 | ||
|
|
70402a4e4d | ||
|
|
c2d66bdf5a | ||
|
|
80b584bbe7 | ||
|
|
15c21e8eec | ||
|
|
c0a1fff064 | ||
|
|
77fa4d2386 | ||
|
|
9be8752541 | ||
|
|
2b57b3cea4 | ||
|
|
00c531709a | ||
|
|
a094108f84 | ||
|
|
61e73eec3f | ||
|
|
1aa2798919 | ||
|
|
b829eac9bc | ||
|
|
7b1719327d | ||
|
|
493645eda9 | ||
|
|
8614cd0be7 | ||
|
|
19bd74d093 | ||
|
|
b54dda4cef | ||
|
|
b998d7b219 | ||
|
|
4821b5a847 | ||
|
|
63cb447fd5 | ||
|
|
5eec9d91d8 | ||
|
|
63d18b51a7 | ||
|
|
74419497fc | ||
|
|
ccfd572647 | ||
|
|
07ba16fe03 | ||
|
|
e1ffc08f72 | ||
|
|
ef8117883b | ||
|
|
ae80f9291a | ||
|
|
1469600b0d | ||
|
|
c50b836540 | ||
|
|
754e801826 | ||
|
|
19722d4411 | ||
|
|
5615b982c2 | ||
|
|
aff596b8e1 | ||
|
|
07d838a3bf | ||
|
|
d4e7888ae3 | ||
|
|
6c8c0ddbe2 | ||
|
|
19bab73d79 | ||
|
|
c19a65baae | ||
|
|
1ea8dbec90 | ||
|
|
500ff97c21 | ||
|
|
441273766a | ||
|
|
014136da47 | ||
|
|
91b5a31a2c | ||
|
|
575b89585f | ||
|
|
408cc4ace9 | ||
|
|
b4b135efbf | ||
|
|
54fa799129 | ||
|
|
b4c7b274a1 | ||
|
|
7279d24232 | ||
|
|
ef8253c495 | ||
|
|
6c0729fe70 | ||
|
|
e125d40f66 | ||
|
|
58df0ea9a0 | ||
|
|
8b120f0ef9 | ||
|
|
f2f1591ce7 | ||
|
|
f36a11a35d | ||
|
|
c77efdf057 | ||
|
|
b79994c952 | ||
|
|
616d222518 | ||
|
|
64e4e77558 | ||
|
|
9bdcc9ca75 | ||
|
|
e7d2ae69c9 | ||
|
|
52a66aa27e | ||
|
|
13d67b7ea3 | ||
|
|
b71517f07e | ||
|
|
95e4d34f06 | ||
|
|
f5b6aa60ce | ||
|
|
c38b5884ff | ||
|
|
4079105a6c | ||
|
|
774f0723bf | ||
|
|
88c6eeaa7d |
@@ -1,7 +1,7 @@
|
||||
dnl Process this file with autoconf to produce a configure script
|
||||
AC_INIT
|
||||
|
||||
AM_INIT_AUTOMAKE(openbsc, 0.3.96onwaves)
|
||||
AM_INIT_AUTOMAKE(openbsc, 0.3.99.6onwaves)
|
||||
|
||||
dnl kernel style compile messages
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
@@ -6,7 +6,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \
|
||||
bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \
|
||||
silent_call.h mgcp.h meas_rep.h rest_octets.h \
|
||||
system_information.h handover.h mgcp_internal.h \
|
||||
vty.h bssap.h bsc_msc.h bsc_nat.h
|
||||
vty.h bssap.h bsc_msc.h bsc_nat.h bsc_msc_rf.h
|
||||
|
||||
openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h
|
||||
openbscdir = $(includedir)/openbsc
|
||||
|
||||
@@ -72,6 +72,8 @@ int rsl_release_request(struct gsm_lchan *lchan, u_int8_t link_id, u_int8_t rele
|
||||
|
||||
int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
|
||||
|
||||
int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
|
||||
|
||||
/* to be provided by external code */
|
||||
int abis_rsl_sendmsg(struct msgb *msg);
|
||||
int rsl_deact_sacch(struct gsm_lchan *lchan);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
struct bsc_msc_connection {
|
||||
struct write_queue write_queue;
|
||||
int is_connected;
|
||||
int is_authenticated;
|
||||
const char *ip;
|
||||
int port;
|
||||
|
||||
|
||||
20
openbsc/include/openbsc/bsc_msc_rf.h
Normal file
20
openbsc/include/openbsc/bsc_msc_rf.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef BSC_MSC_RF
|
||||
#define BSC_MSC_RF
|
||||
|
||||
#include <osmocore/write_queue.h>
|
||||
|
||||
struct gsm_network;
|
||||
|
||||
struct bsc_msc_rf {
|
||||
struct bsc_fd listen;
|
||||
struct gsm_network *gsm_network;
|
||||
};
|
||||
|
||||
struct bsc_msc_rf_conn {
|
||||
struct write_queue queue;
|
||||
struct gsm_network *gsm_network;
|
||||
};
|
||||
|
||||
struct bsc_msc_rf *bsc_msc_rf_create(const char *path, struct gsm_network *net);
|
||||
|
||||
#endif
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/timer.h>
|
||||
#include <osmocore/write_queue.h>
|
||||
#include <osmocore/statistics.h>
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define DIR_BSC 1
|
||||
#define DIR_MSC 2
|
||||
@@ -90,6 +93,10 @@ struct bsc_connection {
|
||||
/* a timeout node */
|
||||
struct timer_list id_timeout;
|
||||
|
||||
/* pong timeout */
|
||||
struct timer_list ping_timeout;
|
||||
struct timer_list pong_timeout;
|
||||
|
||||
/* a back pointer */
|
||||
struct bsc_nat *nat;
|
||||
};
|
||||
@@ -107,12 +114,28 @@ struct sccp_connections {
|
||||
struct sccp_source_reference real_ref;
|
||||
struct sccp_source_reference patched_ref;
|
||||
struct sccp_source_reference remote_ref;
|
||||
int has_remote_ref;
|
||||
|
||||
/* GSM audio handling. That is 32 * multiplex + ts */
|
||||
int crcx;
|
||||
int msc_timeslot;
|
||||
int bsc_timeslot;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stats per BSC
|
||||
*/
|
||||
struct bsc_config_stats {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} net;
|
||||
};
|
||||
|
||||
/**
|
||||
* One BSC entry in the config
|
||||
*/
|
||||
@@ -123,7 +146,18 @@ struct bsc_config {
|
||||
unsigned int lac;
|
||||
int nr;
|
||||
|
||||
/* imsi white and blacklist */
|
||||
char *imsi_allow;
|
||||
regex_t imsi_allow_re;
|
||||
char *imsi_deny;
|
||||
regex_t imsi_deny_re;
|
||||
|
||||
int forbid_paging;
|
||||
|
||||
/* backpointer */
|
||||
struct bsc_nat *nat;
|
||||
|
||||
struct bsc_config_stats stats;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -134,8 +168,25 @@ struct bsc_endpoint {
|
||||
char *transaction_id;
|
||||
/* the bsc we are talking to */
|
||||
struct bsc_connection *bsc;
|
||||
/* pending delete */
|
||||
int pending_delete;
|
||||
};
|
||||
|
||||
/**
|
||||
* Statistic for the nat.
|
||||
*/
|
||||
struct bsc_nat_statistics {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
struct counter *auth_fail;
|
||||
} bsc;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} msc;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -159,9 +210,25 @@ struct bsc_nat {
|
||||
int mgcp_length;
|
||||
|
||||
/* msc things */
|
||||
char *msc_ip;
|
||||
int msc_port;
|
||||
int first_contact;
|
||||
|
||||
/* timeouts */
|
||||
int auth_timeout;
|
||||
int ping_timeout;
|
||||
int pong_timeout;
|
||||
|
||||
struct bsc_endpoint *bsc_endpoints;
|
||||
|
||||
/* filter */
|
||||
char *imsi_allow;
|
||||
regex_t imsi_allow_re;
|
||||
char *imsi_deny;
|
||||
regex_t imsi_deny_re;
|
||||
|
||||
/* statistics */
|
||||
struct bsc_nat_statistics stats;
|
||||
};
|
||||
|
||||
/* create and init the structures */
|
||||
@@ -169,8 +236,10 @@ struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsi
|
||||
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num);
|
||||
struct bsc_nat *bsc_nat_alloc(void);
|
||||
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat);
|
||||
void bsc_nat_set_msc_ip(struct bsc_nat *bsc, const char *ip);
|
||||
|
||||
void sccp_connection_destroy(struct sccp_connections *);
|
||||
void bsc_close_connection(struct bsc_connection *);
|
||||
|
||||
/**
|
||||
* parse the given message into the above structure
|
||||
@@ -182,7 +251,7 @@ struct bsc_nat_parsed *bsc_nat_parse(struct msgb *msg);
|
||||
*/
|
||||
int bsc_nat_filter_ipa(int direction, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
||||
int bsc_nat_vty_init(struct bsc_nat *nat);
|
||||
struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg);
|
||||
struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg, int *_lac);
|
||||
|
||||
/**
|
||||
* SCCP patching and handling
|
||||
@@ -191,19 +260,19 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
|
||||
int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *parsed);
|
||||
void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc_nat_parsed *parsed);
|
||||
struct sccp_connections *patch_sccp_src_ref_to_bsc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *);
|
||||
struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat_parsed *, struct bsc_nat *);
|
||||
struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat_parsed *, struct bsc_connection *);
|
||||
|
||||
/**
|
||||
* MGCP/Audio handling
|
||||
*/
|
||||
int bsc_write_mgcp(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length);
|
||||
int bsc_mgcp_assign(struct sccp_connections *, struct msgb *msg);
|
||||
void bsc_mgcp_clear(struct sccp_connections *);
|
||||
void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int);
|
||||
void bsc_mgcp_init(struct sccp_connections *);
|
||||
void bsc_mgcp_dlcx(struct sccp_connections *);
|
||||
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
|
||||
int bsc_mgcp_init(struct bsc_nat *nat);
|
||||
int bsc_mgcp_nat_init(struct bsc_nat *nat);
|
||||
|
||||
struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
||||
struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
|
||||
struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port);
|
||||
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
|
||||
|
||||
|
||||
@@ -330,6 +330,4 @@ void bts_send_queued(struct bss_sccp_connection_data*);
|
||||
void bts_free_queued(struct bss_sccp_connection_data*);
|
||||
void bts_unblock_queue(struct bss_sccp_connection_data*);
|
||||
|
||||
const struct tlv_definition *gsm0808_att_tlvdef();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@ struct gsm_lchan *lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr)
|
||||
struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr);
|
||||
|
||||
/* Allocate a logical channel (SDCCH, TCH, ...) */
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type);
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, int allow_bigger);
|
||||
|
||||
/* Free a logical channel (SDCCH, TCH, ...) */
|
||||
void lchan_free(struct gsm_lchan *lchan);
|
||||
|
||||
@@ -66,6 +66,8 @@ struct e1inp_ts {
|
||||
struct {
|
||||
/* list of all signalling links on this TS */
|
||||
struct llist_head sign_links;
|
||||
/* delay for the queue */
|
||||
int delay;
|
||||
/* timer when to dequeue next frame */
|
||||
struct timer_list tx_timer;
|
||||
} sign;
|
||||
@@ -93,6 +95,7 @@ struct e1inp_driver {
|
||||
struct llist_head list;
|
||||
const char *name;
|
||||
int (*want_write)(struct e1inp_ts *ts);
|
||||
int default_delay;
|
||||
};
|
||||
|
||||
struct e1inp_line {
|
||||
|
||||
@@ -73,17 +73,18 @@ enum gsm_paging_event {
|
||||
GSM_PAGING_OOM,
|
||||
};
|
||||
|
||||
enum bts_gprs_mode {
|
||||
BTS_GPRS_NONE = 0,
|
||||
BTS_GPRS_GPRS = 1,
|
||||
BTS_GPRS_EGPRS = 2,
|
||||
};
|
||||
|
||||
struct msgb;
|
||||
typedef int gsm_cbfn(unsigned int hooknum,
|
||||
unsigned int event,
|
||||
struct msgb *msg,
|
||||
void *data, void *param);
|
||||
|
||||
/* communications link with a BTS */
|
||||
struct gsm_bts_link {
|
||||
struct gsm_bts *bts;
|
||||
};
|
||||
|
||||
struct sccp_connection;
|
||||
|
||||
/* Real authentication information containing Ki */
|
||||
@@ -126,6 +127,7 @@ struct bss_sccp_connection_data {
|
||||
struct timer_list T10;
|
||||
|
||||
/* for SCCP ... */
|
||||
struct timer_list sccp_cc_timeout;
|
||||
struct timer_list sccp_it;
|
||||
|
||||
/* audio handling */
|
||||
@@ -399,6 +401,10 @@ struct gsm_bts_paging_state {
|
||||
struct gsm_bts *bts;
|
||||
|
||||
struct timer_list work_timer;
|
||||
struct timer_list credit_timer;
|
||||
|
||||
/* free chans needed */
|
||||
int free_chans_need;
|
||||
|
||||
/* load */
|
||||
u_int16_t available_slots;
|
||||
@@ -503,7 +509,7 @@ struct gsm_bts {
|
||||
|
||||
/* Not entirely sure how ip.access specific this is */
|
||||
struct {
|
||||
int enabled;
|
||||
enum bts_gprs_mode mode;
|
||||
struct {
|
||||
struct gsm_nm_state nm_state;
|
||||
u_int16_t nsei;
|
||||
@@ -515,6 +521,10 @@ struct gsm_bts {
|
||||
struct gsm_bts_gprs_nsvc nsvc[2];
|
||||
u_int8_t rac;
|
||||
} gprs;
|
||||
|
||||
/* RACH NM values */
|
||||
int rach_b_thresh;
|
||||
int rach_ldavg_slots;
|
||||
|
||||
/* transceivers */
|
||||
int num_trx;
|
||||
@@ -562,6 +572,14 @@ struct gsmnet_stats {
|
||||
struct counter *alerted; /* we alerted the other end */
|
||||
struct counter *connected;/* how many calls were accepted */
|
||||
} call;
|
||||
struct {
|
||||
struct counter *rf_fail;
|
||||
struct counter *rll_err;
|
||||
} chan;
|
||||
struct {
|
||||
struct counter *oml_fail;
|
||||
struct counter *rsl_fail;
|
||||
} bts;
|
||||
};
|
||||
|
||||
enum gsm_auth_policy {
|
||||
@@ -653,6 +671,10 @@ struct gsm_network {
|
||||
|
||||
/* a simple token for this network... */
|
||||
char *bsc_token;
|
||||
char *msc_ip;
|
||||
int msc_port;
|
||||
int ping_timeout;
|
||||
int pong_timeout;
|
||||
};
|
||||
|
||||
#define SMS_HDR_SIZE 128
|
||||
@@ -749,15 +771,10 @@ const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
|
||||
enum rrlp_mode rrlp_mode_parse(const char *arg);
|
||||
const char *rrlp_mode_name(enum rrlp_mode mode);
|
||||
|
||||
void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
|
||||
enum bts_gprs_mode bts_gprs_mode_parse(const char *arg);
|
||||
const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
|
||||
|
||||
/* A parsed GPRS routing area */
|
||||
struct gprs_ra_id {
|
||||
u_int16_t mnc;
|
||||
u_int16_t mcc;
|
||||
u_int16_t lac;
|
||||
u_int8_t rac;
|
||||
};
|
||||
void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
|
||||
|
||||
int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts);
|
||||
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
|
||||
|
||||
@@ -73,5 +73,6 @@ struct mgcp_msg_ptr {
|
||||
int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
|
||||
struct mgcp_msg_ptr *ptr, int size,
|
||||
const char **transaction_id, struct mgcp_endpoint **endp);
|
||||
int mgcp_send_dummy(struct mgcp_endpoint *endp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,4 +43,7 @@ void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
||||
/* update paging load */
|
||||
void paging_update_buffer_space(struct gsm_bts *bts, u_int16_t);
|
||||
|
||||
/* pending paging requests */
|
||||
unsigned int paging_pending_requests_nr(struct gsm_bts *bts);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,7 @@ enum gprs_nmo {
|
||||
GPRS_NMO_III = 2, /* no paging coordination */
|
||||
};
|
||||
|
||||
/* TS 04.60 12.24 */
|
||||
struct gprs_cell_options {
|
||||
enum gprs_nmo nmo;
|
||||
/* T3168: wait for packet uplink assignment message */
|
||||
@@ -79,6 +80,16 @@ struct gprs_cell_options {
|
||||
u_int32_t t3192; /* in milliseconds */
|
||||
u_int32_t drx_timer_max;/* in seconds */
|
||||
u_int32_t bs_cv_max;
|
||||
|
||||
u_int8_t ext_info_present;
|
||||
struct {
|
||||
u_int8_t egprs_supported;
|
||||
u_int8_t use_egprs_p_ch_req;
|
||||
u_int8_t bep_period;
|
||||
u_int8_t pfc_supported;
|
||||
u_int8_t dtm_supported;
|
||||
u_int8_t bss_paging_coordination;
|
||||
} ext_info;
|
||||
};
|
||||
|
||||
/* TS 04.60 Table 12.9.2 */
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef OPENBSC_VTY_H
|
||||
#define OPENBSC_VTY_H
|
||||
|
||||
struct gsm_network;
|
||||
struct vty;
|
||||
|
||||
void openbsc_vty_add_cmds(void);
|
||||
void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -411,4 +411,10 @@ struct sccp_data_it {
|
||||
u_int8_t credit;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct sccp_proto_err {
|
||||
u_int8_t type;
|
||||
struct sccp_source_reference destination_local_reference;
|
||||
u_int8_t error_cause;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
/* Create a new buffer. Memory will be allocated in chunks of the given
|
||||
size. If the argument is 0, the library will supply a reasonable
|
||||
default size suitable for buffering socket I/O. */
|
||||
struct buffer *buffer_new(size_t);
|
||||
struct buffer *buffer_new(void *ctx, size_t);
|
||||
|
||||
/* Free all data in the buffer. */
|
||||
void buffer_reset(struct buffer *);
|
||||
|
||||
@@ -35,7 +35,7 @@ bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -ldl -ldbi $(LIBCRYPT)
|
||||
bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c debug.c \
|
||||
rs232.c bts_siemens_bs11.c
|
||||
bsc_msc_ip_SOURCES = bssap.c bsc_msc_ip.c bsc_init.c vty_interface.c vty_interface_bsc.c \
|
||||
bsc_msc.c
|
||||
bsc_msc.c bsc_msc_rf.c
|
||||
bsc_msc_ip_LDADD = libbsc.a libvty.a libsccp.a
|
||||
|
||||
|
||||
|
||||
@@ -822,15 +822,56 @@ static int ipacc_sw_activate(struct gsm_bts *bts, u_int8_t obj_class, u_int8_t i
|
||||
return abis_nm_sendmsg(bts, msg);
|
||||
}
|
||||
|
||||
static int abis_nm_parse_sw_descr(const u_int8_t *sw_descr, int sw_descr_len)
|
||||
{
|
||||
static const struct tlv_definition sw_descr_def = {
|
||||
.def = {
|
||||
[NM_ATT_FILE_ID] = { TLV_TYPE_TL16V, },
|
||||
[NM_ATT_FILE_VERSION] = { TLV_TYPE_TL16V, },
|
||||
},
|
||||
};
|
||||
|
||||
u_int8_t tag;
|
||||
u_int16_t tag_len;
|
||||
const u_int8_t *val;
|
||||
int ofs = 0, len;
|
||||
|
||||
/* Classic TLV parsing doesn't work well with SW_DESCR because of it's
|
||||
* nested nature and the fact you have to assume it contains only two sub
|
||||
* tags NM_ATT_FILE_VERSION & NM_ATT_FILE_ID to parse it */
|
||||
|
||||
if (sw_descr[0] != NM_ATT_SW_DESCR) {
|
||||
DEBUGP(DNM, "SW_DESCR attribute identifier not found!\n");
|
||||
return -1;
|
||||
}
|
||||
ofs += 1;
|
||||
|
||||
len = tlv_parse_one(&tag, &tag_len, &val,
|
||||
&sw_descr_def, &sw_descr[ofs], sw_descr_len-ofs);
|
||||
if (len < 0 || (tag != NM_ATT_FILE_ID)) {
|
||||
DEBUGP(DNM, "FILE_ID attribute identifier not found!\n");
|
||||
return -2;
|
||||
}
|
||||
ofs += len;
|
||||
|
||||
len = tlv_parse_one(&tag, &tag_len, &val,
|
||||
&sw_descr_def, &sw_descr[ofs], sw_descr_len-ofs);
|
||||
if (len < 0 || (tag != NM_ATT_FILE_VERSION)) {
|
||||
DEBUGP(DNM, "FILE_VERSION attribute identifier not found!\n");
|
||||
return -3;
|
||||
}
|
||||
ofs += len;
|
||||
|
||||
return ofs;
|
||||
}
|
||||
|
||||
static int abis_nm_rx_sw_act_req(struct msgb *mb)
|
||||
{
|
||||
struct abis_om_hdr *oh = msgb_l2(mb);
|
||||
struct abis_om_fom_hdr *foh = msgb_l3(mb);
|
||||
struct tlv_parsed tp;
|
||||
const u_int8_t *sw_config;
|
||||
int sw_config_len;
|
||||
int file_id_len;
|
||||
int ret;
|
||||
int ret, sw_config_len, sw_descr_len;
|
||||
|
||||
debugp_foh(foh);
|
||||
|
||||
@@ -854,20 +895,16 @@ static int abis_nm_rx_sw_act_req(struct msgb *mb)
|
||||
DEBUGP(DNM, "Found SW config: %s\n", hexdump(sw_config, sw_config_len));
|
||||
}
|
||||
|
||||
if (sw_config[0] != NM_ATT_SW_DESCR)
|
||||
DEBUGP(DNM, "SW_DESCR attribute identifier not found!\n");
|
||||
if (sw_config[1] != NM_ATT_FILE_ID)
|
||||
DEBUGP(DNM, "FILE_ID attribute identifier not found!\n");
|
||||
file_id_len = sw_config[2] * 256 + sw_config[3];
|
||||
/* Use the first SW_DESCR present in SW config */
|
||||
sw_descr_len = abis_nm_parse_sw_descr(sw_config, sw_config_len);
|
||||
if (sw_descr_len < 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Assumes first SW file in list is the one to be activated */
|
||||
/* sw_config + 4 to skip over 2 attribute ID bytes and 16-bit length field */
|
||||
return ipacc_sw_activate(mb->trx->bts, foh->obj_class,
|
||||
foh->obj_inst.bts_nr,
|
||||
foh->obj_inst.trx_nr,
|
||||
foh->obj_inst.ts_nr,
|
||||
sw_config + 4,
|
||||
file_id_len);
|
||||
sw_config, sw_descr_len);
|
||||
}
|
||||
|
||||
/* Receive a CHANGE_ADM_STATE_ACK, parse the TLV and update local state */
|
||||
|
||||
@@ -845,6 +845,7 @@ static int rsl_rx_conn_fail(struct msgb *msg)
|
||||
|
||||
LOGPC(DRSL, LOGL_NOTICE, "\n");
|
||||
/* FIXME: only free it after channel release ACK */
|
||||
counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rf_fail);
|
||||
return rsl_rf_chan_release(msg->lchan, 1);
|
||||
}
|
||||
|
||||
@@ -1139,6 +1140,7 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
struct gsm_lchan *lchan;
|
||||
u_int8_t rqd_ta;
|
||||
int ret;
|
||||
int is_lu;
|
||||
|
||||
u_int16_t arfcn;
|
||||
u_int8_t ts_number, subch;
|
||||
@@ -1161,8 +1163,14 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
|
||||
|
||||
counter_inc(bts->network->stats.chreq.total);
|
||||
|
||||
/*
|
||||
* We want LOCATION UPDATES to succeed and will assign a TCH
|
||||
* if we have no SDCCH available.
|
||||
*/
|
||||
is_lu = !!(chreq_reason == GSM_CHREQ_REASON_LOCATION_UPD);
|
||||
|
||||
/* check availability / allocate channel */
|
||||
lchan = lchan_alloc(bts, lctype);
|
||||
lchan = lchan_alloc(bts, lctype, is_lu);
|
||||
if (!lchan) {
|
||||
LOGP(DRSL, LOGL_NOTICE, "BTS %d CHAN RQD: no resources for %s 0x%x\n",
|
||||
msg->lchan->ts->trx->bts->nr, gsm_lchant_name(lctype), rqd_ref->ra);
|
||||
@@ -1232,6 +1240,10 @@ static int rsl_rx_ccch_load(struct msgb *msg)
|
||||
switch (rslh->data[0]) {
|
||||
case RSL_IE_PAGING_LOAD:
|
||||
pg_buf_space = rslh->data[1] << 8 | rslh->data[2];
|
||||
if (is_ipaccess_bts(msg->trx->bts) && pg_buf_space == 0xffff) {
|
||||
/* paging load below configured threshold, use 50 as default */
|
||||
pg_buf_space = 50;
|
||||
}
|
||||
paging_update_buffer_space(msg->trx->bts, pg_buf_space);
|
||||
break;
|
||||
case RSL_IE_RACH_LOAD:
|
||||
@@ -1291,8 +1303,10 @@ static int rsl_rx_rll_err_ind(struct msgb *msg)
|
||||
|
||||
rll_indication(msg->lchan, rllh->link_id, BSC_RLLR_IND_ERR_IND);
|
||||
|
||||
if (rlm_cause[1] == RLL_CAUSE_T200_EXPIRED)
|
||||
if (rlm_cause[1] == RLL_CAUSE_T200_EXPIRED) {
|
||||
counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rll_err);
|
||||
return rsl_rf_chan_release(msg->lchan, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ line vty
|
||||
no login
|
||||
!
|
||||
nat
|
||||
msc ip 10.0.0.23
|
||||
bsc 0
|
||||
token zecke
|
||||
location_area_code 3
|
||||
|
||||
@@ -378,11 +378,11 @@ static unsigned char nanobts_attr_cell[] = {
|
||||
4, /* N3103 */
|
||||
8, /* N3105 */
|
||||
15, /* RLC CV countdown */
|
||||
NM_ATT_IPACC_CODING_SCHEMES, 0, 2, 0x0f, 0x00,
|
||||
NM_ATT_IPACC_CODING_SCHEMES, 0, 2, 0x0f, 0x00, /* CS1..CS4 */
|
||||
NM_ATT_IPACC_RLC_CFG_2, 0, 5,
|
||||
0x00, 250,
|
||||
0x00, 250,
|
||||
2, /* MCS2 */
|
||||
0x00, 250, /* T downlink TBF extension (0..500) */
|
||||
0x00, 250, /* T uplink TBF extension (0..500) */
|
||||
2, /* CS2 */
|
||||
#if 0
|
||||
/* EDGE model only, breaks older models.
|
||||
* Should inquire the BTS capabilities */
|
||||
@@ -418,16 +418,15 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
switch (obj_class) {
|
||||
case NM_OC_SITE_MANAGER:
|
||||
bts = container_of(obj, struct gsm_bts, site_mgr);
|
||||
if ((new_state->operational == 2 &&
|
||||
if ((new_state->operational == NM_OPSTATE_ENABLED &&
|
||||
new_state->availability == NM_AVSTATE_OK) ||
|
||||
(new_state->operational == 1 &&
|
||||
(new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_OFF_LINE))
|
||||
abis_nm_opstart(bts, obj_class, 0xff, 0xff, 0xff);
|
||||
break;
|
||||
case NM_OC_BTS:
|
||||
bts = obj;
|
||||
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
printf("STARTING BTS...\n");
|
||||
patch_nm_tables(bts);
|
||||
abis_nm_set_bts_attr(bts, nanobts_attr_bts,
|
||||
sizeof(nanobts_attr_bts));
|
||||
@@ -441,9 +440,8 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
case NM_OC_CHANNEL:
|
||||
ts = obj;
|
||||
trx = ts->trx;
|
||||
if (new_state->operational == 1 &&
|
||||
if (new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
printf("STARTING OC Channel...\n");
|
||||
patch_nm_tables(trx->bts);
|
||||
enum abis_nm_chan_comb ccomb =
|
||||
abis_nm_chcomb4pchan(ts->pchan);
|
||||
@@ -457,16 +455,16 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
break;
|
||||
case NM_OC_RADIO_CARRIER:
|
||||
trx = obj;
|
||||
if (new_state->operational == 1 &&
|
||||
if (new_state->operational == NM_OPSTATE_DISABLED &&
|
||||
new_state->availability == NM_AVSTATE_OK)
|
||||
abis_nm_opstart(trx->bts, obj_class, trx->bts->bts_nr,
|
||||
trx->nr, 0xff);
|
||||
break;
|
||||
case NM_OC_GPRS_NSE:
|
||||
bts = container_of(obj, struct gsm_bts, gprs.nse);
|
||||
if (!bts->gprs.enabled)
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
if (new_state->availability == 5) {
|
||||
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr,
|
||||
0xff, 0xff, nanobts_attr_nse,
|
||||
sizeof(nanobts_attr_nse));
|
||||
@@ -478,9 +476,9 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
break;
|
||||
case NM_OC_GPRS_CELL:
|
||||
bts = container_of(obj, struct gsm_bts, gprs.cell);
|
||||
if (!bts->gprs.enabled)
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
if (new_state->availability == 5) {
|
||||
if (new_state->availability == NM_AVSTATE_DEPENDENCY) {
|
||||
abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr,
|
||||
0, 0xff, nanobts_attr_cell,
|
||||
sizeof(nanobts_attr_cell));
|
||||
@@ -493,7 +491,7 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
||||
case NM_OC_GPRS_NSVC:
|
||||
nsvc = obj;
|
||||
bts = nsvc->bts;
|
||||
if (!bts->gprs.enabled)
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE)
|
||||
break;
|
||||
/* We skip NSVC1 since we only use NSVC0 */
|
||||
if (nsvc->id == 1)
|
||||
@@ -801,7 +799,7 @@ static int set_system_infos(struct gsm_bts_trx *trx)
|
||||
DEBUGP(DRR, "SI%2u: %s\n", i, hexdump(si_tmp, rc));
|
||||
rsl_bcch_info(trx, i, si_tmp, sizeof(si_tmp));
|
||||
}
|
||||
if (bts->gprs.enabled) {
|
||||
if (bts->gprs.mode != BTS_GPRS_NONE) {
|
||||
i = 13;
|
||||
rc = gsm_generate_si(si_tmp, trx->bts, RSL_SYSTEM_INFO_13);
|
||||
if (rc < 0)
|
||||
@@ -855,6 +853,22 @@ static void patch_nm_tables(struct gsm_bts *bts)
|
||||
bs11_attr_radio[2] |= arfcn_high;
|
||||
bs11_attr_radio[3] = arfcn_low;
|
||||
|
||||
/* patch the RACH attributes */
|
||||
if (bts->rach_b_thresh != -1) {
|
||||
nanobts_attr_bts[33] = bts->rach_b_thresh & 0xff;
|
||||
bs11_attr_bts[33] = bts->rach_b_thresh & 0xff;
|
||||
}
|
||||
|
||||
if (bts->rach_ldavg_slots != -1) {
|
||||
u_int8_t avg_high = bts->rach_ldavg_slots & 0xff;
|
||||
u_int8_t avg_low = (bts->rach_ldavg_slots >> 8) & 0x0f;
|
||||
|
||||
nanobts_attr_bts[35] = avg_high;
|
||||
nanobts_attr_bts[36] = avg_low;
|
||||
bs11_attr_bts[35] = avg_high;
|
||||
bs11_attr_bts[36] = avg_low;
|
||||
}
|
||||
|
||||
/* patch BSIC */
|
||||
bs11_attr_bts[1] = bts->bsic;
|
||||
nanobts_attr_bts[sizeof(nanobts_attr_bts)-11] = bts->bsic;
|
||||
@@ -888,6 +902,11 @@ static void patch_nm_tables(struct gsm_bts *bts)
|
||||
/* patch RAC */
|
||||
nanobts_attr_cell[3] = bts->gprs.rac;
|
||||
|
||||
if (bts->gprs.mode == BTS_GPRS_EGPRS) {
|
||||
/* patch EGPRS coding schemes MCS 1..9 */
|
||||
nanobts_attr_cell[29] = 0x8f;
|
||||
nanobts_attr_cell[30] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
static void bootstrap_rsl(struct gsm_bts_trx *trx)
|
||||
@@ -920,6 +939,11 @@ void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
||||
case EVT_E1_TEI_DN:
|
||||
LOGP(DMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", type, trx);
|
||||
|
||||
if (type == E1INP_SIGN_OML)
|
||||
counter_inc(trx->bts->network->stats.bts.oml_fail);
|
||||
else if (type == E1INP_SIGN_RSL)
|
||||
counter_inc(trx->bts->network->stats.bts.rsl_fail);
|
||||
|
||||
/*
|
||||
* free all allocated channels. change the nm_state so the
|
||||
* trx and trx_ts becomes unusable and chan_alloc.c can not
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* A hackish minimal BSC (+MSC +HLR) implementation */
|
||||
/* The BSC Process to handle GSM08.08 (A-Interface) */
|
||||
|
||||
/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
|
||||
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define _GNU_SOURCE
|
||||
@@ -44,6 +45,7 @@
|
||||
#include <openbsc/chan_alloc.h>
|
||||
#include <openbsc/bsc_msc.h>
|
||||
#include <openbsc/bsc_nat.h>
|
||||
#include <openbsc/bsc_msc_rf.h>
|
||||
|
||||
#include <osmocore/select.h>
|
||||
#include <osmocore/talloc.h>
|
||||
@@ -58,16 +60,27 @@
|
||||
static struct log_target *stderr_target;
|
||||
struct gsm_network *bsc_gsmnet = 0;
|
||||
static const char *config_file = "openbsc.cfg";
|
||||
static char *msc_address = "127.0.0.1";
|
||||
static struct bsc_msc_connection *msc_con;
|
||||
static char *msc_address = NULL;
|
||||
static struct in_addr local_addr;
|
||||
static LLIST_HEAD(active_connections);
|
||||
static struct write_queue mgcp_agent;
|
||||
static const char *rf_ctl = NULL;
|
||||
extern int ipacc_rtp_direct;
|
||||
|
||||
/* msc handling */
|
||||
static struct bsc_msc_connection *msc_con;
|
||||
static struct timer_list msc_ping_timeout;
|
||||
static struct timer_list msc_pong_timeout;
|
||||
|
||||
extern int bsc_bootstrap_network(int (*layer4)(struct gsm_network *, int, void *), const char *cfg_file);
|
||||
extern int bsc_shutdown_net(struct gsm_network *net);
|
||||
|
||||
|
||||
struct llist_head *bsc_sccp_connections()
|
||||
{
|
||||
return &active_connections;
|
||||
}
|
||||
|
||||
struct bss_sccp_connection_data *bss_sccp_create_data()
|
||||
{
|
||||
struct bss_sccp_connection_data *data;
|
||||
@@ -87,6 +100,7 @@ struct bss_sccp_connection_data *bss_sccp_create_data()
|
||||
void bss_sccp_free_data(struct bss_sccp_connection_data *data)
|
||||
{
|
||||
bsc_del_timer(&data->T10);
|
||||
bsc_del_timer(&data->sccp_cc_timeout);
|
||||
bsc_del_timer(&data->sccp_it);
|
||||
if (data->sccp)
|
||||
bsc_free_queued(data->sccp);
|
||||
@@ -104,6 +118,41 @@ static void sccp_it_fired(void *_data)
|
||||
bsc_schedule_timer(&data->sccp_it, SCCP_IT_TIMER, 0);
|
||||
}
|
||||
|
||||
static void bss_force_close(struct bss_sccp_connection_data *bss)
|
||||
{
|
||||
if (bss->lchan) {
|
||||
bss->lchan->msc_data = NULL;
|
||||
put_subscr_con(&bss->lchan->conn, 0);
|
||||
bss->lchan = NULL;
|
||||
}
|
||||
|
||||
if (bss->secondary_lchan) {
|
||||
bss->secondary_lchan->msc_data = NULL;
|
||||
put_subscr_con(&bss->secondary_lchan->conn, 0);
|
||||
bss->secondary_lchan = NULL;
|
||||
}
|
||||
|
||||
/* force the close by poking stuff */
|
||||
if (bss->sccp) {
|
||||
sccp_connection_force_free(bss->sccp);
|
||||
bss->sccp = NULL;
|
||||
}
|
||||
|
||||
bss_sccp_free_data(bss);
|
||||
}
|
||||
|
||||
/* check if this connection was ever confirmed and then recycle */
|
||||
static void sccp_check_cc(void *_data)
|
||||
{
|
||||
struct bss_sccp_connection_data *data = _data;
|
||||
|
||||
if (data->sccp->connection_state >= SCCP_CONNECTION_STATE_ESTABLISHED)
|
||||
return;
|
||||
|
||||
LOGP(DMSC, LOGL_ERROR, "The connection was never established\n");
|
||||
bss_force_close(data);
|
||||
}
|
||||
|
||||
|
||||
/* GSM subscriber drop-ins */
|
||||
extern struct llist_head *subscr_bsc_active_subscriber(void);
|
||||
@@ -192,8 +241,12 @@ void msc_outgoing_sccp_state(struct sccp_connection *conn, int old_state)
|
||||
|
||||
LOGP(DMSC, LOGL_DEBUG, "Connection established: %p\n", conn);
|
||||
|
||||
/* start the inactivity test timer */
|
||||
con_data = (struct bss_sccp_connection_data *) conn->data_ctx;
|
||||
|
||||
/* stop the CC timeout */
|
||||
bsc_del_timer(&con_data->sccp_cc_timeout);
|
||||
|
||||
/* start the inactivity test timer */
|
||||
con_data->sccp_it.cb = sccp_it_fired;
|
||||
con_data->sccp_it.data = con_data;
|
||||
bsc_schedule_timer(&con_data->sccp_it, SCCP_IT_TIMER, 0);
|
||||
@@ -217,7 +270,7 @@ static int open_sccp_connection(struct msgb *layer3)
|
||||
struct msgb *data;
|
||||
|
||||
/* When not connected to a MSC. We will simply close things down. */
|
||||
if (!msc_con->is_connected) {
|
||||
if (!msc_con->is_authenticated) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Not connected to a MSC. Not forwarding data.\n");
|
||||
use_subscr_con(&layer3->lchan->conn);
|
||||
put_subscr_con(&layer3->lchan->conn, 0);
|
||||
@@ -255,6 +308,11 @@ static int open_sccp_connection(struct msgb *layer3)
|
||||
sccp_connection->data_ctx = con_data;
|
||||
layer3->lchan->msc_data = con_data;
|
||||
|
||||
/* Make sure we open the connection */
|
||||
con_data->sccp_cc_timeout.data = con_data;
|
||||
con_data->sccp_cc_timeout.cb = sccp_check_cc;
|
||||
bsc_schedule_timer(&con_data->sccp_cc_timeout, 10, 0);
|
||||
|
||||
/* FIXME: Use transaction for this */
|
||||
use_subscr_con(&layer3->lchan->conn);
|
||||
sccp_connection_connect(sccp_connection, &sccp_ssn_bssap, data);
|
||||
@@ -364,7 +422,8 @@ static int handle_ass_compl(struct msgb *msg)
|
||||
old_chan->msc_data = NULL;
|
||||
|
||||
/* give up the old channel to not do a SACCH deactivate */
|
||||
subscr_put(old_chan->conn.subscr);
|
||||
if (old_chan->conn.subscr)
|
||||
subscr_put(old_chan->conn.subscr);
|
||||
old_chan->conn.subscr = NULL;
|
||||
put_subscr_con(&old_chan->conn, 1);
|
||||
|
||||
@@ -568,7 +627,7 @@ static int handle_abisip_signal(unsigned int subsys, unsigned int signal,
|
||||
|
||||
static void print_usage()
|
||||
{
|
||||
printf("Usage: bsc_hack\n");
|
||||
printf("Usage: bsc_msc_ip\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -762,18 +821,10 @@ static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data)
|
||||
*/
|
||||
static void initialize_if_needed(void)
|
||||
{
|
||||
if (!bsc_gsmnet) {
|
||||
int rc;
|
||||
struct msgb *msg;
|
||||
|
||||
fprintf(stderr, "Bootstraping the network. Sending GSM08.08 reset.\n");
|
||||
rc = bsc_bootstrap_network(NULL, config_file);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Bootstrapping the network failed. exiting.\n");
|
||||
exit(1);
|
||||
}
|
||||
struct msgb *msg;
|
||||
|
||||
|
||||
if (!msc_con->is_authenticated) {
|
||||
/* send a gsm 08.08 reset message from here */
|
||||
msg = bssmap_create_reset();
|
||||
if (!msg) {
|
||||
@@ -783,6 +834,7 @@ static void initialize_if_needed(void)
|
||||
|
||||
sccp_write(msg, &sccp_ssn_bssap, &sccp_ssn_bssap, 0);
|
||||
msgb_free(msg);
|
||||
msc_con->is_authenticated = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,30 +870,63 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc)
|
||||
LOGP(DMSC, LOGL_ERROR, "Lost MSC connection. Freing stuff.\n");
|
||||
|
||||
llist_for_each_entry_safe(bss, tmp, &active_connections, active_connections) {
|
||||
if (bss->lchan) {
|
||||
bss->lchan->msc_data = NULL;
|
||||
put_subscr_con(&bss->lchan->conn, 0);
|
||||
bss->lchan = NULL;
|
||||
}
|
||||
|
||||
if (bss->secondary_lchan) {
|
||||
bss->secondary_lchan->msc_data = NULL;
|
||||
put_subscr_con(&bss->secondary_lchan->conn, 0);
|
||||
bss->secondary_lchan = NULL;
|
||||
}
|
||||
|
||||
/* force the close by poking stuff */
|
||||
if (bss->sccp) {
|
||||
sccp_connection_force_free(bss->sccp);
|
||||
bss->sccp = NULL;
|
||||
}
|
||||
|
||||
bss_sccp_free_data(bss);
|
||||
bss_force_close(bss);
|
||||
}
|
||||
|
||||
bsc_del_timer(&msc_ping_timeout);
|
||||
bsc_del_timer(&msc_pong_timeout);
|
||||
|
||||
msc->is_authenticated = 0;
|
||||
bsc_msc_schedule_connect(msc);
|
||||
}
|
||||
|
||||
static void msc_pong_timeout_cb(void *data)
|
||||
{
|
||||
LOGP(DMSC, LOGL_ERROR, "MSC didn't answer PING. Closing connection.\n");
|
||||
bsc_msc_lost(msc_con);
|
||||
}
|
||||
|
||||
static void send_ping(void)
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
||||
msg = msgb_alloc_headroom(4096, 128, "ping");
|
||||
if (!msg) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Failed to create PING.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
msg->l2h = msgb_put(msg, 1);
|
||||
msg->l2h[0] = IPAC_MSGT_PING;
|
||||
|
||||
msc_queue_write(msg, IPAC_PROTO_IPACCESS);
|
||||
}
|
||||
|
||||
static void msc_ping_timeout_cb(void *data)
|
||||
{
|
||||
if (bsc_gsmnet->ping_timeout < 0)
|
||||
return;
|
||||
|
||||
send_ping();
|
||||
|
||||
/* send another ping in 20 seconds */
|
||||
bsc_schedule_timer(&msc_ping_timeout, bsc_gsmnet->ping_timeout, 0);
|
||||
|
||||
/* also start a pong timer */
|
||||
bsc_schedule_timer(&msc_pong_timeout, bsc_gsmnet->pong_timeout, 0);
|
||||
}
|
||||
|
||||
static void msc_connection_connected(struct bsc_msc_connection *con)
|
||||
{
|
||||
int ret, on;
|
||||
on = 1;
|
||||
ret = setsockopt(con->write_queue.bfd.fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
||||
if (ret != 0)
|
||||
LOGP(DMSC, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno));
|
||||
|
||||
msc_ping_timeout_cb(con);
|
||||
}
|
||||
|
||||
/*
|
||||
* callback with IP access data
|
||||
*/
|
||||
@@ -874,6 +959,8 @@ static int ipaccess_a_fd_cb(struct bsc_fd *bfd)
|
||||
initialize_if_needed();
|
||||
else if (msg->l2h[0] == IPAC_MSGT_ID_GET) {
|
||||
send_id_get_response(bfd->fd);
|
||||
} else if (msg->l2h[0] == IPAC_MSGT_PONG) {
|
||||
bsc_del_timer(&msc_pong_timeout);
|
||||
}
|
||||
} else if (hh->proto == IPAC_PROTO_SCCP) {
|
||||
sccp_system_incoming(msg);
|
||||
@@ -896,6 +983,7 @@ static void print_help()
|
||||
printf(" -m --msc=IP. The address of the MSC.\n");
|
||||
printf(" -l --local=IP. The local address of the MGCP.\n");
|
||||
printf(" -e --log-level number. Set a global loglevel.\n");
|
||||
printf(" -r --rf-ctl NAME. A unix domain socket to listen for cmds.\n");
|
||||
}
|
||||
|
||||
static void handle_options(int argc, char** argv)
|
||||
@@ -908,14 +996,14 @@ static void handle_options(int argc, char** argv)
|
||||
{"config-file", 1, 0, 'c'},
|
||||
{"disable-color", 0, 0, 's'},
|
||||
{"timestamp", 0, 0, 'T'},
|
||||
{"rtp-proxy", 0, 0, 'P'},
|
||||
{"msc", 1, 0, 'm'},
|
||||
{"local", 1, 0, 'l'},
|
||||
{"log-level", 1, 0, 'e'},
|
||||
{"rf-ctl", 1, 0, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hd:sTPc:m:l:e:",
|
||||
c = getopt_long(argc, argv, "hd:sTc:m:l:e:r:",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -941,7 +1029,7 @@ static void handle_options(int argc, char** argv)
|
||||
ipacc_rtp_direct = 0;
|
||||
break;
|
||||
case 'm':
|
||||
msc_address = strdup(optarg);
|
||||
msc_address = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
inet_aton(optarg, &local_addr);
|
||||
@@ -949,6 +1037,9 @@ static void handle_options(int argc, char** argv)
|
||||
case 'e':
|
||||
log_set_log_level(stderr_target, atoi(optarg));
|
||||
break;
|
||||
case 'r':
|
||||
rf_ctl = optarg;
|
||||
break;
|
||||
default:
|
||||
/* ignore */
|
||||
break;
|
||||
@@ -975,7 +1066,7 @@ static void signal_handler(int signal)
|
||||
talloc_report_full(tall_bsc_ctx, stderr);
|
||||
break;
|
||||
case SIGUSR2:
|
||||
if (!msc_con->is_connected)
|
||||
if (!msc_con || !msc_con->is_connected)
|
||||
return;
|
||||
bsc_msc_lost(msc_con);
|
||||
break;
|
||||
@@ -1030,6 +1121,9 @@ extern int bts_model_nanobts_init(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *msc;
|
||||
int rc;
|
||||
|
||||
log_init(&log_info);
|
||||
tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
|
||||
stderr_target = log_target_create_stderr();
|
||||
@@ -1048,6 +1142,12 @@ int main(int argc, char **argv)
|
||||
/* seed the PRNG */
|
||||
srand(time(NULL));
|
||||
|
||||
signal(SIGINT, &signal_handler);
|
||||
signal(SIGABRT, &signal_handler);
|
||||
signal(SIGUSR1, &signal_handler);
|
||||
signal(SIGUSR2, &signal_handler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
/* attempt to register the local mgcp forward */
|
||||
if (mgcp_create_port() != 0) {
|
||||
fprintf(stderr, "Failed to bind local MGCP port\n");
|
||||
@@ -1062,25 +1162,43 @@ int main(int argc, char **argv)
|
||||
/* initialize ipaccess handling */
|
||||
register_signal_handler(SS_ABISIP, handle_abisip_signal, NULL);
|
||||
|
||||
fprintf(stderr, "Bootstraping the network. Sending GSM08.08 reset.\n");
|
||||
rc = bsc_bootstrap_network(NULL, config_file);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Bootstrapping the network failed. exiting.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rf_ctl) {
|
||||
struct bsc_msc_rf *rf;
|
||||
rf = bsc_msc_rf_create(rf_ctl, bsc_gsmnet);
|
||||
if (!rf) {
|
||||
fprintf(stderr, "Failed to create the RF service.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* setup MSC Connection handling */
|
||||
msc_con = bsc_msc_create(msc_address, 5000);
|
||||
msc = bsc_gsmnet->msc_ip;
|
||||
if (msc_address)
|
||||
msc = msc_address;
|
||||
|
||||
msc_con = bsc_msc_create(msc, bsc_gsmnet->msc_port);
|
||||
if (!msc_con) {
|
||||
fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
msc_ping_timeout.cb = msc_ping_timeout_cb;
|
||||
msc_pong_timeout.cb = msc_pong_timeout_cb;
|
||||
|
||||
msc_con->connection_loss = msc_connection_was_lost;
|
||||
msc_con->connected = msc_connection_connected;
|
||||
msc_con->write_queue.read_cb = ipaccess_a_fd_cb;
|
||||
msc_con->write_queue.write_cb = msc_sccp_do_write;
|
||||
bsc_msc_connect(msc_con);
|
||||
|
||||
|
||||
signal(SIGINT, &signal_handler);
|
||||
signal(SIGABRT, &signal_handler);
|
||||
signal(SIGUSR1, &signal_handler);
|
||||
signal(SIGUSR2, &signal_handler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
while (1) {
|
||||
bsc_select_main(0);
|
||||
|
||||
249
openbsc/src/bsc_msc_rf.c
Normal file
249
openbsc/src/bsc_msc_rf.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/* RF Ctl handling socket */
|
||||
|
||||
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
|
||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||
* (C) 2010 by On-Waves
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openbsc/bsc_msc_rf.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/gsm_data.h>
|
||||
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/protocol/gsm_12_21.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define RF_CMD_QUERY '?'
|
||||
#define RF_CMD_OFF '0'
|
||||
#define RF_CMD_ON '1'
|
||||
|
||||
static int lock_each_trx(struct gsm_network *net, int lock)
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
|
||||
llist_for_each_entry(bts, &net->bts_list, list) {
|
||||
struct gsm_bts_trx *trx;
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
gsm_trx_lock_rf(trx, lock);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a '1' when one TRX is online, otherwise send 0
|
||||
*/
|
||||
static void handle_query(struct bsc_msc_rf_conn *conn)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct gsm_bts *bts;
|
||||
char send = '0';
|
||||
|
||||
llist_for_each_entry(bts, &conn->gsm_network->bts_list, list) {
|
||||
struct gsm_bts_trx *trx;
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
if (trx->nm_state.availability == NM_AVSTATE_OK &&
|
||||
trx->nm_state.operational != NM_STATE_LOCKED) {
|
||||
send = '1';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = msgb_alloc(10, "RF Query");
|
||||
if (!msg) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate response msg.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
msg->l2h = msgb_put(msg, 1);
|
||||
msg->l2h[0] = send;
|
||||
|
||||
if (write_queue_enqueue(&conn->queue, msg) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue the answer.\n");
|
||||
msgb_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int rf_read_cmd(struct bsc_fd *fd)
|
||||
{
|
||||
struct bsc_msc_rf_conn *conn = fd->data;
|
||||
char buf[1];
|
||||
int rc;
|
||||
|
||||
rc = read(fd->fd, buf, sizeof(buf));
|
||||
if (rc != sizeof(buf)) {
|
||||
LOGP(DINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno));
|
||||
bsc_unregister_fd(fd);
|
||||
close(fd->fd);
|
||||
write_queue_clear(&conn->queue);
|
||||
talloc_free(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (buf[0]) {
|
||||
case RF_CMD_QUERY:
|
||||
handle_query(conn);
|
||||
break;
|
||||
case RF_CMD_OFF:
|
||||
lock_each_trx(conn->gsm_network, 1);
|
||||
break;
|
||||
case RF_CMD_ON:
|
||||
lock_each_trx(conn->gsm_network, 0);
|
||||
break;
|
||||
default:
|
||||
LOGP(DINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rf_write_cmd(struct bsc_fd *fd, struct msgb *msg)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = write(fd->fd, msg->data, msg->len);
|
||||
if (rc != msg->len) {
|
||||
LOGP(DINP, LOGL_ERROR, "Short write %d/%s\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rf_ctl_accept(struct bsc_fd *bfd, unsigned int what)
|
||||
{
|
||||
struct bsc_msc_rf_conn *conn;
|
||||
struct bsc_msc_rf *rf = bfd->data;
|
||||
struct sockaddr_un addr;
|
||||
socklen_t len = sizeof(addr);
|
||||
int fd;
|
||||
|
||||
fd = accept(bfd->fd, (struct sockaddr *) &addr, &len);
|
||||
if (fd < 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to accept. errno: %d/%s\n",
|
||||
errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
conn = talloc_zero(rf, struct bsc_msc_rf_conn);
|
||||
if (!conn) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to allocate mem.\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
write_queue_init(&conn->queue, 10);
|
||||
conn->queue.bfd.data = conn;
|
||||
conn->queue.bfd.fd = fd;
|
||||
conn->queue.bfd.when = BSC_FD_READ | BSC_FD_WRITE;
|
||||
conn->queue.read_cb = rf_read_cmd;
|
||||
conn->queue.write_cb = rf_write_cmd;
|
||||
conn->gsm_network = rf->gsm_network;
|
||||
|
||||
if (bsc_register_fd(&conn->queue.bfd) != 0) {
|
||||
close(fd);
|
||||
talloc_free(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct bsc_msc_rf *bsc_msc_rf_create(const char *path, struct gsm_network *net)
|
||||
{
|
||||
unsigned int namelen;
|
||||
struct sockaddr_un local;
|
||||
struct bsc_fd *bfd;
|
||||
struct bsc_msc_rf *rf;
|
||||
int rc;
|
||||
|
||||
rf = talloc_zero(NULL, struct bsc_msc_rf);
|
||||
if (!rf) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to create bsc_msc_rf.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd = &rf->listen;
|
||||
bfd->fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (bfd->fd < 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Can not create socket. %d/%s\n",
|
||||
errno, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
local.sun_family = AF_UNIX;
|
||||
strncpy(local.sun_path, path, sizeof(local.sun_path));
|
||||
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
|
||||
unlink(local.sun_path);
|
||||
|
||||
/* we use the same magic that X11 uses in Xtranssock.c for
|
||||
* calculating the proper length of the sockaddr */
|
||||
#if defined(BSD44SOCKETS) || defined(__UNIXWARE__)
|
||||
local.sun_len = strlen(local.sun_path);
|
||||
#endif
|
||||
#if defined(BSD44SOCKETS) || defined(SUN_LEN)
|
||||
namelen = SUN_LEN(&local);
|
||||
#else
|
||||
namelen = strlen(local.sun_path) +
|
||||
offsetof(struct sockaddr_un, sun_path);
|
||||
#endif
|
||||
|
||||
rc = bind(bfd->fd, (struct sockaddr *) &local, namelen);
|
||||
if (rc != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to bind '%s' errno: %d/%s\n",
|
||||
local.sun_path, errno, strerror(errno));
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (listen(bfd->fd, 0) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to listen: %d/%s\n", errno, strerror(errno));
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd->when = BSC_FD_READ;
|
||||
bfd->cb = rf_ctl_accept;
|
||||
bfd->data = rf;
|
||||
|
||||
if (bsc_register_fd(bfd) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to register bfd.\n");
|
||||
close(bfd->fd);
|
||||
talloc_free(rf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rf->gsm_network = net;
|
||||
|
||||
return rf;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <openbsc/paging.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
|
||||
#include <osmocore/tlv.h>
|
||||
#include <osmocore/gsm0808.h>
|
||||
|
||||
#include <sccp/sccp.h>
|
||||
|
||||
@@ -40,38 +40,12 @@
|
||||
#define BSSMAP_MSG_SIZE 512
|
||||
#define BSSMAP_MSG_HEADROOM 128
|
||||
|
||||
#define LINK_ID_CB 0
|
||||
|
||||
static void bts_queue_send(struct msgb *msg, int link_id);
|
||||
static void bssmap_free_secondary(struct bss_sccp_connection_data *data);
|
||||
|
||||
|
||||
static const struct tlv_definition bss_att_tlvdef = {
|
||||
.def = {
|
||||
[GSM0808_IE_IMSI] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_TMSI] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_CELL_IDENTIFIER_LIST] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_CHANNEL_NEEDED] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_EMLPP_PRIORITY] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_CHANNEL_TYPE] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_PRIORITY] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_CIRCUIT_IDENTITY_CODE] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_DOWNLINK_DTX_FLAG] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_INTERFERENCE_BAND_TO_USE] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_CLASSMARK_INFORMATION_T2] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_GROUP_CALL_REFERENCE] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_TALKER_FLAG] = { TLV_TYPE_T },
|
||||
[GSM0808_IE_CONFIG_EVO_INDI] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_LSA_ACCESS_CTRL_SUPPR] = { TLV_TYPE_TV },
|
||||
[GSM0808_IE_SERVICE_HANDOVER] = { TLV_TYPE_TV},
|
||||
[GSM0808_IE_ENCRYPTION_INFORMATION] = { TLV_TYPE_TLV },
|
||||
[GSM0808_IE_CIPHER_RESPONSE_MODE] = { TLV_TYPE_TV },
|
||||
},
|
||||
};
|
||||
|
||||
const struct tlv_definition *gsm0808_att_tlvdef()
|
||||
{
|
||||
return &bss_att_tlvdef;
|
||||
}
|
||||
|
||||
static u_int16_t get_network_code_for_msc(struct gsm_network *net)
|
||||
{
|
||||
if (net->core_network_code > 0)
|
||||
@@ -88,7 +62,7 @@ static u_int16_t get_country_code_for_msc(struct gsm_network *net)
|
||||
|
||||
static int bssmap_paging_cb(unsigned int hooknum, unsigned int event, struct msgb *msg, void *data, void *param)
|
||||
{
|
||||
LOGP(DMSC, LOGL_DEBUG, "Paging is complete.\n");
|
||||
LOGP(DPAG, LOGL_DEBUG, "Paging is complete.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -112,7 +86,7 @@ static int bssmap_handle_paging(struct gsm_network *net, struct msgb *msg, unsig
|
||||
u_int8_t chan_needed = RSL_CHANNEED_ANY;
|
||||
int paged;
|
||||
|
||||
tlv_parse(&tp, &bss_att_tlvdef, msg->l4h + 1, payload_length - 1, 0, 0);
|
||||
tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, payload_length - 1, 0, 0);
|
||||
|
||||
if (!TLVP_PRESENT(&tp, GSM0808_IE_IMSI)) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Mandantory IMSI not present.\n");
|
||||
@@ -173,7 +147,7 @@ static int bssmap_handle_paging(struct gsm_network *net, struct msgb *msg, unsig
|
||||
subscr->tmsi = tmsi;
|
||||
subscr->lac = lac;
|
||||
paged = paging_request(net, subscr, chan_needed, bssmap_paging_cb, subscr);
|
||||
LOGP(DMSC, LOGL_DEBUG, "Paged IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x on #bts: %d\n", mi_string, tmsi, tmsi, lac, paged);
|
||||
LOGP(DPAG, LOGL_DEBUG, "Paged IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x on #bts: %d\n", mi_string, tmsi, tmsi, lac, paged);
|
||||
|
||||
subscr_put(subscr);
|
||||
return -1;
|
||||
@@ -242,7 +216,7 @@ static int bssmap_handle_cipher_mode(struct sccp_connection *conn,
|
||||
msg->lchan->msc_data->ciphering_handled = 1;
|
||||
msg->lchan->msc_data->block_gsm = 1;
|
||||
|
||||
tlv_parse(&tp, &bss_att_tlvdef, msg->l4h + 1, payload_length - 1, 0, 0);
|
||||
tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, payload_length - 1, 0, 0);
|
||||
if (!TLVP_PRESENT(&tp, GSM0808_IE_ENCRYPTION_INFORMATION)) {
|
||||
LOGP(DMSC, LOGL_ERROR, "IE Encryption Information missing.\n");
|
||||
goto reject;
|
||||
@@ -317,7 +291,8 @@ static void bssmap_free_secondary(struct bss_sccp_connection_data *data)
|
||||
lchan->msc_data = NULL;
|
||||
|
||||
/* give up the new channel to not do a SACCH deactivate */
|
||||
subscr_put(lchan->conn.subscr);
|
||||
if (lchan->conn.subscr)
|
||||
subscr_put(lchan->conn.subscr);
|
||||
lchan->conn.subscr = NULL;
|
||||
put_subscr_con(&lchan->conn, 1);
|
||||
}
|
||||
@@ -431,7 +406,7 @@ static int handle_new_assignment(struct msgb *msg, int full_rate, int chan_mode)
|
||||
bts = msg->lchan->ts->trx->bts;
|
||||
chan_type = full_rate ? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H;
|
||||
|
||||
new_lchan = lchan_alloc(bts, chan_type);
|
||||
new_lchan = lchan_alloc(bts, chan_type, 0);
|
||||
|
||||
if (!new_lchan) {
|
||||
LOGP(DMSC, LOGL_NOTICE, "No free channel.\n");
|
||||
@@ -442,7 +417,8 @@ static int handle_new_assignment(struct msgb *msg, int full_rate, int chan_mode)
|
||||
memcpy(&new_lchan->encr, &msg->lchan->encr, sizeof(new_lchan->encr));
|
||||
new_lchan->ms_power = msg->lchan->ms_power;
|
||||
new_lchan->bs_power = msg->lchan->bs_power;
|
||||
new_lchan->conn.subscr = subscr_get(msg->lchan->conn.subscr);
|
||||
if (msg->lchan->conn.subscr)
|
||||
new_lchan->conn.subscr = subscr_get(msg->lchan->conn.subscr);
|
||||
|
||||
/* copy new data to it */
|
||||
use_subscr_con(&new_lchan->conn);
|
||||
@@ -515,7 +491,7 @@ static int bssmap_handle_assignm_req(struct sccp_connection *conn,
|
||||
|
||||
msc_data = msg->lchan->msc_data;
|
||||
network = msg->lchan->ts->trx->bts->network;
|
||||
tlv_parse(&tp, &bss_att_tlvdef, msg->l4h + 1, length - 1, 0, 0);
|
||||
tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l4h + 1, length - 1, 0, 0);
|
||||
|
||||
if (!TLVP_PRESENT(&tp, GSM0808_IE_CHANNEL_TYPE)) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Mandantory channel type not present.\n");
|
||||
@@ -1262,7 +1238,7 @@ static void bts_queue_send(struct msgb *msg, int link_id)
|
||||
if (msg->lchan->sapis[link_id & 0x7] != LCHAN_SAPI_UNUSED) {
|
||||
rsl_data_request(msg, link_id);
|
||||
} else {
|
||||
msg->smsh = (unsigned char*) link_id;
|
||||
msg->cb[LINK_ID_CB] = link_id;
|
||||
msgb_enqueue(&data->gsm_queue, msg);
|
||||
++data->gsm_queue_size;
|
||||
|
||||
@@ -1278,7 +1254,7 @@ static void bts_queue_send(struct msgb *msg, int link_id)
|
||||
LOGP(DMSC, LOGL_DEBUG, "Queueing GSM0408 message on %p. Queue size: %d\n",
|
||||
data->sccp, data->gsm_queue_size + 1);
|
||||
|
||||
msg->smsh = (unsigned char*) link_id;
|
||||
msg->cb[LINK_ID_CB] = link_id;
|
||||
msgb_enqueue(&data->gsm_queue, msg);
|
||||
++data->gsm_queue_size;
|
||||
}
|
||||
@@ -1304,7 +1280,7 @@ void bts_send_queued(struct bss_sccp_connection_data *data)
|
||||
while (!llist_empty(&data->gsm_queue)) {
|
||||
/* this is not allowed to fail */
|
||||
msg = msgb_dequeue(&data->gsm_queue);
|
||||
rsl_data_request(msg, (int) msg->smsh);
|
||||
rsl_data_request(msg, msg->cb[LINK_ID_CB]);
|
||||
}
|
||||
|
||||
data->gsm_queue_size = 0;
|
||||
@@ -1326,7 +1302,7 @@ void bts_unblock_queue(struct bss_sccp_connection_data *data)
|
||||
/* now queue them again to send RSL establish and such */
|
||||
while (!llist_empty(&head)) {
|
||||
msg = msgb_dequeue(&head);
|
||||
bts_queue_send(msg, (int) msg->smsh);
|
||||
bts_queue_send(msg, msg->cb[LINK_ID_CB]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,8 @@ _lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan)
|
||||
}
|
||||
|
||||
/* Allocate a logical channel */
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
|
||||
struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
|
||||
int allow_bigger)
|
||||
{
|
||||
struct gsm_lchan *lchan = NULL;
|
||||
enum gsm_phys_chan_config first, second;
|
||||
@@ -241,6 +242,19 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
|
||||
lchan = _lc_find_bts(bts, first);
|
||||
if (lchan == NULL)
|
||||
lchan = _lc_find_bts(bts, second);
|
||||
|
||||
/* allow to assign bigger channels */
|
||||
if (allow_bigger) {
|
||||
if (lchan == NULL) {
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H);
|
||||
type = GSM_LCHAN_TCH_H;
|
||||
}
|
||||
|
||||
if (lchan == NULL) {
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
|
||||
type = GSM_LCHAN_TCH_F;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GSM_LCHAN_TCH_F:
|
||||
lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
|
||||
@@ -375,6 +389,7 @@ static void _lchan_handle_release(struct gsm_lchan *lchan)
|
||||
lchan->conn.use_count);
|
||||
|
||||
rsl_release_request(lchan, 0, lchan->release_reason);
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ);
|
||||
}
|
||||
|
||||
/* called from abis rsl */
|
||||
|
||||
@@ -303,6 +303,10 @@ int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
|
||||
|
||||
switch (type) {
|
||||
case E1INP_TS_TYPE_SIGN:
|
||||
if (line->driver)
|
||||
ts->sign.delay = line->driver->default_delay;
|
||||
else
|
||||
ts->sign.delay = 100000;
|
||||
INIT_LLIST_HEAD(&ts->sign.sign_links);
|
||||
break;
|
||||
case E1INP_TS_TYPE_TRAU:
|
||||
|
||||
@@ -675,7 +675,7 @@ static int gsm411_rx_rp_ud(struct msgb *msg, struct gsm_trans *trans,
|
||||
GSM411_RP_CAUSE_INV_MAND_INF);
|
||||
return -EIO;
|
||||
}
|
||||
msg->smsh = tpdu;
|
||||
msg->l4h = tpdu;
|
||||
|
||||
DEBUGP(DSMS, "DST(%u,%s)\n", dst_len, hexdump(dst, dst_len));
|
||||
|
||||
|
||||
@@ -257,7 +257,6 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_t
|
||||
if (((strlen(response_text) * 7) % 8) != 0)
|
||||
response_len += 1;
|
||||
|
||||
msg->bts_link = in_msg->bts_link;
|
||||
msg->lchan = in_msg->lchan;
|
||||
|
||||
/* First put the payload text into the message */
|
||||
@@ -304,7 +303,6 @@ int gsm0480_send_ussd_reject(const struct msgb *in_msg,
|
||||
struct msgb *msg = gsm48_msgb_alloc();
|
||||
struct gsm48_hdr *gh;
|
||||
|
||||
msg->bts_link = in_msg->bts_link;
|
||||
msg->lchan = in_msg->lchan;
|
||||
|
||||
/* First insert the problem code */
|
||||
|
||||
@@ -222,6 +222,10 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
|
||||
}
|
||||
bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4;
|
||||
|
||||
bts->paging.free_chans_need = -1;
|
||||
bts->rach_b_thresh = -1;
|
||||
bts->rach_ldavg_slots = -1;
|
||||
|
||||
llist_add_tail(&bts->list, &net->bts_list);
|
||||
|
||||
return bts;
|
||||
@@ -281,6 +285,10 @@ struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_c
|
||||
net->stats.call.dialled = counter_alloc("net.call.dialled");
|
||||
net->stats.call.alerted = counter_alloc("net.call.alerted");
|
||||
net->stats.call.connected = counter_alloc("net.call.connected");
|
||||
net->stats.chan.rf_fail = counter_alloc("net.chan.rf_fail");
|
||||
net->stats.chan.rll_err = counter_alloc("net.chan.rll_err");
|
||||
net->stats.bts.oml_fail = counter_alloc("net.bts.oml_fail");
|
||||
net->stats.bts.rsl_fail = counter_alloc("net.bts.rsl_fail");
|
||||
|
||||
net->mncc_recv = mncc_recv;
|
||||
|
||||
@@ -290,6 +298,11 @@ struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_c
|
||||
net->core_network_code = -1;
|
||||
net->rtp_base_port = 4000;
|
||||
|
||||
net->msc_ip = talloc_strdup(net, "127.0.0.1");
|
||||
net->msc_port = 5000;
|
||||
net->ping_timeout = 20;
|
||||
net->pong_timeout = 5;
|
||||
|
||||
return net;
|
||||
}
|
||||
|
||||
@@ -443,33 +456,6 @@ const char *gsm_auth_policy_name(enum gsm_auth_policy policy)
|
||||
return get_value_string(auth_policy_names, policy);
|
||||
}
|
||||
|
||||
/* this should not be here but in gsm_04_08... but that creates
|
||||
in turn a dependency nightmare (abis_nm depending on 04_08, ...) */
|
||||
static int gsm48_construct_ra(u_int8_t *buf, const struct gprs_ra_id *raid)
|
||||
{
|
||||
u_int16_t mcc = raid->mcc;
|
||||
u_int16_t mnc = raid->mnc;
|
||||
|
||||
buf[0] = ((mcc / 100) % 10) | (((mcc / 10) % 10) << 4);
|
||||
buf[1] = (mcc % 10);
|
||||
|
||||
/* I wonder who came up with the stupidity of encoding the MNC
|
||||
* differently depending on how many digits its decimal number has! */
|
||||
if (mnc < 100) {
|
||||
buf[1] |= 0xf0;
|
||||
buf[2] = ((mnc / 10) % 10) | ((mnc % 10) << 4);
|
||||
} else {
|
||||
buf[1] |= (mnc % 10) << 4;
|
||||
buf[2] = ((mnc / 100) % 10) | (((mcc / 10) % 10) << 4);
|
||||
}
|
||||
|
||||
*(u_int16_t *)(buf+3) = htons(raid->lac);
|
||||
|
||||
buf[5] = raid->rac;
|
||||
|
||||
return 6;
|
||||
}
|
||||
|
||||
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
|
||||
{
|
||||
raid->mcc = bts->network->country_code;
|
||||
@@ -505,6 +491,23 @@ const char *rrlp_mode_name(enum rrlp_mode mode)
|
||||
return get_value_string(rrlp_mode_names, mode);
|
||||
}
|
||||
|
||||
static const struct value_string bts_gprs_mode_names[] = {
|
||||
{ BTS_GPRS_NONE, "none" },
|
||||
{ BTS_GPRS_GPRS, "gprs" },
|
||||
{ BTS_GPRS_EGPRS, "egprs" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
enum bts_gprs_mode bts_gprs_mode_parse(const char *arg)
|
||||
{
|
||||
return get_string_value(bts_gprs_mode_names, arg);
|
||||
}
|
||||
|
||||
const char *bts_gprs_mode_name(enum bts_gprs_mode mode)
|
||||
{
|
||||
return get_value_string(bts_gprs_mode_names, mode);
|
||||
}
|
||||
|
||||
struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan)
|
||||
{
|
||||
struct gsm_meas_rep *meas_rep;
|
||||
|
||||
@@ -99,7 +99,7 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts)
|
||||
|
||||
counter_inc(bts->network->stats.handover.attempted);
|
||||
|
||||
new_lchan = lchan_alloc(bts, old_lchan->type);
|
||||
new_lchan = lchan_alloc(bts, old_lchan->type, 0);
|
||||
if (!new_lchan) {
|
||||
LOGP(DHO, LOGL_NOTICE, "No free channel\n");
|
||||
counter_inc(bts->network->stats.handover.no_channel);
|
||||
@@ -230,7 +230,7 @@ static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan)
|
||||
/* update lchan pointer of transaction */
|
||||
trans_lchan_change(&ho->old_lchan->conn, &new_lchan->conn);
|
||||
|
||||
ho->old_lchan->state = LCHAN_S_INACTIVE;
|
||||
rsl_lchan_set_state(ho->old_lchan, LCHAN_S_INACTIVE);
|
||||
|
||||
/* do something to re-route the actual speech frames ! */
|
||||
|
||||
|
||||
@@ -265,6 +265,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
|
||||
trx->rsl_link = e1inp_sign_link_create(e1i_ts,
|
||||
E1INP_SIGN_RSL, trx,
|
||||
trx->rsl_tei, 0);
|
||||
trx->rsl_link->ts->sign.delay = 10;
|
||||
|
||||
/* get rid of our old temporary bfd */
|
||||
memcpy(newbfd, bfd, sizeof(*newbfd));
|
||||
@@ -572,7 +573,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
|
||||
e1i_ts->sign.tx_timer.data = e1i_ts;
|
||||
|
||||
/* Reducing this might break the nanoBTS 900 init. */
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 100000);
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -606,6 +607,7 @@ static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
struct e1inp_driver ipaccess_driver = {
|
||||
.name = "ip.access",
|
||||
.want_write = ts_want_write,
|
||||
.default_delay = 100000,
|
||||
};
|
||||
|
||||
/* callback of the OML listening filedescriptor */
|
||||
|
||||
@@ -235,7 +235,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
|
||||
/* set tx delay timer for next event */
|
||||
e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
|
||||
e1i_ts->sign.tx_timer.data = e1i_ts;
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 50000);
|
||||
bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -375,6 +375,7 @@ static int activate_bchan(struct e1inp_line *line, int ts, int act)
|
||||
struct e1inp_driver misdn_driver = {
|
||||
.name = "mISDNuser",
|
||||
.want_write = ts_want_write,
|
||||
.default_delay = 50000,
|
||||
};
|
||||
|
||||
static int mi_e1_setup(struct e1inp_line *line, int release_l2)
|
||||
|
||||
@@ -59,6 +59,7 @@ static int sw_load_state = 0;
|
||||
static int oml_state = 0;
|
||||
static int dump_files = 0;
|
||||
static char *firmware_analysis = NULL;
|
||||
static int trx_nr = 0;
|
||||
|
||||
struct sw_load {
|
||||
u_int8_t file_id[255];
|
||||
@@ -316,7 +317,8 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||
memcpy(buf+3, unit_id, len);
|
||||
buf[3+len] = 0;
|
||||
printf("setting Unit ID to '%s'\n", unit_id);
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, buf, 3+len+1);
|
||||
abis_nm_ipaccess_set_nvattr(gsm_bts_trx_by_nr(bts, trx_nr),
|
||||
buf, 3+len+1);
|
||||
}
|
||||
if (prim_oml_ip) {
|
||||
struct in_addr ia;
|
||||
@@ -354,7 +356,8 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||
*cur++ = nv_mask >> 8;
|
||||
printf("setting NV Flags/Mask to 0x%04x/0x%04x\n",
|
||||
nv_flags, nv_mask);
|
||||
abis_nm_ipaccess_set_nvattr(bts->c0, buf, 3+len);
|
||||
abis_nm_ipaccess_set_nvattr(gsm_bts_trx_by_nr(bts, trx_nr),
|
||||
buf, 3+len);
|
||||
}
|
||||
|
||||
if (restart && !prim_oml_ip && !software) {
|
||||
@@ -605,6 +608,7 @@ static void print_help(void)
|
||||
printf(" -d --software firmware\n");
|
||||
printf(" -f --firmware firmware Provide firmware information\n");
|
||||
printf(" -w --write-firmware. This will dump the firmware parts to the filesystem. Use with -f.\n");
|
||||
printf(" -t --trx NR. The TRX to use for the Unit ID and NVRAM attributes.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@@ -639,9 +643,11 @@ int main(int argc, char **argv)
|
||||
{ "software", 1, 0, 'd' },
|
||||
{ "firmware", 1, 0, 'f' },
|
||||
{ "write-firmware", 0, 0, 'w' },
|
||||
{ "trx", 1, 0, 't' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "u:o:rn:l:hs:d:f:w", long_options,
|
||||
c = getopt_long(argc, argv, "u:o:rn:l:hs:d:f:wt:", long_options,
|
||||
&option_index);
|
||||
|
||||
if (c == -1)
|
||||
@@ -683,6 +689,9 @@ int main(int argc, char **argv)
|
||||
case 'w':
|
||||
dump_files = 1;
|
||||
break;
|
||||
case 't':
|
||||
trx_nr = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
print_usage();
|
||||
print_help();
|
||||
@@ -724,6 +733,8 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bts->oml_link->ts->sign.delay = 10;
|
||||
bts->c0->rsl_link->ts->sign.delay = 10;
|
||||
while (1) {
|
||||
rc = bsc_select_main(0);
|
||||
if (rc < 0)
|
||||
|
||||
@@ -128,6 +128,15 @@ static int mgcp_rsip_cb(struct mgcp_config *cfg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mgcp_change_cb(struct mgcp_config *cfg, int endpoint, int state, int local_rtp)
|
||||
{
|
||||
if (state != MGCP_ENDP_MDCX)
|
||||
return 0;
|
||||
|
||||
mgcp_send_dummy(&cfg->endpoints[endpoint]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_call_agent(struct bsc_fd *fd, unsigned int what)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
@@ -200,6 +209,7 @@ int main(int argc, char** argv)
|
||||
|
||||
/* set some callbacks */
|
||||
cfg->reset_cb = mgcp_rsip_cb;
|
||||
cfg->change_cb = mgcp_change_cb;
|
||||
|
||||
/* we need to bind a socket */
|
||||
if (rc == 0) {
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/select.h>
|
||||
|
||||
#include <openbsc/debug.h>
|
||||
@@ -73,6 +72,8 @@ enum {
|
||||
PROTO_RTCP,
|
||||
};
|
||||
|
||||
#define DUMMY_LOAD 0x23
|
||||
|
||||
|
||||
static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
|
||||
{
|
||||
@@ -84,6 +85,14 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
|
||||
return sendto(fd, buf, len, 0, (struct sockaddr *)&out, sizeof(out));
|
||||
}
|
||||
|
||||
int mgcp_send_dummy(struct mgcp_endpoint *endp)
|
||||
{
|
||||
static char buf[] = { DUMMY_LOAD };
|
||||
|
||||
return udp_send(endp->local_rtp.fd, &endp->remote,
|
||||
endp->net_rtp, buf, 1);
|
||||
}
|
||||
|
||||
static void patch_payload(int payload, char *data, int len)
|
||||
{
|
||||
struct rtp_hdr *rtp_hdr;
|
||||
@@ -163,9 +172,17 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Found BTS for endpoint: 0x%x on port: %d/%d of %s\n",
|
||||
ENDPOINT_NUMBER(endp), ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
|
||||
inet_ntoa(addr.sin_addr));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* throw away dummy message */
|
||||
if (rc == 1 && buf[0] == DUMMY_LOAD) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* do this before the loop handling */
|
||||
if (dest == DEST_NETWORK)
|
||||
++endp->in_bts;
|
||||
|
||||
@@ -389,6 +389,7 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
if (cfg->force_realloc) {
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Endpoint 0x%x already allocated. Forcing realloc.\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
mgcp_free_endp(endp);
|
||||
} else {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Endpoint is already used. 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
@@ -485,6 +486,7 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *trans_id;
|
||||
struct mgcp_endpoint *endp;
|
||||
int error_code = 500;
|
||||
int silent = 0;
|
||||
|
||||
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
|
||||
if (found != 0)
|
||||
@@ -517,6 +519,9 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
goto error3;
|
||||
}
|
||||
break;
|
||||
case 'Z':
|
||||
silent = strcmp("noanswer", (const char *)&msg->l3h[line_start + 3]) == 0;
|
||||
break;
|
||||
case '\0':
|
||||
/* SDP file begins */
|
||||
break;
|
||||
@@ -562,6 +567,8 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
case MGCP_POLICY_REJECT:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "MDCX rejected by policy on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(500, "MDCX", trans_id);
|
||||
break;
|
||||
case MGCP_POLICY_DEFER:
|
||||
@@ -579,6 +586,9 @@ static struct msgb *handle_modify_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
ENDPOINT_NUMBER(endp), inet_ntoa(endp->remote), ntohs(endp->net_rtp));
|
||||
if (cfg->change_cb)
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX, endp->rtp_port);
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
|
||||
return create_response_with_sdp(endp, "MDCX", trans_id);
|
||||
|
||||
error:
|
||||
@@ -589,6 +599,10 @@ error:
|
||||
|
||||
error3:
|
||||
return create_response(error_code, "MDCX", trans_id);
|
||||
|
||||
|
||||
out_silent:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
@@ -598,6 +612,7 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
const char *trans_id;
|
||||
struct mgcp_endpoint *endp;
|
||||
int error_code = 500;
|
||||
int silent = 0;
|
||||
|
||||
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
|
||||
if (found != 0)
|
||||
@@ -619,6 +634,9 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
if (verify_ci(endp, (const char *)&msg->l3h[line_start + 3]) != 0)
|
||||
goto error3;
|
||||
break;
|
||||
case 'Z':
|
||||
silent = strcmp("noanswer", (const char *)&msg->l3h[line_start + 3]) == 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Unhandled option: '%c'/%d on 0x%x\n",
|
||||
@@ -634,6 +652,8 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
case MGCP_POLICY_REJECT:
|
||||
LOGP(DMGCP, LOGL_NOTICE, "DLCX rejected by policy on 0x%x\n",
|
||||
ENDPOINT_NUMBER(endp));
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(500, "DLCX", trans_id);
|
||||
break;
|
||||
case MGCP_POLICY_DEFER:
|
||||
@@ -647,10 +667,14 @@ static struct msgb *handle_delete_con(struct mgcp_config *cfg, struct msgb *msg)
|
||||
}
|
||||
|
||||
/* free the connection */
|
||||
LOGP(DMGCP, LOGL_NOTICE, "Deleted endpoint on: 0x%x Server: %s:%u\n",
|
||||
ENDPOINT_NUMBER(endp), inet_ntoa(endp->remote), ntohs(endp->net_rtp));
|
||||
mgcp_free_endp(endp);
|
||||
if (cfg->change_cb)
|
||||
cfg->change_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX, endp->rtp_port);
|
||||
|
||||
if (silent)
|
||||
goto out_silent;
|
||||
return create_response(250, "DLCX", trans_id);
|
||||
|
||||
error:
|
||||
@@ -661,6 +685,9 @@ error:
|
||||
|
||||
error3:
|
||||
return create_response(error_code, "DLCX", trans_id);
|
||||
|
||||
out_silent:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg)
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <vty/command.h>
|
||||
#include <vty/vty.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static struct mgcp_config *g_cfg = NULL;
|
||||
|
||||
/*
|
||||
@@ -48,23 +50,25 @@ static int config_write_mgcp(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, "mgcp%s", VTY_NEWLINE);
|
||||
if (g_cfg->local_ip)
|
||||
vty_out(vty, " local ip %s%s", g_cfg->local_ip, VTY_NEWLINE);
|
||||
if (g_cfg->bts_ip)
|
||||
vty_out(vty, " local ip %s%s", g_cfg->local_ip, VTY_NEWLINE);
|
||||
if (g_cfg->bts_ip && strlen(g_cfg->bts_ip) != 0)
|
||||
vty_out(vty, " bts ip %s%s", g_cfg->bts_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE);
|
||||
vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE);
|
||||
vty_out(vty, " bind early %u%s", !!g_cfg->early_bind, VTY_NEWLINE);
|
||||
vty_out(vty, " rtp base %u%s", g_cfg->rtp_base_port, VTY_NEWLINE);
|
||||
vty_out(vty, " sdp audio payload number %u%s", g_cfg->audio_payload, VTY_NEWLINE);
|
||||
vty_out(vty, " sdp audio payload name %s%s", g_cfg->audio_name, VTY_NEWLINE);
|
||||
if (g_cfg->audio_payload != -1)
|
||||
vty_out(vty, " sdp audio payload number %d%s", g_cfg->audio_payload, VTY_NEWLINE);
|
||||
if (g_cfg->audio_name)
|
||||
vty_out(vty, " sdp audio payload name %s%s", g_cfg->audio_name, VTY_NEWLINE);
|
||||
vty_out(vty, " loop %u%s", !!g_cfg->audio_loop, VTY_NEWLINE);
|
||||
vty_out(vty, " endpoints %u%s", g_cfg->number_endpoints, VTY_NEWLINE);
|
||||
vty_out(vty, " number endpoints %u%s", g_cfg->number_endpoints - 1, VTY_NEWLINE);
|
||||
if (g_cfg->forward_ip)
|
||||
vty_out(vty, " forward audio ip %s%s", g_cfg->forward_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " forward audio ip %s%s", g_cfg->forward_ip, VTY_NEWLINE);
|
||||
if (g_cfg->forward_port != 0)
|
||||
vty_out(vty, " forward audio port %d%s", g_cfg->forward_port, VTY_NEWLINE);
|
||||
vty_out(vty, " forward audio port %d%s", g_cfg->forward_port, VTY_NEWLINE);
|
||||
if (g_cfg->call_agent_addr)
|
||||
vty_out(vty, " call agent ip %s%s", g_cfg->call_agent_addr, VTY_NEWLINE);
|
||||
vty_out(vty, " call agent ip %s%s", g_cfg->call_agent_addr, VTY_NEWLINE);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
#include <openbsc/mgcp.h>
|
||||
#include <openbsc/mgcp_internal.h>
|
||||
|
||||
#include <sccp/sccp.h>
|
||||
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/gsm0808.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -36,10 +39,12 @@
|
||||
|
||||
int bsc_mgcp_assign(struct sccp_connections *con, struct msgb *msg)
|
||||
{
|
||||
struct sccp_connections *mcon;
|
||||
struct tlv_parsed tp;
|
||||
u_int16_t cic;
|
||||
u_int8_t timeslot;
|
||||
u_int8_t multiplex;
|
||||
int combined;
|
||||
|
||||
if (!msg->l3h) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Assignment message should have l3h pointer.\n");
|
||||
@@ -61,18 +66,27 @@ int bsc_mgcp_assign(struct sccp_connections *con, struct msgb *msg)
|
||||
timeslot = cic & 0x1f;
|
||||
multiplex = (cic & ~0x1f) >> 5;
|
||||
|
||||
con->msc_timeslot = (32 * multiplex) + timeslot;
|
||||
|
||||
combined = (32 * multiplex) + timeslot;
|
||||
|
||||
/* find stale connections using that endpoint */
|
||||
llist_for_each_entry(mcon, &con->bsc->nat->sccp_connections, list_entry) {
|
||||
if (mcon->msc_timeslot == combined) {
|
||||
LOGP(DNAT, LOGL_ERROR,
|
||||
"Timeslot %d was assigned to 0x%x and now 0x%x\n",
|
||||
combined,
|
||||
sccp_src_ref_to_int(&mcon->patched_ref),
|
||||
sccp_src_ref_to_int(&con->patched_ref));
|
||||
bsc_mgcp_dlcx(mcon);
|
||||
}
|
||||
}
|
||||
|
||||
con->msc_timeslot = combined;
|
||||
con->bsc_timeslot = con->msc_timeslot;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bsc_mgcp_clear(struct sccp_connections *con)
|
||||
{
|
||||
con->msc_timeslot = -1;
|
||||
con->bsc_timeslot = -1;
|
||||
}
|
||||
|
||||
void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int i)
|
||||
static void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int i)
|
||||
{
|
||||
if (nat->bsc_endpoints[i].transaction_id) {
|
||||
talloc_free(nat->bsc_endpoints[i].transaction_id);
|
||||
@@ -80,19 +94,78 @@ void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int i)
|
||||
}
|
||||
|
||||
nat->bsc_endpoints[i].bsc = NULL;
|
||||
mgcp_free_endp(&nat->mgcp_cfg->endpoints[i]);
|
||||
}
|
||||
|
||||
void bsc_mgcp_free_endpoints(struct bsc_nat *nat)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < nat->mgcp_cfg->number_endpoints; ++i)
|
||||
for (i = 1; i < nat->mgcp_cfg->number_endpoints; ++i){
|
||||
bsc_mgcp_free_endpoint(nat, i);
|
||||
mgcp_free_endp(&nat->mgcp_cfg->endpoints[i]);
|
||||
}
|
||||
}
|
||||
|
||||
struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
||||
/* send a MDCX where we do not want a response */
|
||||
static void bsc_mgcp_send_mdcx(struct bsc_connection *bsc, struct mgcp_endpoint *endp)
|
||||
{
|
||||
char buf[2096];
|
||||
int len;
|
||||
|
||||
len = snprintf(buf, sizeof(buf),
|
||||
"MDCX 23 %x@mgw MGCP 1.0\r\n"
|
||||
"Z: noanswer\r\n"
|
||||
"\r\n"
|
||||
"c=IN IP4 %s\r\n"
|
||||
"m=audio %d RTP/AVP 255\r\n",
|
||||
ENDPOINT_NUMBER(endp),
|
||||
bsc->nat->mgcp_cfg->source_addr,
|
||||
endp->rtp_port);
|
||||
if (len < 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "snprintf for DLCX failed.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void bsc_mgcp_send_dlcx(struct bsc_connection *bsc, int endpoint)
|
||||
{
|
||||
char buf[2096];
|
||||
int len;
|
||||
|
||||
len = snprintf(buf, sizeof(buf),
|
||||
"DLCX 23 %x@mgw MGCP 1.0\r\n"
|
||||
"Z: noanswer\r\n", endpoint);
|
||||
if (len < 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "snprintf for DLCX failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bsc_write_mgcp(bsc, (u_int8_t *) buf, len);
|
||||
}
|
||||
|
||||
void bsc_mgcp_init(struct sccp_connections *con)
|
||||
{
|
||||
con->msc_timeslot = -1;
|
||||
con->bsc_timeslot = -1;
|
||||
con->crcx = 0;
|
||||
}
|
||||
|
||||
void bsc_mgcp_dlcx(struct sccp_connections *con)
|
||||
{
|
||||
/* send a DLCX down the stream */
|
||||
if (con->bsc_timeslot != -1 && con->crcx) {
|
||||
int endp = mgcp_timeslot_to_endpoint(0, con->msc_timeslot);
|
||||
bsc_mgcp_send_dlcx(con->bsc, endp);
|
||||
bsc_mgcp_free_endpoint(con->bsc->nat, endp);
|
||||
}
|
||||
|
||||
bsc_mgcp_init(con);
|
||||
}
|
||||
|
||||
|
||||
struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
||||
{
|
||||
struct sccp_connections *con = NULL;
|
||||
struct sccp_connections *sccp;
|
||||
|
||||
llist_for_each_entry(sccp, &nat->sccp_connections, list_entry) {
|
||||
@@ -101,9 +174,12 @@ struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
|
||||
if (mgcp_timeslot_to_endpoint(0, sccp->msc_timeslot) != endpoint)
|
||||
continue;
|
||||
|
||||
return sccp->bsc;
|
||||
con = sccp;
|
||||
}
|
||||
|
||||
if (con)
|
||||
return con;
|
||||
|
||||
LOGP(DMGCP, LOGL_ERROR, "Failed to find the connection.\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -112,7 +188,7 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||
{
|
||||
struct bsc_nat *nat;
|
||||
struct bsc_endpoint *bsc_endp;
|
||||
struct bsc_connection *bsc_con;
|
||||
struct sccp_connections *sccp;
|
||||
struct mgcp_endpoint *mgcp_endp;
|
||||
struct msgb *bsc_msg;
|
||||
|
||||
@@ -120,10 +196,18 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||
bsc_endp = &nat->bsc_endpoints[endpoint];
|
||||
mgcp_endp = &nat->mgcp_cfg->endpoints[endpoint];
|
||||
|
||||
bsc_con = bsc_mgcp_find_con(nat, endpoint);
|
||||
if (bsc_endp->transaction_id) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Endpoint 0x%x had pending transaction: '%s'\n",
|
||||
endpoint, bsc_endp->transaction_id);
|
||||
talloc_free(bsc_endp->transaction_id);
|
||||
bsc_endp->transaction_id = NULL;
|
||||
}
|
||||
bsc_endp->bsc = NULL;
|
||||
|
||||
if (!bsc_con) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Did not find BSC for a new connection on 0x%x for %d\n", endpoint, state);
|
||||
sccp = bsc_mgcp_find_con(nat, endpoint);
|
||||
|
||||
if (!sccp) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Did not find BSC for change on endpoint: 0x%x state: %d\n", endpoint, state);
|
||||
|
||||
switch (state) {
|
||||
case MGCP_ENDP_CRCX:
|
||||
@@ -142,12 +226,6 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||
}
|
||||
}
|
||||
|
||||
if (bsc_endp->transaction_id) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "One transaction with id '%s' on 0x%x\n",
|
||||
bsc_endp->transaction_id, endpoint);
|
||||
talloc_free(bsc_endp->transaction_id);
|
||||
}
|
||||
|
||||
/* we need to generate a new and patched message */
|
||||
bsc_msg = bsc_mgcp_rewrite((char *) nat->mgcp_msg, nat->mgcp_length,
|
||||
nat->mgcp_cfg->source_addr, mgcp_endp->rtp_port);
|
||||
@@ -158,27 +236,33 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
|
||||
|
||||
|
||||
bsc_endp->transaction_id = talloc_strdup(nat, transaction_id);
|
||||
bsc_endp->bsc = bsc_con;
|
||||
bsc_endp->pending_delete = 0;
|
||||
bsc_endp->bsc = sccp->bsc;
|
||||
|
||||
/* we need to update some bits */
|
||||
if (state == MGCP_ENDP_CRCX) {
|
||||
struct sockaddr_in sock;
|
||||
socklen_t len = sizeof(sock);
|
||||
if (getpeername(bsc_con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
|
||||
if (getpeername(sccp->bsc->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
|
||||
LOGP(DMGCP, LOGL_ERROR, "Can not get the peername...%d/%s\n",
|
||||
errno, strerror(errno));
|
||||
} else {
|
||||
mgcp_endp->bts = sock.sin_addr;
|
||||
}
|
||||
} else if (state == MGCP_ENDP_DLCX) {
|
||||
/* we will free the endpoint now in case the BSS does not respond */
|
||||
bsc_endp->pending_delete = 1;
|
||||
mgcp_free_endp(mgcp_endp);
|
||||
}
|
||||
|
||||
bsc_write(bsc_con, bsc_msg, NAT_IPAC_PROTO_MGCP);
|
||||
return MGCP_POLICY_DEFER;
|
||||
/* send the message and a fake MDCX for force sending of a dummy packet */
|
||||
sccp->crcx = 1;
|
||||
bsc_write(sccp->bsc, bsc_msg, NAT_IPAC_PROTO_MGCP);
|
||||
bsc_mgcp_send_mdcx(sccp->bsc, mgcp_endp);
|
||||
return MGCP_POLICY_DEFER;
|
||||
} else if (state == MGCP_ENDP_DLCX) {
|
||||
/* we will free the endpoint now and send a DLCX to the BSC */
|
||||
msgb_free(bsc_msg);
|
||||
bsc_mgcp_dlcx(sccp);
|
||||
return MGCP_POLICY_CONT;
|
||||
} else {
|
||||
bsc_write(sccp->bsc, bsc_msg, NAT_IPAC_PROTO_MGCP);
|
||||
return MGCP_POLICY_DEFER;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -228,13 +312,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
/* make it point to our endpoint if it was not deleted */
|
||||
if (bsc_endp->pending_delete) {
|
||||
bsc_endp->bsc = NULL;
|
||||
bsc_endp->pending_delete = 0;
|
||||
} else {
|
||||
endp->ci = bsc_mgcp_extract_ci((const char *) msg->l2h);
|
||||
}
|
||||
endp->ci = bsc_mgcp_extract_ci((const char *) msg->l2h);
|
||||
|
||||
/* free some stuff */
|
||||
talloc_free(bsc_endp->transaction_id);
|
||||
@@ -395,7 +473,7 @@ static int mgcp_do_write(struct bsc_fd *bfd, struct msgb *msg)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int bsc_mgcp_init(struct bsc_nat *nat)
|
||||
int bsc_mgcp_nat_init(struct bsc_nat *nat)
|
||||
{
|
||||
int on;
|
||||
struct sockaddr_in addr;
|
||||
@@ -475,11 +553,7 @@ void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc)
|
||||
if (bsc_endp->bsc != bsc)
|
||||
continue;
|
||||
|
||||
bsc_endp->bsc = NULL;
|
||||
bsc_endp->pending_delete = 0;
|
||||
if (bsc_endp->transaction_id)
|
||||
talloc_free(bsc_endp->transaction_id);
|
||||
bsc_endp->transaction_id = NULL;
|
||||
bsc_mgcp_free_endpoint(bsc->nat, i);
|
||||
mgcp_free_endp(&bsc->nat->mgcp_cfg->endpoints[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
@@ -51,15 +52,14 @@
|
||||
|
||||
struct log_target *stderr_target;
|
||||
static const char *config_file = "bsc-nat.cfg";
|
||||
static char *msc_address = "127.0.0.1";
|
||||
static struct in_addr local_addr;
|
||||
static struct bsc_msc_connection *msc_con;
|
||||
static struct bsc_fd bsc_listen;
|
||||
static const char *msc_ip = NULL;
|
||||
|
||||
|
||||
static struct bsc_nat *nat;
|
||||
static void bsc_send_data(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length, int);
|
||||
static void remove_bsc_connection(struct bsc_connection *connection);
|
||||
static void msc_send_reset(struct bsc_msc_connection *con);
|
||||
|
||||
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num)
|
||||
@@ -90,6 +90,14 @@ int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void queue_for_msc(struct bsc_msc_connection *con, struct msgb *msg)
|
||||
{
|
||||
if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n");
|
||||
msgb_free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void send_reset_ack(struct bsc_connection *bsc)
|
||||
{
|
||||
static const u_int8_t gsm_reset_ack[] = {
|
||||
@@ -101,6 +109,58 @@ static void send_reset_ack(struct bsc_connection *bsc)
|
||||
bsc_send_data(bsc, gsm_reset_ack, sizeof(gsm_reset_ack), IPAC_PROTO_SCCP);
|
||||
}
|
||||
|
||||
static void send_ping(struct bsc_connection *bsc)
|
||||
{
|
||||
static const u_int8_t id_ping[] = {
|
||||
IPAC_MSGT_PING,
|
||||
};
|
||||
|
||||
bsc_send_data(bsc, id_ping, sizeof(id_ping), IPAC_PROTO_IPACCESS);
|
||||
}
|
||||
|
||||
static void send_pong(struct bsc_connection *bsc)
|
||||
{
|
||||
static const u_int8_t id_pong[] = {
|
||||
IPAC_MSGT_PONG,
|
||||
};
|
||||
|
||||
bsc_send_data(bsc, id_pong, sizeof(id_pong), IPAC_PROTO_IPACCESS);
|
||||
}
|
||||
|
||||
static void bsc_pong_timeout(void *_bsc)
|
||||
{
|
||||
struct bsc_connection *bsc = _bsc;
|
||||
|
||||
LOGP(DNAT, LOGL_ERROR, "BSC Nr: %d PONG timeout.\n", bsc->cfg->nr);
|
||||
bsc_close_connection(bsc);
|
||||
}
|
||||
|
||||
static void bsc_ping_timeout(void *_bsc)
|
||||
{
|
||||
struct bsc_connection *bsc = _bsc;
|
||||
|
||||
if (bsc->nat->ping_timeout < 0)
|
||||
return;
|
||||
|
||||
send_ping(bsc);
|
||||
|
||||
/* send another ping in 20 seconds */
|
||||
bsc_schedule_timer(&bsc->ping_timeout, bsc->nat->ping_timeout, 0);
|
||||
|
||||
/* also start a pong timer */
|
||||
bsc_schedule_timer(&bsc->pong_timeout, bsc->nat->pong_timeout, 0);
|
||||
}
|
||||
|
||||
static void start_ping_pong(struct bsc_connection *bsc)
|
||||
{
|
||||
bsc->pong_timeout.data = bsc;
|
||||
bsc->pong_timeout.cb = bsc_pong_timeout;
|
||||
bsc->ping_timeout.data = bsc;
|
||||
bsc->ping_timeout.cb = bsc_ping_timeout;
|
||||
|
||||
bsc_ping_timeout(bsc);
|
||||
}
|
||||
|
||||
static void send_id_ack(struct bsc_connection *bsc)
|
||||
{
|
||||
static const u_int8_t id_ack[] = {
|
||||
@@ -147,10 +207,7 @@ static void nat_send_rlsd(struct sccp_connections *conn)
|
||||
|
||||
ipaccess_prepend_header(msg, IPAC_PROTO_SCCP);
|
||||
|
||||
if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n");
|
||||
msgb_free(msg);
|
||||
}
|
||||
queue_for_msc(msc_con, msg);
|
||||
}
|
||||
|
||||
static void nat_send_rlc(struct sccp_source_reference *src,
|
||||
@@ -173,10 +230,7 @@ static void nat_send_rlc(struct sccp_source_reference *src,
|
||||
|
||||
ipaccess_prepend_header(msg, IPAC_PROTO_SCCP);
|
||||
|
||||
if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n");
|
||||
msgb_free(msg);
|
||||
}
|
||||
queue_for_msc(msc_con, msg);
|
||||
}
|
||||
|
||||
static void send_mgcp_reset(struct bsc_connection *bsc)
|
||||
@@ -258,7 +312,10 @@ static int forward_sccp_to_bts(struct msgb *msg)
|
||||
case SCCP_MSG_TYPE_IT:
|
||||
con = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
|
||||
if (parsed->gsm_type == BSS_MAP_MSG_ASSIGMENT_RQST) {
|
||||
counter_inc(nat->stats.sccp.calls);
|
||||
|
||||
if (con) {
|
||||
counter_inc(con->bsc->cfg->stats.sccp.calls);
|
||||
if (bsc_mgcp_assign(con, msg) != 0)
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to assign...\n");
|
||||
} else
|
||||
@@ -306,11 +363,15 @@ send_to_all:
|
||||
* message and then send it to the authenticated messages...
|
||||
*/
|
||||
if (parsed->ipa_proto == IPAC_PROTO_SCCP && parsed->gsm_type == BSS_MAP_MSG_PAGING) {
|
||||
bsc = bsc_nat_find_bsc(nat, msg);
|
||||
if (bsc)
|
||||
int lac;
|
||||
bsc = bsc_nat_find_bsc(nat, msg, &lac);
|
||||
if (bsc && bsc->cfg->forbid_paging)
|
||||
LOGP(DNAT, LOGL_DEBUG, "Paging forbidden for BTS: %d\n", bsc->cfg->nr);
|
||||
else if (bsc)
|
||||
bsc_send_data(bsc, msg->l2h, msgb_l2len(msg), parsed->ipa_proto);
|
||||
else
|
||||
LOGP(DNAT, LOGL_ERROR, "Could not determine BSC for paging.\n");
|
||||
LOGP(DNAT, LOGL_ERROR, "Could not determine BSC for paging on lac: %d/0x%x\n",
|
||||
lac, lac);
|
||||
|
||||
goto exit;
|
||||
}
|
||||
@@ -331,9 +392,11 @@ static void msc_connection_was_lost(struct bsc_msc_connection *con)
|
||||
{
|
||||
struct bsc_connection *bsc, *tmp;
|
||||
|
||||
counter_inc(nat->stats.msc.reconn);
|
||||
|
||||
LOGP(DMSC, LOGL_ERROR, "Closing all connections downstream.\n");
|
||||
llist_for_each_entry_safe(bsc, tmp, &nat->bsc_connections, list_entry)
|
||||
remove_bsc_connection(bsc);
|
||||
bsc_close_connection(bsc);
|
||||
|
||||
nat->first_contact = 0;
|
||||
bsc_mgcp_free_endpoints(nat);
|
||||
@@ -360,10 +423,7 @@ static void msc_send_reset(struct bsc_msc_connection *msc_con)
|
||||
msg->l2h = msgb_put(msg, sizeof(reset));
|
||||
memcpy(msg->l2h, reset, msgb_l2len(msg));
|
||||
|
||||
if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
|
||||
LOGP(DMSC, LOGL_ERROR, "Failed to enqueue reset msg.\n");
|
||||
msgb_free(msg);
|
||||
}
|
||||
queue_for_msc(msc_con, msg);
|
||||
|
||||
LOGP(DMSC, LOGL_NOTICE, "Scheduled GSM0808 reset msg for the MSC.\n");
|
||||
}
|
||||
@@ -375,13 +435,12 @@ static int ipaccess_msc_read_cb(struct bsc_fd *bfd)
|
||||
struct ipaccess_head *hh;
|
||||
|
||||
if (!msg) {
|
||||
if (error == 0) {
|
||||
if (error == 0)
|
||||
LOGP(DNAT, LOGL_FATAL, "The connection the MSC was lost, exiting\n");
|
||||
bsc_msc_lost(msc_con);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
|
||||
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
|
||||
bsc_msc_lost(msc_con);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -425,38 +484,47 @@ static int ipaccess_msc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
|
||||
* remove it from the patching of SCCP header lists
|
||||
* as well. Maybe in the future even close connection..
|
||||
*/
|
||||
static void remove_bsc_connection(struct bsc_connection *connection)
|
||||
void bsc_close_connection(struct bsc_connection *connection)
|
||||
{
|
||||
struct sccp_connections *sccp_patch, *tmp;
|
||||
bsc_unregister_fd(&connection->write_queue.bfd);
|
||||
close(connection->write_queue.bfd.fd);
|
||||
write_queue_clear(&connection->write_queue);
|
||||
llist_del(&connection->list_entry);
|
||||
|
||||
/* stop the timeout timer */
|
||||
bsc_del_timer(&connection->id_timeout);
|
||||
bsc_del_timer(&connection->ping_timeout);
|
||||
bsc_del_timer(&connection->pong_timeout);
|
||||
|
||||
/* remove all SCCP connections */
|
||||
llist_for_each_entry_safe(sccp_patch, tmp, &nat->sccp_connections, list_entry) {
|
||||
if (sccp_patch->bsc != connection)
|
||||
continue;
|
||||
|
||||
nat_send_rlsd(sccp_patch);
|
||||
if (sccp_patch->has_remote_ref)
|
||||
nat_send_rlsd(sccp_patch);
|
||||
sccp_connection_destroy(sccp_patch);
|
||||
}
|
||||
|
||||
/* close endpoints allocated by this BSC */
|
||||
bsc_mgcp_clear_endpoints_for(connection);
|
||||
|
||||
bsc_unregister_fd(&connection->write_queue.bfd);
|
||||
close(connection->write_queue.bfd.fd);
|
||||
write_queue_clear(&connection->write_queue);
|
||||
llist_del(&connection->list_entry);
|
||||
|
||||
talloc_free(connection);
|
||||
}
|
||||
|
||||
static void ipaccess_close_bsc(void *data)
|
||||
{
|
||||
struct sockaddr_in sock;
|
||||
socklen_t len = sizeof(sock);
|
||||
struct bsc_connection *conn = data;
|
||||
|
||||
LOGP(DNAT, LOGL_ERROR, "BSC didn't respond to identity request. Closing.\n");
|
||||
remove_bsc_connection(conn);
|
||||
|
||||
getpeername(conn->write_queue.bfd.fd, (struct sockaddr *) &sock, &len);
|
||||
LOGP(DNAT, LOGL_ERROR, "BSC on %s didn't respond to identity request. Closing.\n",
|
||||
inet_ntoa(sock.sin_addr));
|
||||
bsc_close_connection(conn);
|
||||
}
|
||||
|
||||
static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc)
|
||||
@@ -464,15 +532,27 @@ static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc
|
||||
struct bsc_config *conf;
|
||||
const char* token = (const char *) TLVP_VAL(tvp, IPAC_IDTAG_UNITNAME);
|
||||
|
||||
if (bsc->cfg) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Reauth on fd %d bsc nr %d\n",
|
||||
bsc->write_queue.bfd.fd, bsc->cfg->nr);
|
||||
return;
|
||||
}
|
||||
|
||||
llist_for_each_entry(conf, &bsc->nat->bsc_configs, entry) {
|
||||
if (strcmp(conf->token, token) == 0) {
|
||||
counter_inc(conf->stats.net.reconn);
|
||||
bsc->authenticated = 1;
|
||||
bsc->cfg = conf;
|
||||
bsc_del_timer(&bsc->id_timeout);
|
||||
LOGP(DNAT, LOGL_NOTICE, "Authenticated bsc nr: %d lac: %d\n", conf->nr, conf->lac);
|
||||
break;
|
||||
LOGP(DNAT, LOGL_NOTICE, "Authenticated bsc nr: %d lac: %d on fd %d\n",
|
||||
conf->nr, conf->lac, bsc->write_queue.bfd.fd);
|
||||
start_ping_pong(bsc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LOGP(DNAT, LOGL_ERROR, "No bsc found for token %s on fd: %d.\n", token,
|
||||
bsc->write_queue.bfd.fd);
|
||||
}
|
||||
|
||||
static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
|
||||
@@ -509,17 +589,17 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
|
||||
case SCCP_MSG_TYPE_CR:
|
||||
if (create_sccp_src_ref(bsc, msg, parsed) != 0)
|
||||
goto exit2;
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
|
||||
break;
|
||||
case SCCP_MSG_TYPE_RLSD:
|
||||
case SCCP_MSG_TYPE_CREF:
|
||||
case SCCP_MSG_TYPE_DT1:
|
||||
case SCCP_MSG_TYPE_CC:
|
||||
case SCCP_MSG_TYPE_IT:
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
|
||||
break;
|
||||
case SCCP_MSG_TYPE_RLC:
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
|
||||
remove_sccp_src_ref(bsc, msg, parsed);
|
||||
break;
|
||||
case SCCP_MSG_TYPE_UDT:
|
||||
@@ -541,15 +621,13 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
|
||||
}
|
||||
|
||||
if (con && con->bsc != bsc) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Found the wrong entry.\n");
|
||||
LOGP(DNAT, LOGL_ERROR, "The connection belongs to a different BTS: input: %d con: %d\n",
|
||||
bsc->cfg->nr, con->bsc->cfg->nr);
|
||||
goto exit2;
|
||||
}
|
||||
|
||||
/* send the non-filtered but maybe modified msg */
|
||||
if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Can not queue message for the MSC.\n");
|
||||
msgb_free(msg);
|
||||
}
|
||||
queue_for_msc(msc_con, msg);
|
||||
talloc_free(parsed);
|
||||
return 0;
|
||||
|
||||
@@ -583,14 +661,19 @@ static int ipaccess_bsc_read_cb(struct bsc_fd *bfd)
|
||||
int error;
|
||||
struct bsc_connection *bsc = bfd->data;
|
||||
struct msgb *msg = ipaccess_read_msg(bfd, &error);
|
||||
struct ipaccess_head *hh;
|
||||
|
||||
if (!msg) {
|
||||
if (error == 0) {
|
||||
LOGP(DNAT, LOGL_ERROR, "The connection to the BSC was lost. Cleaning it\n");
|
||||
remove_bsc_connection(bsc);
|
||||
} else {
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
|
||||
}
|
||||
if (error == 0)
|
||||
LOGP(DNAT, LOGL_ERROR,
|
||||
"The connection to the BSC Nr: %d was lost. Cleaning it\n",
|
||||
bsc->cfg ? bsc->cfg->nr : -1);
|
||||
else
|
||||
LOGP(DNAT, LOGL_ERROR,
|
||||
"Stream error on BSC Nr: %d. Failed to parse ip access message: %d\n",
|
||||
bsc->cfg ? bsc->cfg->nr : -1, error);
|
||||
|
||||
bsc_close_connection(bsc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -598,6 +681,21 @@ static int ipaccess_bsc_read_cb(struct bsc_fd *bfd)
|
||||
LOGP(DNAT, LOGL_DEBUG, "MSG from BSC: %s proto: %d\n", hexdump(msg->data, msg->len), msg->l2h[0]);
|
||||
|
||||
/* Handle messages from the BSC */
|
||||
hh = (struct ipaccess_head *) msg->data;
|
||||
|
||||
/* stop the pong timeout */
|
||||
if (hh->proto == IPAC_PROTO_IPACCESS) {
|
||||
if (msg->l2h[0] == IPAC_MSGT_PONG) {
|
||||
bsc_del_timer(&bsc->pong_timeout);
|
||||
msgb_free(msg);
|
||||
return 0;
|
||||
} else if (msg->l2h[0] == IPAC_MSGT_PING) {
|
||||
send_pong(bsc);
|
||||
msgb_free(msg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: Currently no PONG is sent to the BSC */
|
||||
/* FIXME: Currently no ID ACK is sent to the BSC */
|
||||
forward_sccp_to_msc(bsc, msg);
|
||||
@@ -619,7 +717,7 @@ static int ipaccess_bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
|
||||
static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
{
|
||||
struct bsc_connection *bsc;
|
||||
int ret;
|
||||
int ret, on;
|
||||
struct sockaddr_in sa;
|
||||
socklen_t sa_len = sizeof(sa);
|
||||
|
||||
@@ -632,6 +730,9 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* count the reconnect */
|
||||
counter_inc(nat->stats.bsc.reconn);
|
||||
|
||||
/*
|
||||
* if we are not connected to a msc... just close the socket
|
||||
*/
|
||||
@@ -641,6 +742,11 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
return 0;
|
||||
}
|
||||
|
||||
on = 1;
|
||||
ret = setsockopt(bfd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
||||
if (ret != 0)
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno));
|
||||
|
||||
/* todo... do something with the connection */
|
||||
/* todo... use GNUtls to see if we want to trust this as a BTS */
|
||||
|
||||
@@ -654,7 +760,6 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
return -1;
|
||||
}
|
||||
|
||||
write_queue_init(&bsc->write_queue, 100);
|
||||
bsc->write_queue.bfd.data = bsc;
|
||||
bsc->write_queue.bfd.fd = ret;
|
||||
bsc->write_queue.read_cb = ipaccess_bsc_read_cb;
|
||||
@@ -667,7 +772,8 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
return -2;
|
||||
}
|
||||
|
||||
LOGP(DNAT, LOGL_NOTICE, "Registered new BSC\n");
|
||||
LOGP(DNAT, LOGL_NOTICE, "BSC connection on %d with IP: %s\n",
|
||||
ret, inet_ntoa(sa.sin_addr));
|
||||
llist_add(&bsc->list_entry, &nat->bsc_connections);
|
||||
send_id_ack(bsc);
|
||||
send_id_req(bsc);
|
||||
@@ -678,7 +784,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
||||
*/
|
||||
bsc->id_timeout.data = bsc;
|
||||
bsc->id_timeout.cb = ipaccess_close_bsc;
|
||||
bsc_schedule_timer(&bsc->id_timeout, 2, 0);
|
||||
bsc_schedule_timer(&bsc->id_timeout, nat->auth_timeout, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -773,7 +879,7 @@ static void handle_options(int argc, char** argv)
|
||||
log_set_print_timestamp(stderr_target, 1);
|
||||
break;
|
||||
case 'm':
|
||||
msc_address = strdup(optarg);
|
||||
msc_ip = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
inet_aton(optarg, &local_addr);
|
||||
@@ -799,17 +905,24 @@ static void signal_handler(int signal)
|
||||
}
|
||||
}
|
||||
|
||||
extern void *tall_msgb_ctx;
|
||||
extern void *tall_ctr_ctx;
|
||||
static void talloc_init_ctx()
|
||||
{
|
||||
tall_bsc_ctx = talloc_named_const(NULL, 0, "nat");
|
||||
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
|
||||
tall_ctr_ctx = talloc_named_const(tall_bsc_ctx, 0, "counter");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
talloc_init_ctx();
|
||||
log_init(&log_info);
|
||||
|
||||
stderr_target = log_target_create_stderr();
|
||||
log_add_target(stderr_target);
|
||||
log_set_all_filter(stderr_target, 1);
|
||||
|
||||
/* parse options */
|
||||
local_addr.s_addr = INADDR_ANY;
|
||||
handle_options(argc, argv);
|
||||
|
||||
nat = bsc_nat_alloc();
|
||||
if (!nat) {
|
||||
fprintf(stderr, "Failed to allocate the BSC nat.\n");
|
||||
@@ -817,6 +930,14 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
nat->mgcp_cfg = talloc_zero(nat, struct mgcp_config);
|
||||
if (!nat->mgcp_cfg) {
|
||||
fprintf(stderr, "Failed to allocate MGCP cfg.\n");
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* parse options */
|
||||
local_addr.s_addr = INADDR_ANY;
|
||||
handle_options(argc, argv);
|
||||
|
||||
/* init vty and parse */
|
||||
bsc_nat_vty_init(nat);
|
||||
@@ -826,17 +947,21 @@ int main(int argc, char** argv)
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* over rule the VTY config */
|
||||
if (msc_ip)
|
||||
bsc_nat_set_msc_ip(nat, msc_ip);
|
||||
|
||||
/* seed the PRNG */
|
||||
srand(time(NULL));
|
||||
|
||||
/*
|
||||
* Setup the MGCP code..
|
||||
*/
|
||||
if (bsc_mgcp_init(nat) != 0)
|
||||
if (bsc_mgcp_nat_init(nat) != 0)
|
||||
return -4;
|
||||
|
||||
/* connect to the MSC */
|
||||
msc_con = bsc_msc_create(msc_address, 5000);
|
||||
msc_con = bsc_msc_create(nat->msc_ip, nat->msc_port);
|
||||
if (!msc_con) {
|
||||
fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
|
||||
exit(1);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <osmocore/linuxlist.h>
|
||||
#include <osmocore/talloc.h>
|
||||
#include <osmocore/gsm0808.h>
|
||||
|
||||
#include <sccp/sccp.h>
|
||||
|
||||
@@ -45,9 +46,26 @@ struct bsc_nat *bsc_nat_alloc(void)
|
||||
INIT_LLIST_HEAD(&nat->sccp_connections);
|
||||
INIT_LLIST_HEAD(&nat->bsc_connections);
|
||||
INIT_LLIST_HEAD(&nat->bsc_configs);
|
||||
nat->stats.sccp.conn = counter_alloc("nat.sccp.conn");
|
||||
nat->stats.sccp.calls = counter_alloc("nat.sccp.calls");
|
||||
nat->stats.bsc.reconn = counter_alloc("nat.bsc.conn");
|
||||
nat->stats.bsc.auth_fail = counter_alloc("nat.bsc.auth_fail");
|
||||
nat->stats.msc.reconn = counter_alloc("nat.msc.conn");
|
||||
nat->msc_ip = talloc_strdup(nat, "127.0.0.1");
|
||||
nat->msc_port = 5000;
|
||||
nat->auth_timeout = 2;
|
||||
nat->ping_timeout = 20;
|
||||
nat->pong_timeout = 5;
|
||||
return nat;
|
||||
}
|
||||
|
||||
void bsc_nat_set_msc_ip(struct bsc_nat *nat, const char *ip)
|
||||
{
|
||||
if (nat->msc_ip)
|
||||
talloc_free(nat->msc_ip);
|
||||
nat->msc_ip = talloc_strdup(nat, ip);
|
||||
}
|
||||
|
||||
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat)
|
||||
{
|
||||
struct bsc_connection *con = talloc_zero(nat, struct bsc_connection);
|
||||
@@ -55,6 +73,7 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat)
|
||||
return NULL;
|
||||
|
||||
con->nat = nat;
|
||||
write_queue_init(&con->write_queue, 100);
|
||||
return con;
|
||||
}
|
||||
|
||||
@@ -69,9 +88,13 @@ struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsi
|
||||
conf->nr = nat->num_bsc;
|
||||
conf->nat = nat;
|
||||
|
||||
llist_add(&conf->entry, &nat->bsc_configs);
|
||||
llist_add_tail(&conf->entry, &nat->bsc_configs);
|
||||
++nat->num_bsc;
|
||||
|
||||
conf->stats.sccp.conn = counter_alloc("nat.bsc.sccp.conn");
|
||||
conf->stats.sccp.calls = counter_alloc("nat.bsc.sccp.calls");
|
||||
conf->stats.net.reconn = counter_alloc("nat.bsc.net.reconnects");
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
@@ -80,12 +103,12 @@ void sccp_connection_destroy(struct sccp_connections *conn)
|
||||
LOGP(DNAT, LOGL_DEBUG, "Destroy 0x%x <-> 0x%x mapping for con %p\n",
|
||||
sccp_src_ref_to_int(&conn->real_ref),
|
||||
sccp_src_ref_to_int(&conn->patched_ref), conn->bsc);
|
||||
bsc_mgcp_clear(conn);
|
||||
bsc_mgcp_dlcx(conn);
|
||||
llist_del(&conn->list_entry);
|
||||
talloc_free(conn);
|
||||
}
|
||||
|
||||
struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg)
|
||||
struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg, int *lac_out)
|
||||
{
|
||||
struct bsc_connection *bsc;
|
||||
int data_length;
|
||||
@@ -93,6 +116,8 @@ struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg)
|
||||
struct tlv_parsed tp;
|
||||
int i = 0;
|
||||
|
||||
*lac_out = -1;
|
||||
|
||||
if (!msg->l3h || msgb_l3len(msg) < 3) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Paging message is too short.\n");
|
||||
return NULL;
|
||||
@@ -106,7 +131,11 @@ struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg)
|
||||
|
||||
data_length = TLVP_LEN(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST);
|
||||
data = TLVP_VAL(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST);
|
||||
if (data[0] != CELL_IDENT_LAC) {
|
||||
|
||||
/* No need to try a different BSS */
|
||||
if (data[0] == CELL_IDENT_BSS) {
|
||||
return NULL;
|
||||
} else if (data[0] != CELL_IDENT_LAC) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Unhandled cell ident discrminator: %d\n", data[0]);
|
||||
return NULL;
|
||||
}
|
||||
@@ -114,6 +143,7 @@ struct bsc_connection *bsc_nat_find_bsc(struct bsc_nat *nat, struct msgb *msg)
|
||||
/* Currently we only handle one BSC */
|
||||
for (i = 1; i < data_length - 1; i += 2) {
|
||||
unsigned int _lac = ntohs(*(unsigned int *) &data[i]);
|
||||
*lac_out = _lac;
|
||||
llist_for_each_entry(bsc, &nat->bsc_connections, list_entry) {
|
||||
if (!bsc->cfg)
|
||||
continue;
|
||||
|
||||
@@ -51,6 +51,15 @@ static struct cmd_node bsc_node = {
|
||||
static int config_write_nat(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, "nat%s", VTY_NEWLINE);
|
||||
if (_nat->imsi_allow)
|
||||
vty_out(vty, " imsi allow %s%s", _nat->imsi_allow, VTY_NEWLINE);
|
||||
if (_nat->imsi_deny)
|
||||
vty_out(vty, " insi deny %s%s", _nat->imsi_deny, VTY_NEWLINE);
|
||||
vty_out(vty, " msc ip %s%s", _nat->msc_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " msc port %d%s", _nat->msc_port, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -58,7 +67,12 @@ static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc)
|
||||
{
|
||||
vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE);
|
||||
vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE);
|
||||
vty_out(vty, " lac %u%s", bsc->lac, VTY_NEWLINE);
|
||||
vty_out(vty, " location_area_code %u%s", bsc->lac, VTY_NEWLINE);
|
||||
if (bsc->imsi_allow)
|
||||
vty_out(vty, " imsi allow %s%s", bsc->imsi_allow, VTY_NEWLINE);
|
||||
if (bsc->imsi_deny)
|
||||
vty_out(vty, " imsi deny %s%s", bsc->imsi_deny, VTY_NEWLINE);
|
||||
vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE);
|
||||
}
|
||||
|
||||
static int config_write_bsc(struct vty *vty)
|
||||
@@ -71,16 +85,20 @@ static int config_write_bsc(struct vty *vty)
|
||||
}
|
||||
|
||||
|
||||
DEFUN(show_sccp, show_sccp_cmd, "show connections sccp",
|
||||
DEFUN(show_sccp, show_sccp_cmd, "show sccp connections",
|
||||
SHOW_STR "Display information about current SCCP connections")
|
||||
{
|
||||
struct sccp_connections *con;
|
||||
vty_out(vty, "Listing all opening SCCP connections%s", VTY_NEWLINE);
|
||||
|
||||
llist_for_each_entry(con, &_nat->sccp_connections, list_entry) {
|
||||
vty_out(vty, "SCCP for BSC: Nr: %d lac: %d BSC ref: 0x%x Local ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s",
|
||||
vty_out(vty, "For BSC Nr: %d lac: %d; BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x%s",
|
||||
con->bsc->cfg ? con->bsc->cfg->nr : -1,
|
||||
con->bsc->cfg ? con->bsc->cfg->lac : -1,
|
||||
sccp_src_ref_to_int(&con->real_ref),
|
||||
sccp_src_ref_to_int(&con->patched_ref),
|
||||
con->has_remote_ref,
|
||||
sccp_src_ref_to_int(&con->remote_ref),
|
||||
con->msc_timeslot, con->bsc_timeslot,
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
@@ -88,7 +106,7 @@ DEFUN(show_sccp, show_sccp_cmd, "show connections sccp",
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_bsc, show_bsc_cmd, "show connections bsc",
|
||||
DEFUN(show_bsc, show_bsc_cmd, "show bsc connections",
|
||||
SHOW_STR "Display information about current BSCs")
|
||||
{
|
||||
struct bsc_connection *con;
|
||||
@@ -97,7 +115,7 @@ DEFUN(show_bsc, show_bsc_cmd, "show connections bsc",
|
||||
|
||||
llist_for_each_entry(con, &_nat->bsc_connections, list_entry) {
|
||||
getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len);
|
||||
vty_out(vty, "BSC lac: %d, %d auth: %d fd: %d peername: %s%s",
|
||||
vty_out(vty, "BSC nr: %d lac: %d auth: %d fd: %d peername: %s%s",
|
||||
con->cfg ? con->cfg->nr : -1,
|
||||
con->cfg ? con->cfg->lac : -1,
|
||||
con->authenticated, con->write_queue.bfd.fd,
|
||||
@@ -114,11 +132,72 @@ DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config",
|
||||
llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
|
||||
vty_out(vty, "BSC token: '%s' lac: %u nr: %u%s",
|
||||
conf->token, conf->lac, conf->nr, VTY_NEWLINE);
|
||||
vty_out(vty, " imsi_allow: '%s' imsi_deny: '%s'%s",
|
||||
conf->imsi_allow ? conf->imsi_allow: "any",
|
||||
conf->imsi_deny ? conf->imsi_deny : "none",
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " paging forbidden: %d%s",
|
||||
conf->forbid_paging, VTY_NEWLINE);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_stats,
|
||||
show_stats_cmd,
|
||||
"show statistics [NR]",
|
||||
SHOW_STR "Display network statistics")
|
||||
{
|
||||
struct bsc_config *conf;
|
||||
|
||||
int nr = -1;
|
||||
|
||||
if (argc == 1)
|
||||
nr = atoi(argv[0]);
|
||||
|
||||
vty_out(vty, "NAT statistics%s", VTY_NEWLINE);
|
||||
vty_out(vty, " SCCP Connections %lu total, %lu calls%s",
|
||||
counter_get(_nat->stats.sccp.conn),
|
||||
counter_get(_nat->stats.sccp.calls), VTY_NEWLINE);
|
||||
vty_out(vty, " MSC Connections %lu%s",
|
||||
counter_get(_nat->stats.msc.reconn), VTY_NEWLINE);
|
||||
vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s",
|
||||
counter_get(_nat->stats.bsc.reconn),
|
||||
counter_get(_nat->stats.bsc.auth_fail), VTY_NEWLINE);
|
||||
|
||||
llist_for_each_entry(conf, &_nat->bsc_configs, entry) {
|
||||
if (argc == 1 && nr != conf->nr)
|
||||
continue;
|
||||
|
||||
vty_out(vty, " BSC lac: %d nr: %d%s",
|
||||
conf->lac, conf->nr, VTY_NEWLINE);
|
||||
vty_out(vty, " SCCP Connnections %lu total, %lu calls%s",
|
||||
counter_get(conf->stats.sccp.conn),
|
||||
counter_get(conf->stats.sccp.calls), VTY_NEWLINE);
|
||||
vty_out(vty, " BSC Connections %lu total%s",
|
||||
counter_get(conf->stats.net.reconn), VTY_NEWLINE);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(close_bsc,
|
||||
close_bsc_cmd,
|
||||
"close bsc connection BSC_NR",
|
||||
"Close the connection with the BSC identified by the config number.")
|
||||
{
|
||||
struct bsc_connection *bsc;
|
||||
int bsc_nr = atoi(argv[0]);
|
||||
|
||||
llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) {
|
||||
if (!bsc->cfg || bsc->cfg->nr != bsc_nr)
|
||||
continue;
|
||||
bsc_close_connection(bsc);
|
||||
break;
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT")
|
||||
{
|
||||
@@ -128,8 +207,87 @@ DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT")
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv)
|
||||
{
|
||||
if (*imsi) {
|
||||
talloc_free(*imsi);
|
||||
*imsi = NULL;
|
||||
}
|
||||
regfree(reg);
|
||||
|
||||
if (argc > 0) {
|
||||
*imsi = talloc_strdup(ctx, argv[0]);
|
||||
regcomp(reg, argv[0], 0);
|
||||
}
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_imsi_allow,
|
||||
cfg_nat_imsi_allow_cmd,
|
||||
"imsi allow [REGEXP]",
|
||||
"Allow matching IMSIs to talk to the MSC. "
|
||||
"The defualt is to allow everyone.")
|
||||
{
|
||||
parse_reg(_nat, &_nat->imsi_allow_re, &_nat->imsi_allow, argc, argv);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_imsi_deny,
|
||||
cfg_nat_imsi_deny_cmd,
|
||||
"imsi deny [REGEXP]",
|
||||
"Deny matching IMSIs to talk to the MSC. "
|
||||
"The defualt is to not deny.")
|
||||
{
|
||||
parse_reg(_nat, &_nat->imsi_deny_re, &_nat->imsi_deny, argc, argv);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_msc_ip,
|
||||
cfg_nat_msc_ip_cmd,
|
||||
"msc ip IP",
|
||||
"Set the IP address of the MSC.")
|
||||
{
|
||||
bsc_nat_set_msc_ip(_nat, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_msc_port,
|
||||
cfg_nat_msc_port_cmd,
|
||||
"msc port <1-65500>",
|
||||
"Set the port of the MSC.")
|
||||
{
|
||||
_nat->msc_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_auth_time,
|
||||
cfg_nat_auth_time_cmd,
|
||||
"timeout auth <1-256>",
|
||||
"The time to wait for an auth response.")
|
||||
{
|
||||
_nat->auth_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_ping_time,
|
||||
cfg_nat_ping_time_cmd,
|
||||
"timeout ping NR",
|
||||
"Send a ping every NR seconds. Negative to disable.")
|
||||
{
|
||||
_nat->ping_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_nat_pong_time,
|
||||
cfg_nat_pong_time_cmd,
|
||||
"timeout pong NR",
|
||||
"Wait NR seconds for the PONG response. Should be smaller than ping.")
|
||||
{
|
||||
_nat->pong_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* per BSC configuration */
|
||||
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure\n")
|
||||
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure")
|
||||
{
|
||||
int bsc_nr = atoi(argv[0]);
|
||||
struct bsc_config *bsc;
|
||||
@@ -164,7 +322,7 @@ DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token")
|
||||
}
|
||||
|
||||
DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>",
|
||||
"Set the Location Area Code (LAC) of this BSC\n")
|
||||
"Set the Location Area Code (LAC) of this BSC")
|
||||
{
|
||||
struct bsc_config *tmp;
|
||||
struct bsc_config *conf = vty->index;
|
||||
@@ -196,6 +354,45 @@ DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>",
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bsc_imsi_allow,
|
||||
cfg_bsc_imsi_allow_cmd,
|
||||
"imsi allow [REGEXP]",
|
||||
"Allow IMSIs with the following network to talk to the MSC."
|
||||
"The default is to allow everyone)")
|
||||
{
|
||||
struct bsc_config *conf = vty->index;
|
||||
|
||||
parse_reg(conf, &conf->imsi_allow_re, &conf->imsi_allow, argc, argv);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bsc_imsi_deny,
|
||||
cfg_bsc_imsi_deny_cmd,
|
||||
"imsi deny [REGEXP]",
|
||||
"Deny IMSIs with the following network to talk to the MSC."
|
||||
"The default is to not deny anyone.)")
|
||||
{
|
||||
struct bsc_config *conf = vty->index;
|
||||
|
||||
parse_reg(conf, &conf->imsi_deny_re, &conf->imsi_deny, argc, argv);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bsc_paging,
|
||||
cfg_bsc_paging_cmd,
|
||||
"paging forbidden (0|1)",
|
||||
"Forbid sending PAGING REQUESTS to the BSC.")
|
||||
{
|
||||
struct bsc_config *conf = vty->index;
|
||||
|
||||
if (strcmp("1", argv[0]) == 0)
|
||||
conf->forbid_paging = 1;
|
||||
else
|
||||
conf->forbid_paging = 0;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int bsc_nat_vty_init(struct bsc_nat *nat)
|
||||
{
|
||||
_nat = nat;
|
||||
@@ -207,6 +404,8 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
|
||||
install_element(VIEW_NODE, &show_sccp_cmd);
|
||||
install_element(VIEW_NODE, &show_bsc_cmd);
|
||||
install_element(VIEW_NODE, &show_bsc_cfg_cmd);
|
||||
install_element(VIEW_NODE, &show_stats_cmd);
|
||||
install_element(VIEW_NODE, &close_bsc_cmd);
|
||||
|
||||
openbsc_vty_add_cmds();
|
||||
|
||||
@@ -214,6 +413,13 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
|
||||
install_element(CONFIG_NODE, &cfg_nat_cmd);
|
||||
install_node(&nat_node, config_write_nat);
|
||||
install_default(NAT_NODE);
|
||||
install_element(NAT_NODE, &cfg_nat_imsi_allow_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_imsi_deny_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_msc_ip_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_msc_port_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_auth_time_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_ping_time_cmd);
|
||||
install_element(NAT_NODE, &cfg_nat_pong_time_cmd);
|
||||
|
||||
/* BSC subgroups */
|
||||
install_element(NAT_NODE, &cfg_bsc_cmd);
|
||||
@@ -221,6 +427,9 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
|
||||
install_default(BSC_NODE);
|
||||
install_element(BSC_NODE, &cfg_bsc_token_cmd);
|
||||
install_element(BSC_NODE, &cfg_bsc_lac_cmd);
|
||||
install_element(BSC_NODE, &cfg_bsc_imsi_allow_cmd);
|
||||
install_element(BSC_NODE, &cfg_bsc_imsi_deny_cmd);
|
||||
install_element(BSC_NODE, &cfg_bsc_paging_cmd);
|
||||
|
||||
mgcp_vty_init();
|
||||
|
||||
|
||||
@@ -85,6 +85,28 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
|
||||
{
|
||||
struct sccp_connections *conn;
|
||||
|
||||
/* Some commercial BSCs like to reassign there SRC ref */
|
||||
llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
|
||||
if (conn->bsc != bsc)
|
||||
continue;
|
||||
if (memcmp(&conn->real_ref, parsed->src_local_ref, sizeof(conn->real_ref)) != 0)
|
||||
continue;
|
||||
|
||||
/* the BSC has reassigned the SRC ref and we failed to keep track */
|
||||
memset(&conn->remote_ref, 0, sizeof(conn->remote_ref));
|
||||
if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
|
||||
LOGP(DNAT, LOGL_ERROR, "BSC %d reused src ref: %d and we failed to generate a new id.\n",
|
||||
bsc->cfg->nr, sccp_src_ref_to_int(parsed->src_local_ref));
|
||||
llist_del(&conn->list_entry);
|
||||
talloc_free(conn);
|
||||
return -1;
|
||||
} else {
|
||||
bsc_mgcp_dlcx(conn);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
conn = talloc_zero(bsc->nat, struct sccp_connections);
|
||||
if (!conn) {
|
||||
LOGP(DNAT, LOGL_ERROR, "Memory allocation failure.\n");
|
||||
@@ -99,7 +121,10 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
|
||||
return -1;
|
||||
}
|
||||
|
||||
llist_add(&conn->list_entry, &bsc->nat->sccp_connections);
|
||||
bsc_mgcp_init(conn);
|
||||
llist_add_tail(&conn->list_entry, &bsc->nat->sccp_connections);
|
||||
counter_inc(bsc->cfg->stats.sccp.conn);
|
||||
counter_inc(bsc->cfg->nat->stats.sccp.conn);
|
||||
|
||||
LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con %p\n",
|
||||
sccp_src_ref_to_int(&conn->real_ref),
|
||||
@@ -116,6 +141,7 @@ int update_sccp_src_ref(struct sccp_connections *sccp, struct bsc_nat_parsed *pa
|
||||
}
|
||||
|
||||
sccp->remote_ref = *parsed->src_local_ref;
|
||||
sccp->has_remote_ref = 1;
|
||||
LOGP(DNAT, LOGL_DEBUG, "Updating 0x%x to remote 0x%x on %p\n",
|
||||
sccp_src_ref_to_int(&sccp->patched_ref),
|
||||
sccp_src_ref_to_int(&sccp->remote_ref), sccp->bsc);
|
||||
@@ -179,11 +205,14 @@ struct sccp_connections *patch_sccp_src_ref_to_bsc(struct msgb *msg,
|
||||
*/
|
||||
struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *msg,
|
||||
struct bsc_nat_parsed *parsed,
|
||||
struct bsc_nat *nat)
|
||||
struct bsc_connection *bsc)
|
||||
{
|
||||
struct sccp_connections *conn;
|
||||
|
||||
llist_for_each_entry(conn, &nat->sccp_connections, list_entry) {
|
||||
llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
|
||||
if (conn->bsc != bsc)
|
||||
continue;
|
||||
|
||||
if (parsed->src_local_ref) {
|
||||
if (equal(parsed->src_local_ref, &conn->real_ref)) {
|
||||
*parsed->src_local_ref = conn->patched_ref;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
!
|
||||
! OpenBSC configuration saved from vty
|
||||
!
|
||||
! !
|
||||
password foo
|
||||
!
|
||||
line vty
|
||||
@@ -11,17 +11,52 @@ network
|
||||
mobile network code 1
|
||||
short name OpenBSC
|
||||
long name OpenBSC
|
||||
auth policy closed
|
||||
location updating reject cause 13
|
||||
encryption a5 0
|
||||
neci 0
|
||||
rrlp mode none
|
||||
mm info 1
|
||||
handover 0
|
||||
handover window rxlev averaging 10
|
||||
handover window rxqual averaging 1
|
||||
handover window rxlev neighbor averaging 10
|
||||
handover power budget interval 6
|
||||
handover power budget hysteresis 3
|
||||
handover maximum distance 9999
|
||||
timer t3101 10
|
||||
timer t3103 0
|
||||
timer t3105 0
|
||||
timer t3107 0
|
||||
timer t3109 0
|
||||
timer t3111 0
|
||||
timer t3113 60
|
||||
timer t3115 0
|
||||
timer t3117 0
|
||||
timer t3119 0
|
||||
timer t3141 0
|
||||
bts 0
|
||||
type nanobts
|
||||
ip.access unit_id 1801 0
|
||||
band GSM1800
|
||||
band DCS1800
|
||||
cell_identity 0
|
||||
location_area_code 1
|
||||
training_sequence_code 7
|
||||
base_station_id_code 63
|
||||
ms max power 15
|
||||
cell reselection hysteresis 4
|
||||
rxlev access min 0
|
||||
channel allocator ascending
|
||||
rach tx integer 9
|
||||
rach max transmission 7
|
||||
ip.access unit_id 1801 0
|
||||
oml ip.access stream_id 255
|
||||
gprs mode none
|
||||
trx 0
|
||||
rf_locked 0
|
||||
arfcn 514
|
||||
nominal power 23
|
||||
max_power_red 20
|
||||
rsl e1 tei 0
|
||||
timeslot 0
|
||||
phys_chan_config CCCH+SDCCH4
|
||||
timeslot 1
|
||||
|
||||
97
openbsc/src/openbsc.cfg.nanobts.multitrx
Normal file
97
openbsc/src/openbsc.cfg.nanobts.multitrx
Normal file
@@ -0,0 +1,97 @@
|
||||
!
|
||||
! OpenBSC configuration saved from vty
|
||||
! !
|
||||
password foo
|
||||
!
|
||||
line vty
|
||||
no login
|
||||
!
|
||||
network
|
||||
network country code 1
|
||||
mobile network code 1
|
||||
short name OpenBSC
|
||||
long name OpenBSC
|
||||
auth policy closed
|
||||
location updating reject cause 13
|
||||
encryption a5 0
|
||||
neci 0
|
||||
rrlp mode none
|
||||
mm info 0
|
||||
handover 0
|
||||
handover window rxlev averaging 10
|
||||
handover window rxqual averaging 1
|
||||
handover window rxlev neighbor averaging 10
|
||||
handover power budget interval 6
|
||||
handover power budget hysteresis 3
|
||||
handover maximum distance 9999
|
||||
timer t3101 10
|
||||
timer t3103 0
|
||||
timer t3105 0
|
||||
timer t3107 0
|
||||
timer t3109 0
|
||||
timer t3111 0
|
||||
timer t3113 60
|
||||
timer t3115 0
|
||||
timer t3117 0
|
||||
timer t3119 0
|
||||
timer t3141 0
|
||||
bts 0
|
||||
type nanobts
|
||||
band DCS1800
|
||||
cell_identity 0
|
||||
location_area_code 1
|
||||
training_sequence_code 7
|
||||
base_station_id_code 63
|
||||
ms max power 15
|
||||
cell reselection hysteresis 4
|
||||
rxlev access min 0
|
||||
channel allocator ascending
|
||||
rach tx integer 9
|
||||
rach max transmission 7
|
||||
ip.access unit_id 1800 0
|
||||
oml ip.access stream_id 255
|
||||
gprs mode none
|
||||
trx 0
|
||||
rf_locked 0
|
||||
arfcn 871
|
||||
nominal power 23
|
||||
max_power_red 0
|
||||
rsl e1 tei 0
|
||||
timeslot 0
|
||||
phys_chan_config CCCH+SDCCH4
|
||||
timeslot 1
|
||||
phys_chan_config SDCCH8
|
||||
timeslot 2
|
||||
phys_chan_config TCH/F
|
||||
timeslot 3
|
||||
phys_chan_config TCH/F
|
||||
timeslot 4
|
||||
phys_chan_config TCH/F
|
||||
timeslot 5
|
||||
phys_chan_config TCH/F
|
||||
timeslot 6
|
||||
phys_chan_config TCH/F
|
||||
timeslot 7
|
||||
phys_chan_config TCH/F
|
||||
trx 1
|
||||
rf_locked 0
|
||||
arfcn 873
|
||||
nominal power 23
|
||||
max_power_red 0
|
||||
rsl e1 tei 0
|
||||
timeslot 0
|
||||
phys_chan_config CCCH+SDCCH4
|
||||
timeslot 1
|
||||
phys_chan_config SDCCH8
|
||||
timeslot 2
|
||||
phys_chan_config TCH/F
|
||||
timeslot 3
|
||||
phys_chan_config TCH/F
|
||||
timeslot 4
|
||||
phys_chan_config TCH/F
|
||||
timeslot 5
|
||||
phys_chan_config TCH/F
|
||||
timeslot 6
|
||||
phys_chan_config TCH/F
|
||||
timeslot 7
|
||||
phys_chan_config TCH/F
|
||||
@@ -45,9 +45,12 @@
|
||||
#include <openbsc/signal.h>
|
||||
#include <openbsc/abis_rsl.h>
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/chan_alloc.h>
|
||||
|
||||
void *tall_paging_ctx;
|
||||
|
||||
#define PAGING_TIMER 0, 500000
|
||||
|
||||
static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber *subscr)
|
||||
{
|
||||
int ccch_conf;
|
||||
@@ -95,6 +98,72 @@ static void page_ms(struct gsm_paging_request *request)
|
||||
request->chan_type);
|
||||
}
|
||||
|
||||
static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
|
||||
{
|
||||
if (llist_empty(&paging_bts->pending_requests))
|
||||
return;
|
||||
|
||||
if (!bsc_timer_pending(&paging_bts->work_timer))
|
||||
bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
|
||||
}
|
||||
|
||||
|
||||
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts);
|
||||
static void paging_give_credit(void *data)
|
||||
{
|
||||
struct gsm_bts_paging_state *paging_bts = data;
|
||||
|
||||
LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n", paging_bts->bts->nr);
|
||||
paging_bts->available_slots = 20;
|
||||
paging_handle_pending_requests(paging_bts);
|
||||
}
|
||||
|
||||
static int can_send_pag_req(struct gsm_bts *bts, int rsl_type)
|
||||
{
|
||||
struct pchan_load pl;
|
||||
int count;
|
||||
|
||||
memset(&pl, 0, sizeof(pl));
|
||||
bts_chan_load(&pl, bts);
|
||||
|
||||
switch (rsl_type) {
|
||||
case RSL_CHANNEED_TCH_F:
|
||||
case RSL_CHANNEED_TCH_ForH:
|
||||
goto count_tch;
|
||||
break;
|
||||
case RSL_CHANNEED_SDCCH:
|
||||
goto count_sdcch;
|
||||
break;
|
||||
case RSL_CHANNEED_ANY:
|
||||
default:
|
||||
if (bts->network->pag_any_tch)
|
||||
goto count_tch;
|
||||
else
|
||||
goto count_sdcch;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
/* could available SDCCH */
|
||||
count_sdcch:
|
||||
count = 0;
|
||||
count += pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].total
|
||||
- pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].used;
|
||||
count += pl.pchan[GSM_PCHAN_CCCH_SDCCH4].total
|
||||
- pl.pchan[GSM_PCHAN_CCCH_SDCCH4].used;
|
||||
return bts->paging.free_chans_need > count;
|
||||
|
||||
count_tch:
|
||||
count = 0;
|
||||
count += pl.pchan[GSM_PCHAN_TCH_F].total
|
||||
- pl.pchan[GSM_PCHAN_TCH_F].used;
|
||||
if (bts->network->neci)
|
||||
count += pl.pchan[GSM_PCHAN_TCH_H].total
|
||||
- pl.pchan[GSM_PCHAN_TCH_H].used;
|
||||
return bts->paging.free_chans_need > count;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is kicked by the periodic PAGING LOAD Indicator
|
||||
* coming from abis_rsl.c
|
||||
@@ -104,8 +173,7 @@ static void page_ms(struct gsm_paging_request *request)
|
||||
*/
|
||||
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts)
|
||||
{
|
||||
struct gsm_paging_request *initial_request = NULL;
|
||||
struct gsm_paging_request *current_request = NULL;
|
||||
struct gsm_paging_request *request = NULL;
|
||||
|
||||
/*
|
||||
* Determine if the pending_requests list is empty and
|
||||
@@ -117,39 +185,37 @@ static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_b
|
||||
}
|
||||
|
||||
/*
|
||||
* In case the BTS does not provide us with load indication just fill
|
||||
* up our slots for this round. We should be able to page 20 subscribers
|
||||
* every two seconds. So we will just give the BTS some extra credit.
|
||||
* We will have to see how often we run out of this credit, so we might
|
||||
* need a low watermark and then add credit or give 20 every run when
|
||||
* the bts sets an option for that.
|
||||
* In case the BTS does not provide us with load indication and we
|
||||
* ran out of slots, call an autofill routine. It might be that the
|
||||
* BTS did not like our paging messages and then we have counted down
|
||||
* to zero and we do not get any messages.
|
||||
*/
|
||||
if (paging_bts->available_slots == 0) {
|
||||
LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n",
|
||||
paging_bts->bts->nr);
|
||||
paging_bts->available_slots = 20;
|
||||
paging_bts->credit_timer.cb = paging_give_credit;
|
||||
paging_bts->credit_timer.data = paging_bts;
|
||||
bsc_schedule_timer(&paging_bts->credit_timer, 5, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
initial_request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
current_request = initial_request;
|
||||
request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
|
||||
do {
|
||||
/* handle the paging request now */
|
||||
page_ms(current_request);
|
||||
paging_bts->available_slots--;
|
||||
/* we need to determine the number of free channels */
|
||||
if (paging_bts->free_chans_need != -1) {
|
||||
if (can_send_pag_req(request->bts, request->chan_type) != 0)
|
||||
goto skip_paging;
|
||||
}
|
||||
|
||||
/* take the current and add it to the back */
|
||||
llist_del(¤t_request->entry);
|
||||
llist_add_tail(¤t_request->entry, &paging_bts->pending_requests);
|
||||
/* handle the paging request now */
|
||||
page_ms(request);
|
||||
paging_bts->available_slots--;
|
||||
|
||||
/* take the next request */
|
||||
current_request = llist_entry(paging_bts->pending_requests.next,
|
||||
struct gsm_paging_request, entry);
|
||||
} while (paging_bts->available_slots > 0
|
||||
&& initial_request != current_request);
|
||||
/* take the current and add it to the back */
|
||||
llist_del(&request->entry);
|
||||
llist_add_tail(&request->entry, &paging_bts->pending_requests);
|
||||
|
||||
bsc_schedule_timer(&paging_bts->work_timer, 2, 0);
|
||||
skip_paging:
|
||||
bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
|
||||
}
|
||||
|
||||
static void paging_worker(void *data)
|
||||
@@ -232,9 +298,7 @@ static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
||||
req->T3113.data = req;
|
||||
bsc_schedule_timer(&req->T3113, bts->network->T3113, 0);
|
||||
llist_add_tail(&req->entry, &bts_entry->pending_requests);
|
||||
|
||||
if (!bsc_timer_pending(&bts_entry->work_timer))
|
||||
bsc_schedule_timer(&bts_entry->work_timer, 2, 0);
|
||||
paging_schedule_if_needed(bts_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -324,5 +388,19 @@ void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
|
||||
|
||||
void paging_update_buffer_space(struct gsm_bts *bts, u_int16_t free_slots)
|
||||
{
|
||||
bsc_del_timer(&bts->paging.credit_timer);
|
||||
bts->paging.available_slots = free_slots;
|
||||
paging_schedule_if_needed(&bts->paging);
|
||||
}
|
||||
|
||||
unsigned int paging_pending_requests_nr(struct gsm_bts *bts)
|
||||
{
|
||||
unsigned int requests = 0;
|
||||
|
||||
struct gsm_paging_request *req;
|
||||
|
||||
llist_for_each_entry(req, &bts->paging.pending_requests, entry)
|
||||
++requests;
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ static int append_lsa_params(struct bitvec *bv,
|
||||
const struct gsm48_lsa_params *lsa_params)
|
||||
{
|
||||
/* FIXME */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Generate SI4 Rest Octets (Chapter 10.5.2.35) */
|
||||
@@ -318,8 +319,31 @@ static int append_gprs_cell_opt(struct bitvec *bv,
|
||||
/* hard-code no PAN_{DEC,INC,MAX} */
|
||||
bitvec_set_bit(bv, 0);
|
||||
|
||||
/* no extension information (EDGE) */
|
||||
bitvec_set_bit(bv, 0);
|
||||
if (!gco->ext_info_present) {
|
||||
/* no extension information */
|
||||
bitvec_set_bit(bv, 0);
|
||||
} else {
|
||||
/* extension information */
|
||||
bitvec_set_bit(bv, 1);
|
||||
if (!gco->ext_info.egprs_supported) {
|
||||
/* 6bit length of extension */
|
||||
bitvec_set_uint(bv, (1 + 3)-1, 6);
|
||||
/* EGPRS supported in the cell */
|
||||
bitvec_set_bit(bv, 0);
|
||||
} else {
|
||||
/* 6bit length of extension */
|
||||
bitvec_set_uint(bv, (1 + 5 + 3)-1, 6);
|
||||
/* EGPRS supported in the cell */
|
||||
bitvec_set_bit(bv, 1);
|
||||
/* 1bit EGPRS PACKET CHANNEL REQUEST */
|
||||
bitvec_set_bit(bv, gco->ext_info.use_egprs_p_ch_req);
|
||||
/* 4bit BEP PERIOD */
|
||||
bitvec_set_uint(bv, gco->ext_info.bep_period, 4);
|
||||
}
|
||||
bitvec_set_bit(bv, gco->ext_info.pfc_supported);
|
||||
bitvec_set_bit(bv, gco->ext_info.dtm_supported);
|
||||
bitvec_set_bit(bv, gco->ext_info.bss_paging_coordination);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -334,7 +358,7 @@ static void append_gprs_pwr_ctrl_pars(struct bitvec *bv,
|
||||
bitvec_set_uint(bv, pcp->n_avg_i, 4);
|
||||
}
|
||||
|
||||
/* Generate SI13 Rest Octests (Chapter 10.5.2.37b) */
|
||||
/* Generate SI13 Rest Octests (04.08 Chapter 10.5.2.37b) */
|
||||
int rest_octets_si13(u_int8_t *data, const struct gsm48_si13_info *si13)
|
||||
{
|
||||
struct bitvec bv;
|
||||
@@ -390,6 +414,11 @@ int rest_octets_si13(u_int8_t *data, const struct gsm48_si13_info *si13)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* 3GPP TS 44.018 Release 6 / 10.5.2.37b */
|
||||
bitvec_set_bit(&bv, H); /* added Release 99 */
|
||||
/* claim our SGSN is compatible with Release 99, as EDGE and EGPRS
|
||||
* was only added in this Release */
|
||||
bitvec_set_bit(&bv, 1);
|
||||
}
|
||||
bitvec_spare_padding(&bv, (bv.data_len*8)-1);
|
||||
return bv.data_len;
|
||||
|
||||
@@ -81,7 +81,7 @@ static struct sccp_data_callback *_find_ssn(u_int8_t ssn)
|
||||
/* need to add one */
|
||||
cb = talloc_zero(tall_sccp_ctx, struct sccp_data_callback);
|
||||
if (!cb) {
|
||||
DEBUGP(DSCCP, "Failed to allocate sccp callback.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Failed to allocate sccp callback.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ static int copy_address(struct sccp_address *addr, u_int8_t offset, struct msgb
|
||||
u_int8_t length;
|
||||
|
||||
if (room <= 0) {
|
||||
DEBUGP(DSCCP, "Not enough room for an address: %u\n", room);
|
||||
LOGP(DSCCP, LOGL_ERROR, "Not enough room for an address: %u\n", room);
|
||||
return -1;
|
||||
}
|
||||
|
||||
length = msgb->l2h[offset];
|
||||
if (room <= length) {
|
||||
DEBUGP(DSCCP, "Not enough room for optional data %u %u\n", room, length);
|
||||
LOGP(DSCCP, LOGL_ERROR, "Not enough room for optional data %u %u\n", room, length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ static int copy_address(struct sccp_address *addr, u_int8_t offset, struct msgb
|
||||
party = (struct sccp_called_party_address *)(msgb->l2h + offset + 1);
|
||||
if (party->point_code_indicator) {
|
||||
if (length <= read + 2) {
|
||||
DEBUGP(DSCCP, "POI does not fit %u\n", length);
|
||||
LOGP(DSCCP, LOGL_ERROR, "POI does not fit %u\n", length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ static int copy_address(struct sccp_address *addr, u_int8_t offset, struct msgb
|
||||
|
||||
if (party->ssn_indicator) {
|
||||
if (length <= read + 1) {
|
||||
DEBUGP(DSCCP, "SSN does not fit %u\n", length);
|
||||
LOGP(DSCCP, LOGL_ERROR, "SSN does not fit %u\n", length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ static int copy_address(struct sccp_address *addr, u_int8_t offset, struct msgb
|
||||
}
|
||||
|
||||
if (party->global_title_indicator) {
|
||||
DEBUGP(DSCCP, "GTI not supported %u\n", *(u_int8_t *)party);
|
||||
LOGP(DSCCP, LOGL_ERROR, "GTI not supported %u\n", *(u_int8_t *)party);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,8 @@ static int check_address(struct sccp_address *addr)
|
||||
if (addr->address.ssn_indicator != 1
|
||||
|| addr->address.global_title_indicator == 1
|
||||
|| addr->address.routing_indicator != 1) {
|
||||
DEBUGP(DSCCP, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
LOGP(DSCCP, LOGL_ERROR,
|
||||
"Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
*(u_int8_t *)&addr->address, addr->ssn);
|
||||
return -1;
|
||||
}
|
||||
@@ -176,7 +177,7 @@ static int _sccp_parse_optional_data(const int offset,
|
||||
return 0;
|
||||
|
||||
if (read + 1 >= room) {
|
||||
DEBUGP(DSCCP, "no place for length\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "no place for length\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -185,7 +186,8 @@ static int _sccp_parse_optional_data(const int offset,
|
||||
|
||||
|
||||
if (room <= read) {
|
||||
DEBUGP(DSCCP, "no space for the data: type: %d read: %d room: %d l2: %d\n",
|
||||
LOGP(DSCCP, LOGL_ERROR,
|
||||
"no space for the data: type: %d read: %d room: %d l2: %d\n",
|
||||
type, read, room, msgb_l2len(msgb));
|
||||
return 0;
|
||||
}
|
||||
@@ -214,7 +216,7 @@ int _sccp_parse_connection_request(struct msgb *msgb, struct sccp_parse_result *
|
||||
|
||||
/* header check */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -224,7 +226,7 @@ int _sccp_parse_connection_request(struct msgb *msgb, struct sccp_parse_result *
|
||||
return -1;
|
||||
|
||||
if (check_address(&result->called) != 0) {
|
||||
DEBUGP(DSCCP, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
*(u_int8_t *)&result->called.address, result->called.ssn);
|
||||
return -1;
|
||||
}
|
||||
@@ -236,7 +238,7 @@ int _sccp_parse_connection_request(struct msgb *msgb, struct sccp_parse_result *
|
||||
*/
|
||||
memset(&optional_data, 0, sizeof(optional_data));
|
||||
if (_sccp_parse_optional_data(optional_offset + req->optional_start, msgb, &optional_data) != 0) {
|
||||
DEBUGP(DSCCP, "parsing of optional data failed.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "parsing of optional data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -260,14 +262,14 @@ int _sccp_parse_connection_released(struct msgb *msgb, struct sccp_parse_result
|
||||
|
||||
/* we don't have enough size for the struct */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb > header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb > header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&optional_data, 0, sizeof(optional_data));
|
||||
if (_sccp_parse_optional_data(optional_offset + rls->optional_start, msgb, &optional_data) != 0) {
|
||||
DEBUGP(DSCCP, "parsing of optional data failed.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "parsing of optional data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -295,7 +297,7 @@ int _sccp_parse_connection_refused(struct msgb *msgb, struct sccp_parse_result *
|
||||
|
||||
/* header check */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -306,7 +308,7 @@ int _sccp_parse_connection_refused(struct msgb *msgb, struct sccp_parse_result *
|
||||
|
||||
memset(&optional_data, 0, sizeof(optional_data));
|
||||
if (_sccp_parse_optional_data(optional_offset + ref->optional_start, msgb, &optional_data) != 0) {
|
||||
DEBUGP(DSCCP, "parsing of optional data failed.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "parsing of optional data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -333,7 +335,7 @@ int _sccp_parse_connection_confirm(struct msgb *msgb, struct sccp_parse_result *
|
||||
|
||||
/* header check */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -344,7 +346,7 @@ int _sccp_parse_connection_confirm(struct msgb *msgb, struct sccp_parse_result *
|
||||
|
||||
memset(&optional_data, 0, sizeof(optional_data));
|
||||
if (_sccp_parse_optional_data(optional_offset + con->optional_start, msgb, &optional_data) != 0) {
|
||||
DEBUGP(DSCCP, "parsing of optional data failed.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "parsing of optional data failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -366,7 +368,7 @@ int _sccp_parse_connection_release_complete(struct msgb *msgb, struct sccp_parse
|
||||
|
||||
/* header check */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -387,13 +389,13 @@ int _sccp_parse_connection_dt1(struct msgb *msgb, struct sccp_parse_result *resu
|
||||
|
||||
/* we don't have enough size for the struct */
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb > header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb > header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dt1->segmenting != 0) {
|
||||
DEBUGP(DSCCP, "This packet has segmenting, not supported: %d\n", dt1->segmenting);
|
||||
LOGP(DSCCP, LOGL_ERROR, "This packet has segmenting, not supported: %d\n", dt1->segmenting);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -401,7 +403,7 @@ int _sccp_parse_connection_dt1(struct msgb *msgb, struct sccp_parse_result *resu
|
||||
|
||||
/* some more size checks in here */
|
||||
if (msgb_l2len(msgb) < variable_offset + dt1->variable_start + 1) {
|
||||
DEBUGP(DSCCP, "Not enough space for variable start: %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Not enough space for variable start: %u %u\n",
|
||||
msgb_l2len(msgb), dt1->variable_start);
|
||||
return -1;
|
||||
}
|
||||
@@ -410,7 +412,7 @@ int _sccp_parse_connection_dt1(struct msgb *msgb, struct sccp_parse_result *resu
|
||||
msgb->l3h = &msgb->l2h[dt1->variable_start + variable_offset + 1];
|
||||
|
||||
if (msgb_l3len(msgb) < result->data_len) {
|
||||
DEBUGP(DSCCP, "Not enough room for the payload: %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Not enough room for the payload: %u %u\n",
|
||||
msgb_l3len(msgb), result->data_len);
|
||||
return -1;
|
||||
}
|
||||
@@ -428,7 +430,7 @@ int _sccp_parse_udt(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
struct sccp_data_unitdata *udt = (struct sccp_data_unitdata *)msgb->l2h;
|
||||
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -438,7 +440,7 @@ int _sccp_parse_udt(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
return -1;
|
||||
|
||||
if (check_address(&result->called) != 0) {
|
||||
DEBUGP(DSCCP, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
*(u_int8_t *)&result->called.address, result->called.ssn);
|
||||
return -1;
|
||||
}
|
||||
@@ -447,13 +449,13 @@ int _sccp_parse_udt(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
return -1;
|
||||
|
||||
if (check_address(&result->calling) != 0) {
|
||||
DEBUGP(DSCCP, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Invalid called address according to 08.06: 0x%x 0x%x\n",
|
||||
*(u_int8_t *)&result->called.address, result->called.ssn);
|
||||
}
|
||||
|
||||
/* we don't have enough size for the data */
|
||||
if (msgb_l2len(msgb) < data_offset + udt->variable_data + 1) {
|
||||
DEBUGP(DSCCP, "msgb < header + offset %u %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header + offset %u %u %u\n",
|
||||
msgb_l2len(msgb), header_size, udt->variable_data);
|
||||
return -1;
|
||||
}
|
||||
@@ -463,7 +465,7 @@ int _sccp_parse_udt(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
result->data_len = msgb_l3len(msgb);
|
||||
|
||||
if (msgb_l3len(msgb) != msgb->l3h[-1]) {
|
||||
DEBUGP(DSCCP, "msgb is truncated is: %u should: %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb is truncated is: %u should: %u\n",
|
||||
msgb_l3len(msgb), msgb->l3h[-1]);
|
||||
return -1;
|
||||
}
|
||||
@@ -478,7 +480,7 @@ static int _sccp_parse_it(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
struct sccp_data_it *it;
|
||||
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
DEBUGP(DSCCP, "msgb < header_size %u %u\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
@@ -490,6 +492,23 @@ static int _sccp_parse_it(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _sccp_parse_err(struct msgb *msgb, struct sccp_parse_result *result)
|
||||
{
|
||||
static const u_int32_t header_size = sizeof(struct sccp_proto_err);
|
||||
|
||||
struct sccp_proto_err *err;
|
||||
|
||||
if (msgb_l2len(msgb) < header_size) {
|
||||
LOGP(DSCCP, LOGL_ERROR, "msgb < header_size %u %u\n",
|
||||
msgb_l2len(msgb), header_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = (struct sccp_proto_err *) msgb->l2h;
|
||||
result->data_len = 0;
|
||||
result->destination_local_reference = &err->destination_local_reference;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send UDT. Currently we have a fixed address...
|
||||
@@ -501,7 +520,7 @@ static int _sccp_send_data(int class, const struct sockaddr_sccp *in,
|
||||
u_int8_t *data;
|
||||
|
||||
if (msgb_l3len(payload) > 256) {
|
||||
DEBUGP(DSCCP, "The payload is too big for one udt\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "The payload is too big for one udt\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -546,7 +565,7 @@ static int _sccp_handle_read(struct msgb *msgb)
|
||||
|
||||
cb = _find_ssn(result.called.ssn);
|
||||
if (!cb || !cb->read_cb) {
|
||||
DEBUGP(DSCCP, "No routing for UDT for called SSN: %u\n", result.called.ssn);
|
||||
LOGP(DSCCP, LOGL_ERROR, "No routing for UDT for called SSN: %u\n", result.called.ssn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -595,7 +614,7 @@ static int assign_source_local_reference(struct sccp_connection *connection)
|
||||
++last_ref;
|
||||
/* do not use the reversed word and wrap around */
|
||||
if ((last_ref & 0x00FFFFFF) == 0x00FFFFFF) {
|
||||
DEBUGP(DSCCP, "Wrapped searching for a free code\n");
|
||||
LOGP(DSCCP, LOGL_DEBUG, "Wrapped searching for a free code\n");
|
||||
last_ref = 0;
|
||||
++wrapped;
|
||||
}
|
||||
@@ -606,7 +625,7 @@ static int assign_source_local_reference(struct sccp_connection *connection)
|
||||
}
|
||||
} while (wrapped != 2);
|
||||
|
||||
DEBUGP(DSCCP, "Finding a free reference failed\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Finding a free reference failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -686,13 +705,13 @@ static int _sccp_send_connection_request(struct sccp_connection *connection,
|
||||
|
||||
|
||||
if (msg && (msgb_l3len(msg) < 3 || msgb_l3len(msg) > 130)) {
|
||||
DEBUGP(DSCCP, "Invalid amount of data... %d\n", msgb_l3len(msg));
|
||||
LOGP(DSCCP, LOGL_ERROR, "Invalid amount of data... %d\n", msgb_l3len(msg));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* try to find a id */
|
||||
if (assign_source_local_reference(connection) != 0) {
|
||||
DEBUGP(DSCCP, "Assigning a local reference failed.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Assigning a local reference failed.\n");
|
||||
_sccp_set_connection_state(connection, SCCP_CONNECTION_STATE_SETUP_ERROR);
|
||||
return -1;
|
||||
}
|
||||
@@ -744,7 +763,7 @@ static int _sccp_send_connection_data(struct sccp_connection *conn, struct msgb
|
||||
int extra_size;
|
||||
|
||||
if (msgb_l3len(_data) < 2 || msgb_l3len(_data) > 256) {
|
||||
DEBUGP(DSCCP, "data size too big, segmenting unimplemented.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "data size too big, segmenting unimplemented.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -840,14 +859,14 @@ static int _sccp_handle_connection_request(struct msgb *msgb)
|
||||
|
||||
cb = _find_ssn(result.called.ssn);
|
||||
if (!cb || !cb->accept_cb) {
|
||||
DEBUGP(DSCCP, "No routing for CR for called SSN: %u\n", result.called.ssn);
|
||||
LOGP(DSCCP, LOGL_ERROR, "No routing for CR for called SSN: %u\n", result.called.ssn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check if the system wants this connection */
|
||||
connection = talloc_zero(tall_sccp_ctx, struct sccp_connection);
|
||||
if (!connection) {
|
||||
DEBUGP(DSCCP, "Allocation failed\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -859,7 +878,7 @@ static int _sccp_handle_connection_request(struct msgb *msgb)
|
||||
* one....
|
||||
*/
|
||||
if (destination_local_reference_is_free(result.source_local_reference) != 0) {
|
||||
DEBUGP(DSCCP, "Need to reject connection with existing reference\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Need to reject connection with existing reference\n");
|
||||
_sccp_send_refuse(result.source_local_reference, SCCP_REFUSAL_SCCP_FAILURE);
|
||||
talloc_free(connection);
|
||||
return -1;
|
||||
@@ -879,7 +898,7 @@ static int _sccp_handle_connection_request(struct msgb *msgb)
|
||||
llist_add_tail(&connection->list, &sccp_connections);
|
||||
|
||||
if (_sccp_send_connection_confirm(connection) != 0) {
|
||||
DEBUGP(DSCCP, "Sending confirm failed... no available source reference?\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Sending confirm failed... no available source reference?\n");
|
||||
|
||||
_sccp_send_refuse(result.source_local_reference, SCCP_REFUSAL_SCCP_FAILURE);
|
||||
_sccp_set_connection_state(connection, SCCP_CONNECTION_STATE_REFUSED);
|
||||
@@ -922,7 +941,7 @@ static int _sccp_handle_connection_release_complete(struct msgb *msgb)
|
||||
}
|
||||
|
||||
|
||||
DEBUGP(DSCCP, "Release complete of unknown connection\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Release complete of unknown connection\n");
|
||||
return -1;
|
||||
|
||||
found:
|
||||
@@ -950,7 +969,7 @@ static int _sccp_handle_connection_dt1(struct msgb *msgb)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGP(DSCCP, "No connection found for dt1 data\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "No connection found for dt1 data\n");
|
||||
return -1;
|
||||
|
||||
found:
|
||||
@@ -1009,7 +1028,7 @@ static int _sccp_handle_connection_released(struct msgb *msgb)
|
||||
}
|
||||
|
||||
|
||||
DEBUGP(DSCCP, "Unknown connection was released.\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Unknown connection was released.\n");
|
||||
return -1;
|
||||
|
||||
/* we have found a connection */
|
||||
@@ -1021,7 +1040,7 @@ found:
|
||||
|
||||
/* generate a response */
|
||||
if (_sccp_send_connection_release_complete(conn) != 0) {
|
||||
DEBUGP(DSCCP, "Sending release confirmed failed\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Sending release confirmed failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1065,7 @@ static int _sccp_handle_connection_refused(struct msgb *msgb)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGP(DSCCP, "Refused but no connection found\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Refused but no connection found\n");
|
||||
return -1;
|
||||
|
||||
found:
|
||||
@@ -1079,7 +1098,7 @@ static int _sccp_handle_connection_confirm(struct msgb *msgb)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGP(DSCCP, "Confirmed but no connection found\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Confirmed but no connection found\n");
|
||||
return -1;
|
||||
|
||||
found:
|
||||
@@ -1108,7 +1127,7 @@ int sccp_system_init(void (*outgoing)(struct msgb *data, void *ctx), void *ctx)
|
||||
int sccp_system_incoming(struct msgb *msgb)
|
||||
{
|
||||
if (msgb_l2len(msgb) < 1 ) {
|
||||
DEBUGP(DSCCP, "Too short packet\n");
|
||||
LOGP(DSCCP, LOGL_ERROR, "Too short packet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1156,7 @@ int sccp_system_incoming(struct msgb *msgb)
|
||||
return _sccp_handle_read(msgb);
|
||||
break;
|
||||
default:
|
||||
DEBUGP(DSCCP, "unimplemented msg type: %d\n", type);
|
||||
LOGP(DSCCP, LOGL_ERROR, "unimplemented msg type: %d\n", type);
|
||||
};
|
||||
|
||||
return -1;
|
||||
@@ -1148,7 +1167,7 @@ int sccp_connection_write(struct sccp_connection *connection, struct msgb *data)
|
||||
{
|
||||
if (connection->connection_state < SCCP_CONNECTION_STATE_CONFIRM
|
||||
|| connection->connection_state > SCCP_CONNECTION_STATE_ESTABLISHED) {
|
||||
DEBUGP(DSCCP, "sccp_connection_write: Wrong connection state: %p %d\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "sccp_connection_write: Wrong connection state: %p %d\n",
|
||||
connection, connection->connection_state);
|
||||
return -1;
|
||||
}
|
||||
@@ -1165,7 +1184,7 @@ int sccp_connection_send_it(struct sccp_connection *connection)
|
||||
{
|
||||
if (connection->connection_state < SCCP_CONNECTION_STATE_CONFIRM
|
||||
|| connection->connection_state > SCCP_CONNECTION_STATE_ESTABLISHED) {
|
||||
DEBUGP(DSCCP, "sccp_connection_write: Wrong connection state: %p %d\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "sccp_connection_write: Wrong connection state: %p %d\n",
|
||||
connection, connection->connection_state);
|
||||
return -1;
|
||||
}
|
||||
@@ -1178,7 +1197,7 @@ int sccp_connection_close(struct sccp_connection *connection, int cause)
|
||||
{
|
||||
if (connection->connection_state < SCCP_CONNECTION_STATE_CONFIRM
|
||||
|| connection->connection_state > SCCP_CONNECTION_STATE_ESTABLISHED) {
|
||||
DEBUGPC(DSCCP, "Can not close the connection. It was never opened: %p %d\n",
|
||||
LOGP(DSCCP, LOGL_ERROR, "Can not close the connection. It was never opened: %p %d\n",
|
||||
connection, connection->connection_state);
|
||||
return -1;
|
||||
}
|
||||
@@ -1190,7 +1209,7 @@ int sccp_connection_free(struct sccp_connection *connection)
|
||||
{
|
||||
if (connection->connection_state > SCCP_CONNECTION_STATE_NONE
|
||||
&& connection->connection_state < SCCP_CONNECTION_STATE_RELEASE_COMPLETE) {
|
||||
DEBUGP(DSCCP, "The connection needs to be released before it is freed");
|
||||
LOGP(DSCCP, LOGL_ERROR, "The connection needs to be released before it is freed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1318,6 +1337,9 @@ int sccp_parse_header(struct msgb *msg, struct sccp_parse_result *result)
|
||||
case SCCP_MSG_TYPE_IT:
|
||||
return _sccp_parse_it(msg, result);
|
||||
break;
|
||||
case SCCP_MSG_TYPE_ERR:
|
||||
return _sccp_parse_err(msg, result);
|
||||
break;
|
||||
};
|
||||
|
||||
LOGP(DSCCP, LOGL_ERROR, "Unimplemented MSG Type: 0x%x\n", type);
|
||||
|
||||
@@ -402,6 +402,16 @@ static struct gsm48_si13_info si13_default = {
|
||||
.t3192 = 500,
|
||||
.drx_timer_max = 3,
|
||||
.bs_cv_max = 15,
|
||||
.ext_info_present = 0,
|
||||
.ext_info = {
|
||||
/* The values below are just guesses ! */
|
||||
.egprs_supported = 0,
|
||||
.use_egprs_p_ch_req = 1,
|
||||
.bep_period = 4,
|
||||
.pfc_supported = 0,
|
||||
.dtm_supported = 0,
|
||||
.bss_paging_coordination = 0,
|
||||
},
|
||||
},
|
||||
.pwr_ctrl_pars = {
|
||||
.alpha = 10, /* a = 1.0 */
|
||||
@@ -448,7 +458,18 @@ static int generate_si13(u_int8_t *output, struct gsm_bts *bts)
|
||||
|
||||
int gsm_generate_si(u_int8_t *output, struct gsm_bts *bts, int type)
|
||||
{
|
||||
si_info.gprs_ind.present = bts->gprs.enabled;
|
||||
switch (bts->gprs.mode) {
|
||||
case BTS_GPRS_EGPRS:
|
||||
si13_default.cell_opts.ext_info_present = 1;
|
||||
si13_default.cell_opts.ext_info.egprs_supported = 1;
|
||||
/* fallthrough */
|
||||
case BTS_GPRS_GPRS:
|
||||
si_info.gprs_ind.present = 1;
|
||||
break;
|
||||
case BTS_GPRS_NONE:
|
||||
si_info.gprs_ind.present = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case RSL_SYSTEM_INFO_1:
|
||||
|
||||
@@ -65,11 +65,11 @@ struct buffer_data {
|
||||
#define BUFFER_DATA_FREE(D) talloc_free((D))
|
||||
|
||||
/* Make new buffer. */
|
||||
struct buffer *buffer_new(size_t size)
|
||||
struct buffer *buffer_new(void *ctx, size_t size)
|
||||
{
|
||||
struct buffer *b;
|
||||
|
||||
b = talloc_zero(tall_vty_ctx, struct buffer);
|
||||
b = talloc_zero(ctx, struct buffer);
|
||||
|
||||
if (size)
|
||||
b->size = size;
|
||||
@@ -138,7 +138,7 @@ static struct buffer_data *buffer_add(struct buffer *b)
|
||||
{
|
||||
struct buffer_data *d;
|
||||
|
||||
d = _talloc_zero(tall_vty_ctx,
|
||||
d = _talloc_zero(b,
|
||||
offsetof(struct buffer_data, data[b->size]),
|
||||
"buffer_add");
|
||||
if (!d)
|
||||
|
||||
@@ -51,10 +51,10 @@ struct vty *vty_new()
|
||||
if (!new)
|
||||
goto out;
|
||||
|
||||
new->obuf = buffer_new(0); /* Use default buffer size. */
|
||||
new->obuf = buffer_new(new, 0); /* Use default buffer size. */
|
||||
if (!new->obuf)
|
||||
goto out_new;
|
||||
new->buf = _talloc_zero(tall_vty_ctx, VTY_BUFSIZ, "vty_new->buf");
|
||||
new->buf = _talloc_zero(new, VTY_BUFSIZ, "vty_new->buf");
|
||||
if (!new->buf)
|
||||
goto out_obuf;
|
||||
|
||||
@@ -170,8 +170,7 @@ void vty_close(struct vty *vty)
|
||||
/* Check configure. */
|
||||
vty_config_unlock(vty);
|
||||
|
||||
/* FIXME: memory leak. We need to call telnet_close_client() but don't
|
||||
* have bfd */
|
||||
/* VTY_CLOSED is handled by the telnet_interface */
|
||||
vty_event(VTY_CLOSED, vty->fd, vty);
|
||||
|
||||
/* OK free vty. */
|
||||
@@ -211,7 +210,7 @@ int vty_out(struct vty *vty, const char *format, ...)
|
||||
else
|
||||
size = size * 2;
|
||||
|
||||
p = talloc_realloc_size(tall_vty_ctx, p, size);
|
||||
p = talloc_realloc_size(vty, p, size);
|
||||
if (!p)
|
||||
return -1;
|
||||
|
||||
@@ -358,7 +357,7 @@ static void vty_ensure(struct vty *vty, int length)
|
||||
{
|
||||
if (vty->max <= length) {
|
||||
vty->max *= 2;
|
||||
vty->buf = talloc_realloc_size(tall_vty_ctx, vty->buf, vty->max);
|
||||
vty->buf = talloc_realloc_size(vty, vty->buf, vty->max);
|
||||
// FIXME: check return
|
||||
}
|
||||
}
|
||||
@@ -459,7 +458,7 @@ static void vty_hist_add(struct vty *vty)
|
||||
/* Insert history entry. */
|
||||
if (vty->hist[vty->hindex])
|
||||
talloc_free(vty->hist[vty->hindex]);
|
||||
vty->hist[vty->hindex] = talloc_strdup(tall_vty_ctx, vty->buf);
|
||||
vty->hist[vty->hindex] = talloc_strdup(vty, vty->buf);
|
||||
|
||||
/* History index rotation. */
|
||||
vty->hindex++;
|
||||
@@ -916,7 +915,7 @@ static void vty_complete_command(struct vty *vty)
|
||||
vty_backward_pure_word(vty);
|
||||
vty_insert_word_overwrite(vty, matched[0]);
|
||||
vty_self_insert(vty, ' ');
|
||||
//talloc_free(matched[0]);
|
||||
talloc_free(matched[0]);
|
||||
break;
|
||||
case CMD_COMPLETE_MATCH:
|
||||
vty_prompt(vty);
|
||||
@@ -924,8 +923,6 @@ static void vty_complete_command(struct vty *vty)
|
||||
vty_backward_pure_word(vty);
|
||||
vty_insert_word_overwrite(vty, matched[0]);
|
||||
talloc_free(matched[0]);
|
||||
vector_only_index_free(matched);
|
||||
return;
|
||||
break;
|
||||
case CMD_COMPLETE_LIST_MATCH:
|
||||
for (i = 0; matched[i] != NULL; i++) {
|
||||
@@ -966,7 +963,7 @@ vty_describe_fold(struct vty *vty, int cmd_width,
|
||||
return;
|
||||
}
|
||||
|
||||
buf = _talloc_zero(tall_vty_ctx, strlen(desc->str) + 1, "describe_fold");
|
||||
buf = _talloc_zero(vty, strlen(desc->str) + 1, "describe_fold");
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <openbsc/telnet_interface.h>
|
||||
#include <openbsc/vty.h>
|
||||
#include <openbsc/ipaccess.h>
|
||||
#include <openbsc/paging.h>
|
||||
|
||||
static struct gsm_network *gsmnet;
|
||||
|
||||
@@ -196,7 +197,8 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
|
||||
net_dump_nmstate(vty, &bts->nm_state);
|
||||
vty_out(vty, " Site Mgr NM State: ");
|
||||
net_dump_nmstate(vty, &bts->site_mgr.nm_state);
|
||||
vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
|
||||
vty_out(vty, " Paging: %u pending requests, %u free slots%s",
|
||||
paging_pending_requests_nr(bts),
|
||||
bts->paging.available_slots, VTY_NEWLINE);
|
||||
if (!is_ipaccess_bts(bts)) {
|
||||
vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
|
||||
@@ -234,6 +236,36 @@ DEFUN(show_bts, show_bts_cmd, "show bts [number]",
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(test_bts_lchan_alloc, test_bts_lchan_alloc_cmd, "test bts alloc (sdcch|tch_h|tch_f)",
|
||||
"Test command to allocate all channels. You will need to restart. To free these channels.\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
int bts_nr;
|
||||
|
||||
enum gsm_chan_t type = GSM_LCHAN_NONE;
|
||||
|
||||
if (strcmp("sdcch", argv[0]) == 0)
|
||||
type = GSM_LCHAN_SDCCH;
|
||||
else if (strcmp("tch_h", argv[0]) == 0)
|
||||
type = GSM_LCHAN_TCH_H;
|
||||
else if (strcmp("tch_f", argv[0]) == 0)
|
||||
type = GSM_LCHAN_TCH_F;
|
||||
else {
|
||||
vty_out(vty, "Unknown mode for allocation.%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
for (bts_nr = 0; bts_nr < net->num_bts; ++bts_nr) {
|
||||
struct gsm_bts *bts = gsm_bts_num(net, bts_nr);
|
||||
struct gsm_lchan *lchan;
|
||||
|
||||
/* alloc the channel */
|
||||
while ((lchan = lchan_alloc(bts, type, 0)) != NULL)
|
||||
rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* utility functions */
|
||||
static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
|
||||
const char *ts, const char *ss)
|
||||
@@ -276,6 +308,9 @@ static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
|
||||
int i;
|
||||
|
||||
vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
|
||||
vty_out(vty, " rf_locked %u%s",
|
||||
trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
|
||||
vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
|
||||
vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
|
||||
@@ -315,6 +350,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
|
||||
vty_out(vty, " rach max transmission %u%s",
|
||||
rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
|
||||
VTY_NEWLINE);
|
||||
|
||||
if (bts->rach_b_thresh != -1)
|
||||
vty_out(vty, " rach nm busy threshold %u%s",
|
||||
bts->rach_b_thresh, VTY_NEWLINE);
|
||||
if (bts->rach_ldavg_slots != -1)
|
||||
vty_out(vty, " rach nm load average %u%s",
|
||||
bts->rach_ldavg_slots, VTY_NEWLINE);
|
||||
if (bts->si_common.rach_control.cell_bar)
|
||||
vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
|
||||
if (is_ipaccess_bts(bts)) {
|
||||
@@ -325,8 +367,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
|
||||
config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
|
||||
vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
|
||||
}
|
||||
vty_out(vty, " gprs enabled %u%s", bts->gprs.enabled, VTY_NEWLINE);
|
||||
if (bts->gprs.enabled) {
|
||||
|
||||
/* if we have a limit, write it */
|
||||
if (bts->paging.free_chans_need >= 0)
|
||||
vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
|
||||
|
||||
vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
|
||||
VTY_NEWLINE);
|
||||
if (bts->gprs.mode != BTS_GPRS_NONE) {
|
||||
vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
|
||||
@@ -430,6 +478,10 @@ static int config_write_net(struct vty *vty)
|
||||
|
||||
if (gsmnet->bsc_token)
|
||||
vty_out(vty, " bsc_token %s%s", gsmnet->bsc_token, VTY_NEWLINE);
|
||||
vty_out(vty, " msc ip %s%s", gsmnet->msc_ip, VTY_NEWLINE);
|
||||
vty_out(vty, " msc port %d%s", gsmnet->msc_port, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout ping %d%s", gsmnet->ping_timeout, VTY_NEWLINE);
|
||||
vty_out(vty, " timeout pong %d%s", gsmnet->pong_timeout, VTY_NEWLINE);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -577,10 +629,6 @@ DEFUN(show_ts,
|
||||
|
||||
static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
|
||||
{
|
||||
int rc;
|
||||
struct gsm_auth_info ainfo;
|
||||
struct gsm_auth_tuple atuple;
|
||||
|
||||
vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
|
||||
subscr->authorized, VTY_NEWLINE);
|
||||
if (subscr->name)
|
||||
@@ -916,46 +964,6 @@ DEFUN(show_paging,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_stats,
|
||||
show_stats_cmd,
|
||||
"show statistics",
|
||||
SHOW_STR "Display network statistics\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
|
||||
vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
|
||||
counter_get(net->stats.chreq.total),
|
||||
counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
|
||||
vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s",
|
||||
counter_get(net->stats.loc_upd_type.attach),
|
||||
counter_get(net->stats.loc_upd_type.normal),
|
||||
counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE);
|
||||
vty_out(vty, "IMSI Detach Indications : %lu%s",
|
||||
counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE);
|
||||
vty_out(vty, "Location Update Response: %lu accept, %lu reject%s",
|
||||
counter_get(net->stats.loc_upd_resp.accept),
|
||||
counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE);
|
||||
vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
|
||||
counter_get(net->stats.paging.attempted),
|
||||
counter_get(net->stats.paging.completed),
|
||||
counter_get(net->stats.paging.expired), VTY_NEWLINE);
|
||||
vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, "
|
||||
"%lu completed, %lu failed%s",
|
||||
counter_get(net->stats.handover.attempted),
|
||||
counter_get(net->stats.handover.no_channel),
|
||||
counter_get(net->stats.handover.timeout),
|
||||
counter_get(net->stats.handover.completed),
|
||||
counter_get(net->stats.handover.failed), VTY_NEWLINE);
|
||||
vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s",
|
||||
counter_get(net->stats.sms.submitted),
|
||||
counter_get(net->stats.sms.no_receiver), VTY_NEWLINE);
|
||||
vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s",
|
||||
counter_get(net->stats.sms.delivered),
|
||||
counter_get(net->stats.sms.rp_err_mem),
|
||||
counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(drop_bts,
|
||||
drop_bts_cmd,
|
||||
"drop bts connection <0-65535> (oml|rsl)",
|
||||
@@ -993,7 +1001,7 @@ DEFUN(drop_bts,
|
||||
ipaccess_drop_rsl(trx);
|
||||
}
|
||||
} else {
|
||||
vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
|
||||
vty_out(vty, "Argument must be 'oml' or 'rsl'.%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
@@ -1309,6 +1317,44 @@ DEFUN(cfg_net_pag_any_tch,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_msc_ip,
|
||||
cfg_net_msc_ip_cmd,
|
||||
"msc ip IP",
|
||||
"Set the MSC/MUX IP address.")
|
||||
{
|
||||
if (gsmnet->msc_ip)
|
||||
talloc_free(gsmnet->msc_ip);
|
||||
gsmnet->msc_ip = talloc_strdup(gsmnet, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_msc_port,
|
||||
cfg_net_msc_port_cmd,
|
||||
"msc port <1-65000>",
|
||||
"Set the MSC/MUX port.")
|
||||
{
|
||||
gsmnet->msc_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_ping_time,
|
||||
cfg_net_ping_time_cmd,
|
||||
"timeout ping NR",
|
||||
"Set the PING interval, negative for not sending PING")
|
||||
{
|
||||
gsmnet->ping_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_net_pong_time,
|
||||
cfg_net_pong_time_cmd,
|
||||
"timeout pong NR",
|
||||
"Set the time to wait for a PONG.")
|
||||
{
|
||||
gsmnet->pong_timeout = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
#define DECLARE_TIMER(number, doc) \
|
||||
DEFUN(cfg_net_T##number, \
|
||||
cfg_net_T##number##_cmd, \
|
||||
@@ -1584,6 +1630,26 @@ DEFUN(cfg_bts_rach_max_trans,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_rach_nm_b_thresh,
|
||||
cfg_bts_rach_nm_b_thresh_cmd,
|
||||
"rach nm busy threshold <0-255>",
|
||||
"Set the NM Busy Threshold in DB")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
bts->rach_b_thresh = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_rach_nm_ldavg,
|
||||
cfg_bts_rach_nm_ldavg_cmd,
|
||||
"rach nm load average <0-65535>",
|
||||
"Set the NM Loadaver Slots value")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
bts->rach_ldavg_slots = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
|
||||
"cell barred (0|1)",
|
||||
"Should this cell be barred from access?")
|
||||
@@ -1640,12 +1706,12 @@ DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
|
||||
"gprs cell bvci <0-65535>",
|
||||
"gprs cell bvci <2-65535>",
|
||||
"GPRS BSSGP VC Identifier")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1661,7 +1727,7 @@ DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1679,7 +1745,7 @@ DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
|
||||
struct gsm_bts *bts = vty->index;
|
||||
int idx = atoi(argv[0]);
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1696,7 +1762,7 @@ DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
|
||||
struct gsm_bts *bts = vty->index;
|
||||
int idx = atoi(argv[0]);
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1713,7 +1779,7 @@ DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
|
||||
struct gsm_bts *bts = vty->index;
|
||||
int idx = atoi(argv[0]);
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1731,7 +1797,7 @@ DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
|
||||
int idx = atoi(argv[0]);
|
||||
struct in_addr ia;
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1742,13 +1808,23 @@ DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
|
||||
"paging free FREE_NR",
|
||||
"Only page when having a certain amount of free slots. -1 to disable")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
bts->paging.free_chans_need = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
|
||||
"gprs routing area <0-255>",
|
||||
"GPRS Routing Area Code")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
if (!bts->gprs.enabled) {
|
||||
if (bts->gprs.mode == BTS_GPRS_NONE) {
|
||||
vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@@ -1758,13 +1834,13 @@ DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_bts_gprs_enabled, cfg_bts_gprs_enabled_cmd,
|
||||
"gprs enabled <0-1>",
|
||||
"GPRS Enabled on this BTS")
|
||||
DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
|
||||
"gprs mode (none|gprs|egprs)",
|
||||
"GPRS Mode for this BTS")
|
||||
{
|
||||
struct gsm_bts *bts = vty->index;
|
||||
|
||||
bts->gprs.enabled = atoi(argv[0]);
|
||||
bts->gprs.mode = bts_gprs_mode_parse(argv[0]);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@@ -1947,6 +2023,8 @@ DEFUN(cfg_ts_e1_subslot,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
extern int bsc_vty_init_extra(struct gsm_network *net);
|
||||
|
||||
int bsc_vty_init(struct gsm_network *net)
|
||||
{
|
||||
gsmnet = net;
|
||||
@@ -1965,9 +2043,9 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(VIEW_NODE, &show_e1ts_cmd);
|
||||
|
||||
install_element(VIEW_NODE, &show_paging_cmd);
|
||||
install_element(VIEW_NODE, &show_stats_cmd);
|
||||
|
||||
install_element(VIEW_NODE, &drop_bts_cmd);
|
||||
install_element(VIEW_NODE, &test_bts_lchan_alloc_cmd);
|
||||
|
||||
openbsc_vty_add_cmds();
|
||||
|
||||
@@ -2009,6 +2087,10 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_bsc_token_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_ip_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_msc_port_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_ping_time_cmd);
|
||||
install_element(GSMNET_NODE, &cfg_net_pong_time_cmd);
|
||||
|
||||
install_element(GSMNET_NODE, &cfg_bts_cmd);
|
||||
install_node(&bts_node, config_write_bts);
|
||||
@@ -2026,12 +2108,14 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(BTS_NODE, &cfg_bts_challoc_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_enabled_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
|
||||
@@ -2039,6 +2123,7 @@ int bsc_vty_init(struct gsm_network *net)
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
|
||||
install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
|
||||
|
||||
install_element(BTS_NODE, &cfg_trx_cmd);
|
||||
install_node(&trx_node, dummy_config_write);
|
||||
|
||||
@@ -27,13 +27,39 @@
|
||||
#include <vty/vty.h>
|
||||
|
||||
#include <openbsc/gsm_data.h>
|
||||
#include <openbsc/vty.h>
|
||||
|
||||
static struct gsmnet *gsmnet = NULL;
|
||||
#include <sccp/sccp.h>
|
||||
|
||||
static struct gsm_network *gsmnet = NULL;
|
||||
|
||||
extern struct llist_head *bsc_sccp_connections();
|
||||
|
||||
DEFUN(show_bsc, show_bsc_cmd, "show bsc",
|
||||
SHOW_STR "Display information about the BSC\n")
|
||||
{
|
||||
vty_out(vty, "BSC... not implemented yet%s", VTY_NEWLINE);
|
||||
struct bss_sccp_connection_data *con;
|
||||
|
||||
vty_out(vty, "BSC Information%s", VTY_NEWLINE);
|
||||
llist_for_each_entry(con, bsc_sccp_connections(), active_connections) {
|
||||
vty_out(vty, " Connection: LCHAN: %p sec LCHAN: %p SCCP src: %d dest: %d%s",
|
||||
con->lchan, con->secondary_lchan,
|
||||
con->sccp ? (int) sccp_src_ref_to_int(&con->sccp->source_local_reference) : -1,
|
||||
con->sccp ? (int) sccp_src_ref_to_int(&con->sccp->destination_local_reference) : -1,
|
||||
VTY_NEWLINE);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_stats,
|
||||
show_stats_cmd,
|
||||
"show statistics",
|
||||
SHOW_STR "Display network statistics\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
|
||||
openbsc_vty_print_statistics(vty, net);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -43,6 +69,7 @@ int bsc_vty_init_extra(struct gsm_network *net)
|
||||
|
||||
/* get runtime information */
|
||||
install_element(VIEW_NODE, &show_bsc_cmd);
|
||||
install_element(VIEW_NODE, &show_stats_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -228,6 +228,23 @@ DEFUN(diable_logging,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
|
||||
{
|
||||
vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
|
||||
counter_get(net->stats.chreq.total),
|
||||
counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
|
||||
vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
|
||||
counter_get(net->stats.chan.rf_fail),
|
||||
counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
|
||||
vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
|
||||
counter_get(net->stats.paging.attempted),
|
||||
counter_get(net->stats.paging.completed),
|
||||
counter_get(net->stats.paging.expired), VTY_NEWLINE);
|
||||
vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
|
||||
counter_get(net->stats.bts.oml_fail),
|
||||
counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
|
||||
}
|
||||
|
||||
void openbsc_vty_add_cmds()
|
||||
{
|
||||
install_element(VIEW_NODE, &enable_logging_cmd);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <osmocore/talloc.h>
|
||||
#include <openbsc/signal.h>
|
||||
#include <openbsc/debug.h>
|
||||
#include <openbsc/vty.h>
|
||||
|
||||
static struct gsm_network *gsmnet;
|
||||
|
||||
@@ -57,7 +58,7 @@ static int dummy_config_write(struct vty *v)
|
||||
|
||||
static struct buffer *argv_to_buffer(int argc, const char *argv[], int base)
|
||||
{
|
||||
struct buffer *b = buffer_new(1024);
|
||||
struct buffer *b = buffer_new(NULL, 1024);
|
||||
int i;
|
||||
|
||||
if (!b)
|
||||
@@ -502,6 +503,41 @@ static int scall_cbfn(unsigned int subsys, unsigned int signal,
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFUN(show_stats,
|
||||
show_stats_cmd,
|
||||
"show statistics",
|
||||
SHOW_STR "Display network statistics\n")
|
||||
{
|
||||
struct gsm_network *net = gsmnet;
|
||||
|
||||
openbsc_vty_print_statistics(vty, net);
|
||||
vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s",
|
||||
counter_get(net->stats.loc_upd_type.attach),
|
||||
counter_get(net->stats.loc_upd_type.normal),
|
||||
counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE);
|
||||
vty_out(vty, "IMSI Detach Indications : %lu%s",
|
||||
counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE);
|
||||
vty_out(vty, "Location Update Response: %lu accept, %lu reject%s",
|
||||
counter_get(net->stats.loc_upd_resp.accept),
|
||||
counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE);
|
||||
vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, "
|
||||
"%lu completed, %lu failed%s",
|
||||
counter_get(net->stats.handover.attempted),
|
||||
counter_get(net->stats.handover.no_channel),
|
||||
counter_get(net->stats.handover.timeout),
|
||||
counter_get(net->stats.handover.completed),
|
||||
counter_get(net->stats.handover.failed), VTY_NEWLINE);
|
||||
vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s",
|
||||
counter_get(net->stats.sms.submitted),
|
||||
counter_get(net->stats.sms.no_receiver), VTY_NEWLINE);
|
||||
vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s",
|
||||
counter_get(net->stats.sms.delivered),
|
||||
counter_get(net->stats.sms.rp_err_mem),
|
||||
counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int bsc_vty_init_extra(struct gsm_network *net)
|
||||
{
|
||||
gsmnet = net;
|
||||
@@ -517,6 +553,7 @@ int bsc_vty_init_extra(struct gsm_network *net)
|
||||
install_element(VIEW_NODE, &subscriber_silent_sms_cmd);
|
||||
install_element(VIEW_NODE, &subscriber_silent_call_start_cmd);
|
||||
install_element(VIEW_NODE, &subscriber_silent_call_stop_cmd);
|
||||
install_element(VIEW_NODE, &show_stats_cmd);
|
||||
|
||||
install_element(CONFIG_NODE, &cfg_subscr_cmd);
|
||||
install_node(&subscr_node, dummy_config_write);
|
||||
|
||||
@@ -96,6 +96,12 @@ static const u_int8_t connnection_it[] = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
/* error in both directions */
|
||||
static const u_int8_t proto_error[] = {
|
||||
0x00, 0x05, 0xfd,
|
||||
0x0f, 0x22, 0x33, 0x44, 0x00,
|
||||
};
|
||||
|
||||
/* MGCP wrap... */
|
||||
static const u_int8_t mgcp_msg[] = {
|
||||
0x00, 0x03, 0xfc,
|
||||
@@ -176,6 +182,19 @@ static const struct filter_result results[] = {
|
||||
.dir = DIR_MSC,
|
||||
.result = 0,
|
||||
},
|
||||
{
|
||||
.data = proto_error,
|
||||
.length = ARRAY_SIZE(proto_error),
|
||||
.dir = DIR_BSC,
|
||||
.result = 0,
|
||||
},
|
||||
{
|
||||
.data = proto_error,
|
||||
.length = ARRAY_SIZE(proto_error),
|
||||
.dir = DIR_MSC,
|
||||
.result = 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
static void test_filter(void)
|
||||
@@ -242,12 +261,13 @@ static void test_contrack()
|
||||
fprintf(stderr, "Testing connection tracking.\n");
|
||||
nat = bsc_nat_alloc();
|
||||
con = bsc_connection_alloc(nat);
|
||||
con->cfg = bsc_config_alloc(nat, "foo", 23);
|
||||
msg = msgb_alloc(4096, "test");
|
||||
|
||||
/* 1.) create a connection */
|
||||
copy_to_msg(msg, bsc_cr, sizeof(bsc_cr));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
|
||||
if (con_found != NULL) {
|
||||
fprintf(stderr, "Con should not exist %p\n", con_found);
|
||||
abort();
|
||||
@@ -257,7 +277,7 @@ static void test_contrack()
|
||||
fprintf(stderr, "Failed to create a ref\n");
|
||||
abort();
|
||||
}
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
|
||||
if (!con_found || con_found->bsc != con) {
|
||||
fprintf(stderr, "Failed to find the con: %p\n", con_found);
|
||||
abort();
|
||||
@@ -281,7 +301,7 @@ static void test_contrack()
|
||||
/* 3.) send some data */
|
||||
copy_to_msg(msg, bsc_dtap, sizeof(bsc_dtap));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
|
||||
VERIFY(con_found, con, msg, bsc_dtap_patched, "BSC DTAP");
|
||||
|
||||
/* 4.) receive some data */
|
||||
@@ -299,7 +319,7 @@ static void test_contrack()
|
||||
/* 6.) confirm the connection close */
|
||||
copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
|
||||
if (!con_found || con_found->bsc != con) {
|
||||
fprintf(stderr, "Failed to find the con: %p\n", con_found);
|
||||
abort();
|
||||
@@ -313,7 +333,7 @@ static void test_contrack()
|
||||
|
||||
copy_to_msg(msg, bsc_rlc, sizeof(bsc_rlc));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, nat);
|
||||
con_found = patch_sccp_src_ref_to_msc(msg, parsed, con);
|
||||
|
||||
/* verify that it is gone */
|
||||
if (con_found != NULL) {
|
||||
@@ -329,6 +349,7 @@ static void test_contrack()
|
||||
|
||||
static void test_paging(void)
|
||||
{
|
||||
int lac;
|
||||
struct bsc_nat *nat;
|
||||
struct bsc_connection *con;
|
||||
struct bsc_nat_parsed *parsed;
|
||||
@@ -347,7 +368,7 @@ static void test_paging(void)
|
||||
|
||||
/* Test completely bad input */
|
||||
copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
|
||||
if (bsc_nat_find_bsc(nat, msg) != 0) {
|
||||
if (bsc_nat_find_bsc(nat, msg, &lac) != 0) {
|
||||
fprintf(stderr, "Should have not found anything.\n");
|
||||
abort();
|
||||
}
|
||||
@@ -355,7 +376,7 @@ static void test_paging(void)
|
||||
/* Test it by not finding it */
|
||||
copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
if (bsc_nat_find_bsc(nat, msg) != 0) {
|
||||
if (bsc_nat_find_bsc(nat, msg, &lac) != 0) {
|
||||
fprintf(stderr, "Should have not found aynthing.\n");
|
||||
abort();
|
||||
}
|
||||
@@ -365,7 +386,7 @@ static void test_paging(void)
|
||||
cfg.lac = 8213;
|
||||
copy_to_msg(msg, paging_by_lac_cmd, sizeof(paging_by_lac_cmd));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
if (bsc_nat_find_bsc(nat, msg) != con) {
|
||||
if (bsc_nat_find_bsc(nat, msg, &lac) != con) {
|
||||
fprintf(stderr, "Should have found it.\n");
|
||||
abort();
|
||||
}
|
||||
@@ -374,6 +395,8 @@ static void test_paging(void)
|
||||
|
||||
static void test_mgcp_ass_tracking(void)
|
||||
{
|
||||
struct bsc_connection *bsc;
|
||||
struct bsc_nat *nat;
|
||||
struct sccp_connections con;
|
||||
struct bsc_nat_parsed *parsed;
|
||||
struct msgb *msg;
|
||||
@@ -381,6 +404,14 @@ static void test_mgcp_ass_tracking(void)
|
||||
fprintf(stderr, "Testing MGCP.\n");
|
||||
memset(&con, 0, sizeof(con));
|
||||
|
||||
nat = bsc_nat_alloc();
|
||||
nat->bsc_endpoints = talloc_zero_array(nat,
|
||||
struct bsc_endpoint,
|
||||
33);
|
||||
bsc = bsc_connection_alloc(nat);
|
||||
bsc->cfg = bsc_config_alloc(nat, "foo", 2323);
|
||||
con.bsc = bsc;
|
||||
|
||||
msg = msgb_alloc(4096, "foo");
|
||||
copy_to_msg(msg, ass_cmd, sizeof(ass_cmd));
|
||||
parsed = bsc_nat_parse(msg);
|
||||
@@ -400,11 +431,13 @@ static void test_mgcp_ass_tracking(void)
|
||||
}
|
||||
talloc_free(parsed);
|
||||
|
||||
bsc_mgcp_clear(&con);
|
||||
bsc_mgcp_dlcx(&con);
|
||||
if (con.bsc_timeslot != -1 || con.msc_timeslot != -1) {
|
||||
fprintf(stderr, "Clearing should remove the mapping.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
talloc_free(nat);
|
||||
}
|
||||
|
||||
/* test the code to find a given connection */
|
||||
@@ -431,14 +464,14 @@ static void test_mgcp_find(void)
|
||||
abort();
|
||||
}
|
||||
|
||||
if (bsc_mgcp_find_con(nat, 12) != con) {
|
||||
if (bsc_mgcp_find_con(nat, 12) != sccp_con) {
|
||||
fprintf(stderr, "Didn't find the connection\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
sccp_con->msc_timeslot = 0;
|
||||
sccp_con->bsc_timeslot = 0;
|
||||
if (bsc_mgcp_find_con(nat, 1) != con) {
|
||||
if (bsc_mgcp_find_con(nat, 1) != sccp_con) {
|
||||
fprintf(stderr, "Didn't find the connection\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -38,4 +38,6 @@ int main(int argc, char** argv)
|
||||
DEBUGP(DRLL, "You should see this\n");
|
||||
DEBUGP(DCC, "You should see this\n");
|
||||
DEBUGP(DMM, "You should not see this\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,10 @@ static const u_int8_t it_test[] = {
|
||||
0x10, 0x01, 0x07,
|
||||
0x94, 0x01, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00 };
|
||||
|
||||
static const u_int8_t proto_err[] = {
|
||||
0x0f, 0x0c, 0x04, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const struct sccp_parse_header_result parse_result[] = {
|
||||
{
|
||||
.msg_type = SCCP_MSG_TYPE_IT,
|
||||
@@ -287,6 +291,21 @@ static const struct sccp_parse_header_result parse_result[] = {
|
||||
.input = it_test,
|
||||
.input_len = sizeof(it_test),
|
||||
},
|
||||
{
|
||||
.msg_type = SCCP_MSG_TYPE_ERR,
|
||||
.wanted_len = 0,
|
||||
.src_ssn = -1,
|
||||
.dst_ssn = -1,
|
||||
.has_src_ref = 0,
|
||||
.has_dst_ref = 1,
|
||||
.dst_ref = {
|
||||
.octet1 = 0x0c,
|
||||
.octet2 = 0x04,
|
||||
.octet3 = 0x00,
|
||||
},
|
||||
.input = proto_err,
|
||||
.input_len = sizeof(proto_err),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -777,7 +796,7 @@ static void test_sccp_parsing(void)
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
if (sccp_parse_header(msg, &result) != 0) {
|
||||
fprintf(stderr, "Failed to parse test: %d\n", current_test);
|
||||
fprintf(stderr, "Failed to sccp parse test: %d\n", current_test);
|
||||
} else {
|
||||
if (parse_result[current_test].wanted_len != result.data_len) {
|
||||
fprintf(stderr, "Unexpected data length.\n");
|
||||
|
||||
Reference in New Issue
Block a user