Commit Graph

4375 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 5dd295ff44 bsc: Timers are in seconds, clarify that in the online help 2014-04-11 19:30:53 +02:00
Holger Hans Peter Freyther 444d7d8e65 ipa: Fix compiler warnings about aliasing
Use memcpy to copy from the OML message into the stack and then
convert the network byte order.

network_listen.c: In function ‘test_rep’:
network_listen.c:145:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  test_rep_len = ntohs(*(uint16_t *) &foh->data[3]);
  ^
network_listen.c:153:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
   ^
network_listen.c:164:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
   ^
network_listen.c:130:11: warning: variable ‘test_rep_len’ set but not used [-Wunused-but-set-variable]
  uint16_t test_rep_len, ferr_list_len;
2014-04-04 13:01:28 +02:00
Holger Hans Peter Freyther 686191a1c9 oml: Fix compiler warning about aliasing
Make the fill_fom_hdr return the header and use it throughout.

  CC       abis_nm.o
In file included from ../../include/openbsc/debug.h:8:0,
                 from abis_nm.c:38:
abis_nm.c: In function ‘abis_nm_opstart’:
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
2014-04-04 12:56:34 +02:00
Holger Hans Peter Freyther 90e9a445c8 gprs: Fix compiler warnings in sgsn_main.c
sgsn_main.c: In function ‘main’:
sgsn_main.c:345:2: warning: implicit declaration of function ‘gprs_sndcp_vty_init’ [-Wimplicit-function-declaration]
  gprs_sndcp_vty_init();
  ^
sgsn_main.c:354:2: warning: implicit declaration of function ‘sgsn_gtp_init’ [-Wimplicit-function-declaration]
  rc = sgsn_gtp_init(&sgsn_inst);
  ^
2014-04-04 12:51:28 +02:00
Holger Hans Peter Freyther 5a1b329a9e gprs: Fix compiler warnings ini gprs_sndcp_vty.c
CC       gprs_sndcp_vty.o
gprs_sndcp_vty.c: In function ‘vty_dump_sne’:
gprs_sndcp_vty.c:46:15: warning: unused variable ‘i’ [-Wunused-variable]
  unsigned int i;
