Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 1 | /* Handover Logic for Inter-BTS (Intra-BSC) Handover. This does not |
| 2 | * actually implement the handover algorithm/decision, but executes a |
| 3 | * handover decision */ |
| 4 | |
| 5 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <errno.h> |
| 29 | #include <time.h> |
| 30 | #include <netinet/in.h> |
| 31 | |
Harald Welte | f4625b1 | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 32 | #include <osmocore/msgb.h> |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 33 | #include <openbsc/debug.h> |
| 34 | #include <openbsc/gsm_data.h> |
Harald Welte | f4625b1 | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 35 | #include <osmocore/gsm_utils.h> |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 36 | #include <openbsc/gsm_subscriber.h> |
| 37 | #include <openbsc/gsm_04_08.h> |
| 38 | #include <openbsc/abis_rsl.h> |
| 39 | #include <openbsc/chan_alloc.h> |
| 40 | #include <openbsc/signal.h> |
Harald Welte | f4625b1 | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 41 | #include <osmocore/talloc.h> |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 42 | #include <openbsc/transaction.h> |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 43 | #include <openbsc/rtp_proxy.h> |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 44 | |
| 45 | struct bsc_handover { |
| 46 | struct llist_head list; |
| 47 | |
| 48 | struct gsm_lchan *old_lchan; |
| 49 | struct gsm_lchan *new_lchan; |
| 50 | |
| 51 | struct timer_list T3103; |
| 52 | |
| 53 | u_int8_t ho_ref; |
| 54 | }; |
| 55 | |
| 56 | static LLIST_HEAD(bsc_handovers); |
| 57 | |
| 58 | static struct bsc_handover *bsc_ho_by_new_lchan(struct gsm_lchan *new_lchan) |
| 59 | { |
| 60 | struct bsc_handover *ho; |
| 61 | |
| 62 | llist_for_each_entry(ho, &bsc_handovers, list) { |
| 63 | if (ho->new_lchan == new_lchan) |
| 64 | return ho; |
| 65 | } |
| 66 | |
| 67 | return NULL; |
| 68 | } |
| 69 | |
| 70 | static struct bsc_handover *bsc_ho_by_old_lchan(struct gsm_lchan *old_lchan) |
| 71 | { |
| 72 | struct bsc_handover *ho; |
| 73 | |
| 74 | llist_for_each_entry(ho, &bsc_handovers, list) { |
| 75 | if (ho->old_lchan == old_lchan) |
| 76 | return ho; |
| 77 | } |
| 78 | |
| 79 | return NULL; |
| 80 | } |
| 81 | |
| 82 | /* Hand over the specified logical channel to the specified new BTS. |
| 83 | * This is the main entry point for the actual handover algorithm, |
| 84 | * after it has decided it wants to initiate HO to a specific BTS */ |
| 85 | int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts) |
| 86 | { |
| 87 | struct gsm_lchan *new_lchan; |
| 88 | struct bsc_handover *ho; |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 89 | static u_int8_t ho_ref; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 90 | int rc; |
| 91 | |
Harald Welte | aef376f | 2009-12-17 22:23:21 +0100 | [diff] [blame] | 92 | /* don't attempt multiple handovers for the same lchan at |
| 93 | * the same time */ |
| 94 | if (bsc_ho_by_old_lchan(old_lchan)) |
| 95 | return -EBUSY; |
| 96 | |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 97 | DEBUGP(DHO, "(old_lchan on BTS %u, new BTS %u)\n", |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 98 | old_lchan->ts->trx->bts->nr, bts->nr); |
| 99 | |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 100 | counter_inc(bts->network->stats.handover.attempted); |
Harald Welte | 3edc5a9 | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 101 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 102 | new_lchan = lchan_alloc(bts, old_lchan->type); |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 103 | if (!new_lchan) { |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 104 | LOGP(DHO, LOGL_NOTICE, "No free channel\n"); |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 105 | counter_inc(bts->network->stats.handover.no_channel); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 106 | return -ENOSPC; |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 107 | } |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 108 | |
| 109 | ho = talloc_zero(NULL, struct bsc_handover); |
| 110 | if (!ho) { |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 111 | LOGP(DHO, LOGL_FATAL, "Out of Memory\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 112 | lchan_free(new_lchan); |
| 113 | return -ENOMEM; |
| 114 | } |
| 115 | ho->old_lchan = old_lchan; |
| 116 | ho->new_lchan = new_lchan; |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 117 | ho->ho_ref = ho_ref++; |
| 118 | |
| 119 | /* copy some parameters from old lchan */ |
| 120 | memcpy(&new_lchan->encr, &old_lchan->encr, sizeof(new_lchan->encr)); |
| 121 | new_lchan->ms_power = old_lchan->ms_power; |
| 122 | new_lchan->bs_power = old_lchan->bs_power; |
| 123 | new_lchan->rsl_cmode = old_lchan->rsl_cmode; |
| 124 | new_lchan->tch_mode = old_lchan->tch_mode; |
Holger Hans Peter Freyther | 065b811 | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 125 | new_lchan->conn.subscr = subscr_get(old_lchan->conn.subscr); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 126 | |
| 127 | /* FIXME: do we have a better idea of the timing advance? */ |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 128 | rc = rsl_chan_activate_lchan(new_lchan, RSL_ACT_INTER_ASYNC, 0, |
| 129 | ho->ho_ref); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 130 | if (rc < 0) { |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 131 | LOGP(DHO, LOGL_ERROR, "could not activate channel\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 132 | talloc_free(ho); |
| 133 | lchan_free(new_lchan); |
| 134 | return rc; |
| 135 | } |
| 136 | |
Holger Hans Peter Freyther | 599056d | 2010-04-10 00:16:04 +0200 | [diff] [blame] | 137 | rsl_lchan_set_state(new_lchan, LCHAN_S_ACT_REQ); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 138 | llist_add(&ho->list, &bsc_handovers); |
| 139 | /* we continue in the SS_LCHAN handler / ho_chan_activ_ack */ |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | /* T3103 expired: Handover has failed without HO COMPLETE or HO FAIL */ |
| 145 | static void ho_T3103_cb(void *_ho) |
| 146 | { |
| 147 | struct bsc_handover *ho = _ho; |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 148 | struct gsm_network *net = ho->new_lchan->ts->trx->bts->network; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 149 | |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 150 | DEBUGP(DHO, "HO T3103 expired\n"); |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 151 | counter_inc(net->stats.handover.timeout); |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 152 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 153 | lchan_free(ho->new_lchan); |
| 154 | llist_del(&ho->list); |
| 155 | talloc_free(ho); |
| 156 | } |
| 157 | |
| 158 | /* RSL has acknowledged activation of the new lchan */ |
| 159 | static int ho_chan_activ_ack(struct gsm_lchan *new_lchan) |
| 160 | { |
| 161 | struct bsc_handover *ho; |
| 162 | int rc; |
| 163 | |
Harald Welte | fedc19e | 2009-12-18 14:50:08 +0100 | [diff] [blame] | 164 | /* we need to check if this channel activation is related to |
| 165 | * a handover at all (and if, which particular handover) */ |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 166 | ho = bsc_ho_by_new_lchan(new_lchan); |
Harald Welte | fedc19e | 2009-12-18 14:50:08 +0100 | [diff] [blame] | 167 | if (!ho) |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 168 | return -ENODEV; |
Harald Welte | fedc19e | 2009-12-18 14:50:08 +0100 | [diff] [blame] | 169 | |
| 170 | DEBUGP(DHO, "handover activate ack, send HO Command\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 171 | |
| 172 | /* we can now send the 04.08 HANDOVER COMMAND to the MS |
| 173 | * using the old lchan */ |
| 174 | |
Harald Welte | b90d7bd | 2009-12-17 00:31:10 +0100 | [diff] [blame] | 175 | rc = gsm48_send_ho_cmd(ho->old_lchan, new_lchan, 0, ho->ho_ref); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 176 | |
| 177 | /* start T3103. We can continue either with T3103 expiration, |
| 178 | * 04.08 HANDOVER COMPLETE or 04.08 HANDOVER FAIL */ |
| 179 | ho->T3103.cb = ho_T3103_cb; |
Harald Welte | 6d8220c | 2009-12-18 11:49:03 +0100 | [diff] [blame] | 180 | ho->T3103.data = ho; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 181 | bsc_schedule_timer(&ho->T3103, 10, 0); |
| 182 | |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 183 | /* create a RTP connection */ |
| 184 | if (is_ipaccess_bts(new_lchan->ts->trx->bts)) |
| 185 | rsl_ipacc_crcx(new_lchan); |
| 186 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | /* RSL has not acknowledged activation of the new lchan */ |
| 191 | static int ho_chan_activ_nack(struct gsm_lchan *new_lchan) |
| 192 | { |
| 193 | struct bsc_handover *ho; |
| 194 | |
| 195 | ho = bsc_ho_by_new_lchan(new_lchan); |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 196 | if (!ho) { |
| 197 | LOGP(DHO, LOGL_ERROR, "unable to find HO record\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 198 | return -ENODEV; |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 199 | } |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 200 | |
| 201 | llist_del(&ho->list); |
| 202 | talloc_free(ho); |
| 203 | |
| 204 | /* FIXME: maybe we should try to allocate a new LCHAN here? */ |
| 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | /* GSM 04.08 HANDOVER COMPLETE has been received on new channel */ |
| 210 | static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan) |
| 211 | { |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 212 | struct gsm_network *net = new_lchan->ts->trx->bts->network; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 213 | struct bsc_handover *ho; |
| 214 | |
| 215 | ho = bsc_ho_by_new_lchan(new_lchan); |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 216 | if (!ho) { |
| 217 | LOGP(DHO, LOGL_ERROR, "unable to find HO record\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 218 | return -ENODEV; |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 219 | } |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 220 | |
Harald Welte | 58eeaba | 2009-12-25 23:02:50 +0100 | [diff] [blame] | 221 | LOGP(DHO, LOGL_INFO, "Subscriber %s HO from BTS %u->%u on ARFCN " |
Holger Hans Peter Freyther | 065b811 | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 222 | "%u->%u\n", subscr_name(ho->old_lchan->conn.subscr), |
Harald Welte | 58eeaba | 2009-12-25 23:02:50 +0100 | [diff] [blame] | 223 | ho->old_lchan->ts->trx->bts->nr, new_lchan->ts->trx->bts->nr, |
| 224 | ho->old_lchan->ts->trx->arfcn, new_lchan->ts->trx->arfcn); |
| 225 | |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 226 | counter_inc(net->stats.handover.completed); |
Harald Welte | 3edc5a9 | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 227 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 228 | bsc_del_timer(&ho->T3103); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 229 | |
Harald Welte | f8c5070 | 2009-12-17 17:14:43 +0100 | [diff] [blame] | 230 | /* update lchan pointer of transaction */ |
Holger Hans Peter Freyther | 4009da4 | 2010-03-23 07:00:22 +0100 | [diff] [blame] | 231 | trans_lchan_change(&ho->old_lchan->conn, &new_lchan->conn); |
Harald Welte | f8c5070 | 2009-12-17 17:14:43 +0100 | [diff] [blame] | 232 | |
Holger Hans Peter Freyther | 68914a0 | 2010-04-10 00:12:31 +0200 | [diff] [blame] | 233 | rsl_lchan_set_state(ho->old_lchan, LCHAN_S_INACTIVE); |
Harald Welte | 83c5981 | 2009-12-21 13:29:19 +0100 | [diff] [blame] | 234 | lchan_auto_release(ho->old_lchan); |
| 235 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 236 | /* do something to re-route the actual speech frames ! */ |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 237 | |
Harald Welte | 83c5981 | 2009-12-21 13:29:19 +0100 | [diff] [blame] | 238 | llist_del(&ho->list); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 239 | talloc_free(ho); |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | /* GSM 04.08 HANDOVER FAIL has been received */ |
| 245 | static int ho_gsm48_ho_fail(struct gsm_lchan *old_lchan) |
| 246 | { |
Holger Hans Peter Freyther | 065b811 | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 247 | struct gsm_subscriber_connection *conn; |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 248 | struct gsm_network *net = old_lchan->ts->trx->bts->network; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 249 | struct bsc_handover *ho; |
| 250 | |
| 251 | ho = bsc_ho_by_old_lchan(old_lchan); |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 252 | if (!ho) { |
| 253 | LOGP(DHO, LOGL_ERROR, "unable to find HO record\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 254 | return -ENODEV; |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 255 | } |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 256 | |
Harald Welte | bdbb744 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 257 | counter_inc(net->stats.handover.failed); |
Harald Welte | 3edc5a9 | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 258 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 259 | bsc_del_timer(&ho->T3103); |
| 260 | llist_del(&ho->list); |
Holger Hans Peter Freyther | 065b811 | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 261 | conn = &ho->new_lchan->conn; |
| 262 | put_subscr_con(conn); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 263 | talloc_free(ho); |
| 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | /* GSM 08.58 HANDOVER DETECT has been received */ |
| 269 | static int ho_rsl_detect(struct gsm_lchan *new_lchan) |
| 270 | { |
| 271 | struct bsc_handover *ho; |
| 272 | |
Harald Welte | bc2e539 | 2009-12-18 11:52:03 +0100 | [diff] [blame] | 273 | ho = bsc_ho_by_new_lchan(new_lchan); |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 274 | if (!ho) { |
| 275 | LOGP(DHO, LOGL_ERROR, "unable to find HO record\n"); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 276 | return -ENODEV; |
Harald Welte | cf2ec4a | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 277 | } |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 278 | |
| 279 | /* FIXME: do we actually want to do something here ? */ |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 284 | static int ho_ipac_crcx_ack(struct gsm_lchan *new_lchan) |
| 285 | { |
| 286 | struct bsc_handover *ho; |
| 287 | struct rtp_socket *old_rs, *new_rs, *other_rs; |
| 288 | |
| 289 | ho = bsc_ho_by_new_lchan(new_lchan); |
| 290 | if (!ho) { |
Harald Welte | 49afbc3 | 2009-12-24 13:27:02 +0100 | [diff] [blame] | 291 | /* it is perfectly normal, we have CRCX even in non-HO cases */ |
| 292 | return 0; |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | if (ipacc_rtp_direct) { |
| 296 | LOGP(DHO, LOGL_ERROR, "unable to handover in direct RTP mode\n"); |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | /* RTP Proxy mode */ |
| 301 | new_rs = new_lchan->abis_ip.rtp_socket; |
| 302 | old_rs = ho->old_lchan->abis_ip.rtp_socket; |
| 303 | |
| 304 | if (!new_rs) { |
| 305 | LOGP(DHO, LOGL_ERROR, "no RTP socket for new_lchan\n"); |
| 306 | return -EIO; |
| 307 | } |
| 308 | |
| 309 | rsl_ipacc_mdcx_to_rtpsock(new_lchan); |
| 310 | |
| 311 | if (!old_rs) { |
| 312 | LOGP(DHO, LOGL_ERROR, "no RTP socekt for old_lchan\n"); |
| 313 | return -EIO; |
| 314 | } |
| 315 | |
| 316 | /* copy rx_action and reference to other sock */ |
| 317 | new_rs->rx_action = old_rs->rx_action; |
| 318 | new_rs->tx_action = old_rs->tx_action; |
| 319 | new_rs->transmit = old_rs->transmit; |
| 320 | |
| 321 | switch (ho->old_lchan->abis_ip.rtp_socket->rx_action) { |
| 322 | case RTP_PROXY: |
| 323 | other_rs = old_rs->proxy.other_sock; |
| 324 | rtp_socket_proxy(new_rs, other_rs); |
| 325 | /* delete reference to other end socket to prevent |
| 326 | * rtp_socket_free() from removing the inverse reference */ |
| 327 | old_rs->proxy.other_sock = NULL; |
| 328 | break; |
| 329 | case RTP_RECV_UPSTREAM: |
| 330 | new_rs->receive = old_rs->receive; |
| 331 | break; |
| 332 | case RTP_NONE: |
| 333 | break; |
| 334 | } |
| 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 339 | static int ho_logic_sig_cb(unsigned int subsys, unsigned int signal, |
| 340 | void *handler_data, void *signal_data) |
| 341 | { |
| 342 | struct gsm_lchan *lchan; |
| 343 | |
| 344 | switch (subsys) { |
| 345 | case SS_LCHAN: |
| 346 | lchan = signal_data; |
| 347 | switch (signal) { |
| 348 | case S_LCHAN_ACTIVATE_ACK: |
| 349 | return ho_chan_activ_ack(lchan); |
| 350 | case S_LCHAN_ACTIVATE_NACK: |
| 351 | return ho_chan_activ_nack(lchan); |
| 352 | case S_LCHAN_HANDOVER_DETECT: |
| 353 | return ho_rsl_detect(lchan); |
| 354 | case S_LCHAN_HANDOVER_COMPL: |
| 355 | return ho_gsm48_ho_compl(lchan); |
| 356 | case S_LCHAN_HANDOVER_FAIL: |
| 357 | return ho_gsm48_ho_fail(lchan); |
| 358 | } |
| 359 | break; |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 360 | case SS_ABISIP: |
| 361 | lchan = signal_data; |
| 362 | switch (signal) { |
| 363 | case S_ABISIP_CRCX_ACK: |
| 364 | return ho_ipac_crcx_ack(lchan); |
| 365 | break; |
| 366 | } |
| 367 | break; |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 368 | default: |
| 369 | break; |
| 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | static __attribute__((constructor)) void on_dso_load_ho_logic(void) |
| 376 | { |
| 377 | register_signal_handler(SS_LCHAN, ho_logic_sig_cb, NULL); |
Harald Welte | f8189fe | 2009-12-20 17:04:40 +0100 | [diff] [blame] | 378 | register_signal_handler(SS_ABISIP, ho_logic_sig_cb, NULL); |
Harald Welte | 96c0b08 | 2009-11-29 22:56:14 +0100 | [diff] [blame] | 379 | } |