2014-04-04 12:49:38 +02:00
Holger Hans Peter Freyther 65762e0455 gprs: Fix compiler warnings in sgsn_libgtp.c
CC       sgsn_libgtp.o
sgsn_libgtp.c: In function ‘create_pdp_conf’:
sgsn_libgtp.c:262:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
sgsn_libgtp.c: In function ‘cb_data_ind’:
sgsn_libgtp.c:432:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
2014-04-04 12:49:00 +02:00
Holger Hans Peter Freyther 744568b569 gprs: Fix compiler warnings in the gprs_llc.c code
CC       gprs_llc.o
gprs_llc.c: In function ‘t200_expired’:
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_UNASSIGNED’ not handled in switch [-Wswitch]
  switch (lle->state) {
  ^
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_ASSIGNED_ADM’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_REMOTE_EST’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_ABM’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_TIMER_REC’ not handled in switch [-Wswitch]
gprs_llc.c: In function ‘gprs_llc_hdr_rx’:
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_NULL’ not handled in switch [-Wswitch]
  switch (gph->cmd) {
  ^
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_RR’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_ACK’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_RNR’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_SACK’ not handled in switch [-Wswitch]
gprs_llc.c: In function ‘gprs_llc_rcvmsg’:
gprs_llc.c:791:23: warning: unused variable ‘udh’ [-Wunused-variable]
  struct bssgp_ud_hdr *udh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
                       ^
gprs_llc.c: At top level:
gprs_llc.c:311:13: warning: ‘t200_expired’ defined but not used [-Wunused-function]
 static void t200_expired(void *data)
             ^
gprs_llc.c:337:13: warning: ‘t201_expired’ defined but not used [-Wunused-function]
 static void t201_expired(void *data)
2014-04-04 12:47:32 +02:00
Holger Hans Peter Freyther cfee952e23 gprs: Fix compiler warnings in gprs_sndcp.c
CC       gprs_sndcp.o
gprs_sndcp.c: In function ‘defrag_input’:
gprs_sndcp.c:188:25: warning: variable ‘scomph’ set but not used [-Wunused-but-set-variable]
  struct sndcp_comp_hdr *scomph = NULL;
                         ^
gprs_sndcp.c: In function ‘sndcp_llunitdata_ind’:
gprs_sndcp.c:512:11: warning: variable ‘npdu_num’ set but not used [-Wunused-but-set-variable]
  uint16_t npdu_num;
           ^
gprs_sndcp.c: At top level:
gprs_sndcp.c:565:12: warning: ‘sndcp_ll_reset_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_reset_ind(struct gprs_sndcp_entity *se)
            ^
gprs_sndcp.c:573:12: warning: ‘sndcp_ll_status_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_status_ind()
            ^
2014-04-04 12:43:08 +02:00
Holger Hans Peter Freyther 1768a5765d gprs: Reduce the number of compiler warnings in gprs_gmm.c
CC       gprs_gmm.o
gprs_gmm.c: In function ‘gsm48_tx_gmm_att_ack’:
gprs_gmm.c:350:11: warning: unused variable ‘ptsig’ [-Wunused-variable]
  uint8_t *ptsig, *mid;
           ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_auth_ciph_resp’:
gprs_gmm.c:524:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_att_req’:
gprs_gmm.c:703:9: warning: implicit declaration of function ‘sgsn_acl_lookup’ [-Wimplicit-function-declaration]
         !sgsn_acl_lookup(mi_string))) {
         ^
gprs_gmm.c:632:40: warning: variable ‘old_ra_info’ set but not used [-Wunused-but-set-variable]
  uint8_t *cur = gh->data, *msnc, *mi, *old_ra_info, *ms_ra_acc_cap;
                                        ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_ra_upd_req’:
gprs_gmm.c:915:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
gprs_gmm.c:910:11: warning: variable ‘ms_ra_acc_cap’ set but not used [-Wunused-but-set-variable]
  uint8_t *ms_ra_acc_cap;
           ^
gprs_gmm.c: At top level:
gprs_gmm.c:458:12: warning: ‘gsm48_tx_gmm_auth_ciph_req’ defined but not used [-Wunused-function]
 static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, uint8_t *rand,
            ^
gprs_gmm.c:501:12: warning: ‘gsm48_tx_gmm_auth_ciph_rej’ defined but not used [-Wunused-function]
 static int gsm48_tx_gmm_auth_ciph_rej(struct sgsn_mm_ctx *mm)
            ^
gprs_gmm.c:1169:13: warning: ‘msgb_put_pdp_addr_ipv4’ defined but not used [-Wunused-function]
 static void msgb_put_pdp_addr_ipv4(struct msgb *msg, uint32_t ipaddr)
             ^
gprs_gmm.c:1180:13: warning: ‘msgb_put_pdp_addr_ppp’ defined but not used [-Wunused-function]
 static void msgb_put_pdp_addr_ppp(struct msgb *msg)
2014-04-04 12:41:03 +02:00
Holger Hans Peter Freyther 4766524d17 rsl: Add missing breaks in the code
Given that the method is only called for a traffic channels the
missing breaks didn't hurt.

Fixes: Coverity CID 1040731, CID 1040732, CID 1040733,
       CID 1040734
2014-04-04 12:17:28 +02:00
Holger Hans Peter Freyther d219507d63 sgsn: Comparing array to NULL is not useful
.v is a unsigned char array with up-to 255 elements. We do not
need to add a null check here.

Fixes: Coverity CID 1040719
2014-04-04 11:55:21 +02:00
Holger Hans Peter Freyther bd30cd3e1f bsc/msc: Extension can never be NULL use strlen instead
Fixes: Coverity CID 1040717
2014-04-04 11:53:18 +02:00
Holger Hans Peter Freyther cb4567f117 msc: Name is never NULL use strlen to check if it is empty
Fixes: Coverity CID 1040716
2014-04-04 11:50:41 +02:00
Holger Hans Peter Freyther 8a080be4ad abis: Check for failure of ftell
In case ftell -1 will be returned. Coverity complained that the
pos we pass to fseek might be negative. In case the ftell fails
we are at the last line for sure.

Fixes: Coverity CID 1040721
2014-04-04 11:49:45 +02:00
Jacob Erlbeck 4ace424fa7 ipa: Be consistent in checking conn->cfg (Coverity)
Coverity complains about checking connection->cfg in
bsc_close_connection() at one place but not at the second.

This patch fixes this by adding a check before accessing cfg when
generating the 'partial message' log message.

Fixes: Coverity CID 1195180
Sponsored-by: On-Waves ehf
2014-04-03 12:42:04 +02:00
Holger Hans Peter Freyther c8b2c2f10e nat: Mention the the BSC the SCCP connection was on
The log message lacked a lot of context. A SCCP connection is
created on behalf of a configured BSC. This way we should be
able to always list this information.
2014-04-03 12:30:34 +02:00
Holger Hans Peter Freyther 27aab2e1c5 gbproxy/debian: Add a start script for the GBproxy
Fixes: OW#1164
2014-04-03 12:20:15 +02:00
Holger Hans Peter Freyther bb8d68196c nat/debian: Create an init script for the nat application 2014-04-03 12:20:15 +02:00
Jacob Erlbeck e827812051 ipa: Use enhanced ipa_msg_recv_buffered() to cope with partioned IPA messages
The old ipa_msg_recv() implementation didn't support partial receive,
so IPA connections got disconnected when this happened.

This patch adds the handling of the temporary message buffers and uses
ipa_msg_recv_buffered().

It has been successfully tested by jerlbeck with osmo-nitb and
osmo-bsc.

Ticket: OW#768
Sponsored-by: On-Waves ehf
2014-04-01 13:40:59 +02:00
Holger Hans Peter Freyther 8a158bb1ea ctrl/abis: When the max_power_reduction changes, send it to the BTS
In case the max_power_reduction changes, issue a new Set Radio
Carrier Attributes command. OML 12.21 allows to not include the
ARFCN list and the semantic I picked/understand is that a partial
update is possible.

Fixes: SYS#267
2014-03-26 18:08:22 +01:00
Holger Hans Peter Freyther a27303094a sgsn/ctrl: Add ctrl interface, implement listing subscribers
Add the control interface with no hierachy right now and implement
the first command to list IMSI + Context Address of active sessions.
sgsn_cmd_handle could share more code with bsc variant.

Fixes: SYS#264, SYS#265
2014-03-23 18:34:58 +01:00
Holger Hans Peter Freyther 49f9e5b6b4 ctrl: Move the lookup into a separate file in preparation for GPRS
For GPRS the look-up via bts/trx does not make any sense and would
introduce bad depdencies for the SGSN. Move the look-up code to a
new file and introduce new setup methods.
2014-03-23 16:25:16 +01:00
Holger Hans Peter Freyther d883db027b nitb/ctrl: Implement a command to list all active subscribers
This is only useful for small networks. List the IMSI and MSISDN
of all active subscribers.

Fixes: SYS#266
2014-03-23 16:22:55 +01:00
Holger Hans Peter Freyther 2d99eeb7f2 nitb/ctrl: Implement creating and deleting subscribers
Sadly there is no proper foreign key relationship on the tables
that related to the Subscriber. This means we can't use a DELETE
with Cascade and need to delete everything by hand. To make things
worse maybe the SMS/Paging code is still using the subscriber
making the operation more dangerous. I had added NULL checks for
sender_id/receiver_id at 30C3 so we should not crash in this
situation.

Fixes: SYS#274
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther 9dbc3f8db7 nitb/ctrl: Add command to add/modify a subscriber to the database
The test has been manually verified. Executing the select for
the subscribers showed:

sqlite> select * from Subscriber;
1|2014-03-23 12:12:46|2014-03-23 12:19:09|2620345||445567|1||0|

This created a subscriber with the right IMSI, MSISDN and has
it authorized.

Fixes: SYS#275
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther d092f48648 nitb/ctrl: Add ctrl command to set the TRX max_power_reduction
In case the BTS is connected the new attribute should be set
through OML. This is left as a todo item.

Addresses: SYS#267
2014-03-23 14:05:22 +01:00
Holger Hans Peter Freyther ebe55aa95a systemd: Add service for the osmo-sgsn
Fixes: SYS#175
2014-03-21 17:43:19 +01:00
Holger Hans Peter Freyther 2826cb58bb systemd: Saying these services restart once should be enough 2014-03-21 17:41:45 +01:00
Holger Hans Peter Freyther 870cc0fdac Merge branch 'jolly/mncc'
Merge the interface changes to the MNCC protocol
2014-03-20 22:36:27 +01:00
Andreas Eversberg 63bfdd83ea mncc: Add support for half rate V1 frames to MNCC/RTP interface 2014-03-20 22:36:16 +01:00
Andreas Eversberg 9acbe4cefe mncc: Use helper function to check if an MNCC frame is data (speech/traffic)
Rename method mncc_rcv_tchf() to mncc_rcv_data(), because the check applies
to all types of data frames, not only TCH/F data.
2014-03-20 22:36:16 +01:00
Andreas Eversberg f78fc4e76e mncc: Complete definitions for all speech traffic frames at MNCC interface
The new definitions are: half rate and AMR

Change of definition name for bad frame, because it applies to all types of
traffic, not only TCH/F.

Increase MNCC interface version to 4. Version 3 is skipped, because it was
used by older version of Linux-Call-Router which is incompatible with the
current version of the MNCC interface.
2014-03-20 22:36:16 +01:00
Holger Hans Peter Freyther f50f70452f mgcp: The valid payload types start at 0. Fix the VTY 2014-03-20 22:34:37 +01:00
Holger Hans Peter Freyther 162a0becc5 systemd: Remove the second occurance of Restart=always 2014-03-13 18:37:19 +01:00
Nikola 9e55636fe0 trau: Fix linking on FreeBSD by using LIBRAY_DL 2014-03-11 15:41:50 +01:00
Alexander Chemeris 9e15e187cc sms: Rename gsm340_gen_tpdu() to gsm340_gen_sms_deliver_tpdu()
Rename gsm340_gen_tpdu() to gsm340_gen_sms_deliver_tpdu() to
show that it generates SMS-DELIVER TPDU and is not a generic function.
2014-03-09 19:27:46 +01:00
Alexander Chemeris 1e77e3dc5b db,sms: Rename db_sms_mark_sent() to db_sms_mark_delivered()
In MT-SMS the message is being delivered. Make the naming follow
that. The schema still refers to "sent" while it should be "delivered"
too.
2014-03-09 10:26:11 +01:00
Alexander Chemeris 82a1858eb0 db: Add more tests for retrieving subscribers from a DB. 2014-03-09 10:24:11 +01:00
Alexander Chemeris 7e20f64f27 db: Remove the german from the log message 2014-03-07 17:05:23 +01:00
Holger Hans Peter Freyther e0bd8efcc0 Merge branch 'daniel/smpp-fixes' 2014-03-06 23:48:49 +01:00
Holger Hans Peter Freyther ed0d4f6222 nitb/smpp: Add simple test runner for the issues found by daniel
Send the two strings that caused the read handling to misbehave.
Verify that we handle this correctly by still being able to issue
a VTY command. The CPU load issue could not be verified like this.
2014-03-06 23:48:17 +01:00
Daniel Willmann 1fc8ec66a3 smpp_smsc: Fix integer overflow in read return value and msgb_alloc()
The size parameter of msgb_alloc is uint16_t so any length value above
65535 will allocate a msgb with incorrect size.

This patch changes the type of rdlen and rc to ssize_t (the return value
of read) and guards against the read length being larger than
UINT16_MAX.

To reproduce the issue run:
echo -en "\x00\x01\x00\x01\x01" |socat stdin tcp:localhost:2775
2014-03-06 23:20:30 +01:00
Daniel Willmann b6f01e77b1 smpp_smsc: Check that the size is large enough to hold actual data
The first 4 bytes are the length including the length field. For
length < 4 the subsequent msgb_put(msg, sizeof(uint32_t)) will fail,
resulting in an abort. The code also expects (in smpp_msgb_cmdid()) the
existence of 4 more bytes for the SMPP command ID.

This patch checks that the length received is large enough to hold all
8 bytes in the msgb and drops the connection if that's not the case.

The issue is reproducible with:
echo -e "\x00\x00\x00\x02\x00" |socat stdin tcp:localhost:2775
2014-03-06 23:20:30 +01:00
Daniel Willmann a4540b2c3b smpp_smsc: Fix socket read() error handling
Read returning -1 is an error here so make sure to print the actual
reason and close the socket. Before this patch we just looped over the
fd with read returning -1 every time.

EINTR is handled to not cause an error and we don't need to check
EAGAIN/EWOULDBLOCK since the callback is only called in case there is
something to read.

To avoid copy&paste issues the check is implemented as a macro and the
log message moved into a separate if.
2014-03-06 23:20:30 +01:00
Ciaby ec6e4f8b3d nitb: Add a test for "show network" in the python testsuite.
Make sure that bsc_gsmnet->bsc_data->rf_ctrl is initialized for
NITB. In commit a9fae1ae66 the
conditions for the rf_ctrl was removed but it was still needed
for the NITB.

Fixes regression from:
a9fae1ae66
bsc: rf_ctrl will always be created, remove the NULL checks
2014-03-06 17:31:23 +01:00
Holger Hans Peter Freyther 1a1463725b Merge branch 'zecke/features/extended-control' 2014-03-06 11:10:30 +01:00
Holger Hans Peter Freyther 4ecc6877a2 nat: Add CTRL command test case for the new control commands 2014-03-06 11:04:56 +01:00
Holger Hans Peter Freyther 472f3bd198 nat: Introduce command to remove an access-list-name 2014-03-04 20:39:38 +01:00
Holger Hans Peter Freyther bc3780a73f nat: Implement setting the access-control-name through CTRL interface
For operation we want to switch the access-list of a BSC at runtime
in a programatic way.

Sponsored-by: On-Waves ehf
2014-03-04 20:39:27 +01:00
Holger Hans Peter Freyther ecdf912ffb bsc: Include the MCC/MNC in the location trap
It is of interest to know the MCC/MNC that is broadcasted at the
specific position.

Sponsored-by: On-Waves ehf
2014-03-04 20:39:16 +01:00