blob: 6eb39b067c7077c00915c43ff3e972e9c024828c [file] [log] [blame]
Harald Weltefbc5ca02010-03-04 10:39:50 +01001/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte8470bf22008-12-25 23:28:35 +00002 *
Harald Welte52b1f982008-12-23 20:25:15 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Harald Welte52b1f982008-12-23 20:25:15 +00008 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte52b1f982008-12-23 20:25:15 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte52b1f982008-12-23 20:25:15 +000017 *
18 */
19
20
21#include <stdlib.h>
Harald Welte51f38452009-02-24 22:36:40 +000022#include <stdio.h>
Harald Welte52b1f982008-12-23 20:25:15 +000023#include <string.h>
Harald Weltefcd24452009-06-20 18:15:19 +020024#include <errno.h>
Harald Welte42581822009-08-08 16:12:58 +020025#include <ctype.h>
Harald Welte52b1f982008-12-23 20:25:15 +000026
Harald Welte97a282b2010-03-14 15:37:43 +080027#include <netinet/in.h>
28
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010029#include <osmocom/core/linuxlist.h>
30#include <osmocom/core/talloc.h>
31#include <osmocom/gsm/gsm_utils.h>
Harald Welte867d9f32011-05-23 20:30:39 +020032#include <osmocom/gsm/abis_nm.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010033#include <osmocom/core/statistics.h>
Harald Welte52b1f982008-12-23 20:25:15 +000034
Holger Hans Peter Freythered832862010-06-28 18:20:22 +080035#include <openbsc/gsm_data.h>
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080036#include <openbsc/osmo_msc_data.h>
Holger Hans Peter Freythered832862010-06-28 18:20:22 +080037#include <openbsc/abis_nm.h>
38
Andreas Eversberg8226fa72009-06-29 15:19:38 +020039void *tall_bsc_ctx;
40
Harald Welte39315c42010-01-10 18:01:52 +010041static LLIST_HEAD(bts_models);
42
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020043void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr,
44 uint8_t e1_ts, uint8_t e1_ts_ss)
Harald Weltecd06bfb2009-02-10 17:33:56 +000045{
46 ts->e1_link.e1_nr = e1_nr;
47 ts->e1_link.e1_ts = e1_ts;
48 ts->e1_link.e1_ts_ss = e1_ts_ss;
49}
50
Harald Welte39315c42010-01-10 18:01:52 +010051static struct gsm_bts_model *bts_model_find(enum gsm_bts_type type)
52{
53 struct gsm_bts_model *model;
54
55 llist_for_each_entry(model, &bts_models, list) {
56 if (model->type == type)
57 return model;
58 }
59
60 return NULL;
61}
62
63int gsm_bts_model_register(struct gsm_bts_model *model)
64{
65 if (bts_model_find(model->type))
66 return -EEXIST;
67
Harald Welte867d9f32011-05-23 20:30:39 +020068 tlv_def_patch(&model->nm_att_tlvdef, &abis_nm_att_tlvdef);
Harald Welte39315c42010-01-10 18:01:52 +010069 llist_add_tail(&model->list, &bts_models);
70 return 0;
71}
72
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020073struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
Harald Welte29b64e92010-12-23 01:07:46 +010074 int (*mncc_recv)(struct gsm_network *, struct msgb *))
Harald Weltee441d9c2009-06-21 16:17:15 +020075{
76 struct gsm_network *net;
77
Holger Hans Peter Freyther5ea73132009-10-29 02:29:45 +010078 net = talloc_zero(tall_bsc_ctx, struct gsm_network);
Harald Welte52b1f982008-12-23 20:25:15 +000079 if (!net)
80 return NULL;
Harald Welte52b1f982008-12-23 20:25:15 +000081
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020082 net->bsc_data = talloc_zero(net, struct osmo_bsc_data);
83 if (!net->bsc_data) {
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +080084 talloc_free(net);
85 return NULL;
86 }
87
Daniel Willmann163f6122011-03-03 13:48:28 +010088 /* Init back pointer */
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020089 net->bsc_data->network = net;
Holger Hans Peter Freyther20fea242011-06-04 19:58:26 +020090 INIT_LLIST_HEAD(&net->bsc_data->mscs);
Daniel Willmann163f6122011-03-03 13:48:28 +010091
Harald Welte52b1f982008-12-23 20:25:15 +000092 net->country_code = country_code;
93 net->network_code = network_code;
Harald Weltee441d9c2009-06-21 16:17:15 +020094 net->num_bts = 0;
Holger Hans Peter Freytherd0c54022010-01-07 16:08:42 +010095 net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED;
Harald Welteb84ddfc2009-12-01 17:36:54 +053096 net->T3101 = GSM_T3101_DEFAULT;
97 net->T3113 = GSM_T3113_DEFAULT;
98 /* FIXME: initialize all other timers! */
Harald Welte52b1f982008-12-23 20:25:15 +000099
Harald Weltef7c28b02009-12-21 13:30:17 +0100100 /* default set of handover parameters */
101 net->handover.win_rxlev_avg = 10;
102 net->handover.win_rxqual_avg = 1;
103 net->handover.win_rxlev_avg_neigh = 10;
104 net->handover.pwr_interval = 6;
105 net->handover.pwr_hysteresis = 3;
106 net->handover.max_distance = 9999;
107
Harald Welte4bfdfe72009-06-10 23:11:52 +0800108 INIT_LLIST_HEAD(&net->trans_list);
109 INIT_LLIST_HEAD(&net->upqueue);
Harald Weltee441d9c2009-06-21 16:17:15 +0200110 INIT_LLIST_HEAD(&net->bts_list);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800111
Pablo Neira Ayusodfb342c2011-05-06 12:13:10 +0200112 net->stats.chreq.total = osmo_counter_alloc("net.chreq.total");
113 net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel");
114 net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted");
115 net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel");
116 net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout");
117 net->stats.handover.completed = osmo_counter_alloc("net.handover.completed");
118 net->stats.handover.failed = osmo_counter_alloc("net.handover.failed");
119 net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach");
120 net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal");
121 net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic");
122 net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count");
123 net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject");
124 net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept");
125 net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted");
126 net->stats.paging.detached = osmo_counter_alloc("net.paging.detached");
127 net->stats.paging.completed = osmo_counter_alloc("net.paging.completed");
128 net->stats.paging.expired = osmo_counter_alloc("net.paging.expired");
129 net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted");
130 net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver");
131 net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered");
132 net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem");
133 net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other");
134 net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup");
135 net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack");
136 net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup");
137 net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect");
138 net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail");
139 net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err");
140 net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail");
141 net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail");
Harald Welteffa55a42009-12-22 19:07:32 +0100142
Harald Welte4bfdfe72009-06-10 23:11:52 +0800143 net->mncc_recv = mncc_recv;
144
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800145 gsm_net_update_ctype(net);
146
Harald Welte8470bf22008-12-25 23:28:35 +0000147 return net;
Harald Welte52b1f982008-12-23 20:25:15 +0000148}
Harald Welte23a68632009-02-19 17:06:42 +0000149
Harald Weltee441d9c2009-06-21 16:17:15 +0200150struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num)
151{
152 struct gsm_bts *bts;
153
154 if (num >= net->num_bts)
155 return NULL;
156
157 llist_for_each_entry(bts, &net->bts_list, list) {
158 if (bts->nr == num)
159 return bts;
160 }
161
162 return NULL;
163}
164
Harald Welte84874c92009-12-14 22:33:02 +0100165/* Get reference to a neighbor cell on a given BCCH ARFCN */
Harald Welte0b121032009-12-15 00:21:31 +0100166struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200167 uint16_t arfcn, uint8_t bsic)
Harald Welte84874c92009-12-14 22:33:02 +0100168{
169 struct gsm_bts *neigh;
170 /* FIXME: use some better heuristics here to determine which cell
171 * using this ARFCN really is closest to the target cell. For
172 * now we simply assume that each ARFCN will only be used by one
173 * cell */
174
175 llist_for_each_entry(neigh, &bts->network->bts_list, list) {
Harald Welte0b121032009-12-15 00:21:31 +0100176 if (neigh->c0->arfcn == arfcn &&
177 neigh->bsic == bsic)
Harald Welte84874c92009-12-14 22:33:02 +0100178 return neigh;
179 }
180
181 return NULL;
182}
183
Harald Welte92b1fe42010-03-25 11:45:30 +0800184static const struct value_string bts_types[] = {
185 { GSM_BTS_TYPE_UNKNOWN, "unknown" },
186 { GSM_BTS_TYPE_BS11, "bs11" },
187 { GSM_BTS_TYPE_NANOBTS, "nanobts" },
Harald Weltedb44f602011-02-11 18:36:18 +0100188 { GSM_BTS_TYPE_RBS2000, "rbs2000" },
Harald Weltefd355a32011-03-04 13:41:31 +0100189 { GSM_BTS_TYPE_HSL_FEMTO, "hsl_femto" },
Dieter Spaar16646022011-07-28 00:01:50 +0200190 { GSM_BTS_TYPE_NOKIA_SITE, "nokia_site" },
Harald Welte92b1fe42010-03-25 11:45:30 +0800191 { 0, NULL }
Harald Welte32201c12009-03-10 12:15:10 +0000192};
193
Harald Welte1d014a52009-08-08 15:38:29 +0200194enum gsm_bts_type parse_btstype(const char *arg)
Harald Welte32201c12009-03-10 12:15:10 +0000195{
Harald Welte92b1fe42010-03-25 11:45:30 +0800196 return get_string_value(bts_types, arg);
Harald Welte32201c12009-03-10 12:15:10 +0000197}
198
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200199const char *btstype2str(enum gsm_bts_type type)
Harald Welte32201c12009-03-10 12:15:10 +0000200{
Harald Welte92b1fe42010-03-25 11:45:30 +0800201 return get_value_string(bts_types, type);
Harald Welte32201c12009-03-10 12:15:10 +0000202}
Harald Weltebe991492009-05-23 13:56:40 +0000203
Harald Welte6e670aa2010-01-07 20:44:32 +0100204struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr)
205{
206 struct gsm_bts_trx *trx;
207
208 llist_for_each_entry(trx, &bts->trx_list, list) {
209 if (trx->nr == nr)
210 return trx;
211 }
212 return NULL;
213}
214
Harald Weltebe991492009-05-23 13:56:40 +0000215/* Search for a BTS in the given Location Area; optionally start searching
216 * with start_bts (for continuing to search after the first result) */
217struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
218 struct gsm_bts *start_bts)
219{
220 int i;
221 struct gsm_bts *bts;
222 int skip = 0;
223
224 if (start_bts)
225 skip = 1;
226
227 for (i = 0; i < net->num_bts; i++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200228 bts = gsm_bts_num(net, i);
Harald Weltebe991492009-05-23 13:56:40 +0000229
230 if (skip) {
231 if (start_bts == bts)
232 skip = 0;
233 continue;
234 }
235
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +0200236 if (lac == GSM_LAC_RESERVED_ALL_BTS || bts->location_area_code == lac)
Harald Weltebe991492009-05-23 13:56:40 +0000237 return bts;
238 }
239 return NULL;
240}
Harald Weltefcd24452009-06-20 18:15:19 +0200241
Harald Welte92b1fe42010-03-25 11:45:30 +0800242static const struct value_string auth_policy_names[] = {
243 { GSM_AUTH_POLICY_CLOSED, "closed" },
244 { GSM_AUTH_POLICY_ACCEPT_ALL, "accept-all" },
245 { GSM_AUTH_POLICY_TOKEN, "token" },
246 { 0, NULL }
Harald Welte (local)69de3972009-08-12 14:42:23 +0200247};
248
249enum gsm_auth_policy gsm_auth_policy_parse(const char *arg)
250{
Harald Welte92b1fe42010-03-25 11:45:30 +0800251 return get_string_value(auth_policy_names, arg);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200252}
253
254const char *gsm_auth_policy_name(enum gsm_auth_policy policy)
255{
Harald Welte92b1fe42010-03-25 11:45:30 +0800256 return get_value_string(auth_policy_names, policy);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200257}
258
Harald Welte92b1fe42010-03-25 11:45:30 +0800259static const struct value_string rrlp_mode_names[] = {
260 { RRLP_MODE_NONE, "none" },
261 { RRLP_MODE_MS_BASED, "ms-based" },
262 { RRLP_MODE_MS_PREF, "ms-preferred" },
263 { RRLP_MODE_ASS_PREF, "ass-preferred" },
264 { 0, NULL }
Harald Welteeab84a12009-12-13 10:53:12 +0100265};
266
267enum rrlp_mode rrlp_mode_parse(const char *arg)
268{
Harald Welte92b1fe42010-03-25 11:45:30 +0800269 return get_string_value(rrlp_mode_names, arg);
Harald Welteeab84a12009-12-13 10:53:12 +0100270}
271
272const char *rrlp_mode_name(enum rrlp_mode mode)
273{
Harald Welte92b1fe42010-03-25 11:45:30 +0800274 return get_value_string(rrlp_mode_names, mode);
Harald Welteeab84a12009-12-13 10:53:12 +0100275}
Harald Welted12b0fd2009-12-15 21:36:05 +0100276
Harald Welte4511d892010-04-18 15:51:20 +0200277static const struct value_string bts_gprs_mode_names[] = {
278 { BTS_GPRS_NONE, "none" },
279 { BTS_GPRS_GPRS, "gprs" },
280 { BTS_GPRS_EGPRS, "egprs" },
281 { 0, NULL }
282};
283
284enum bts_gprs_mode bts_gprs_mode_parse(const char *arg)
285{
286 return get_string_value(bts_gprs_mode_names, arg);
287}
288
289const char *bts_gprs_mode_name(enum bts_gprs_mode mode)
290{
291 return get_value_string(bts_gprs_mode_names, mode);
292}
293
Harald Welted12b0fd2009-12-15 21:36:05 +0100294struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan)
295{
296 struct gsm_meas_rep *meas_rep;
297
298 meas_rep = &lchan->meas_rep[lchan->meas_rep_idx];
299 memset(meas_rep, 0, sizeof(*meas_rep));
300 meas_rep->lchan = lchan;
301 lchan->meas_rep_idx = (lchan->meas_rep_idx + 1)
302 % ARRAY_SIZE(lchan->meas_rep);
303
304 return meas_rep;
305}
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100306
Harald Weltef3d8e922010-06-14 22:44:42 +0200307int gsm_btsmodel_set_feature(struct gsm_bts_model *bts, enum gsm_bts_features feat)
308{
309 return bitvec_set_bit_pos(&bts->features, feat, 1);
310}
311
312int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat)
313{
314 return bitvec_get_bit_pos(&bts->model->features, feat);
315}
316
Harald Welte39315c42010-01-10 18:01:52 +0100317int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type)
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100318{
Harald Welte39315c42010-01-10 18:01:52 +0100319 struct gsm_bts_model *model;
320
321 model = bts_model_find(type);
322 if (!model)
323 return -EINVAL;
324
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100325 bts->type = type;
Harald Welte39315c42010-01-10 18:01:52 +0100326 bts->model = model;
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100327
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200328 if (model->start && !model->started) {
329 int ret = model->start(bts->network);
330 if (ret < 0)
331 return ret;
332
333 model->started = true;
334 }
335
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100336 switch (bts->type) {
Harald Weltefd355a32011-03-04 13:41:31 +0100337 case GSM_BTS_TYPE_HSL_FEMTO:
338 bts->c0->rsl_tei = 0;
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100339 case GSM_BTS_TYPE_NANOBTS:
340 /* Set the default OML Stream ID to 0xff */
341 bts->oml_tei = 0xff;
342 bts->c0->nominal_power = 23;
343 break;
Harald Weltea8e6a652011-02-13 22:13:28 +0100344 case GSM_BTS_TYPE_RBS2000:
345 INIT_LLIST_HEAD(&bts->rbs2000.is.conn_groups);
Harald Weltea02085d2011-02-13 22:45:02 +0100346 INIT_LLIST_HEAD(&bts->rbs2000.con.conn_groups);
Harald Weltea8e6a652011-02-13 22:13:28 +0100347 break;
Holger Hans Peter Freytherf02bb202012-02-03 19:44:37 +0100348 case GSM_BTS_TYPE_BS11:
349 case GSM_BTS_TYPE_UNKNOWN:
350 case GSM_BTS_TYPE_NOKIA_SITE:
351 break;
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100352 }
Harald Welte39315c42010-01-10 18:01:52 +0100353
354 return 0;
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100355}
Harald Welte3300c012011-06-05 13:31:33 +0200356
357struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type,
358 uint8_t tsc, uint8_t bsic)
359{
360 struct gsm_bts_model *model = bts_model_find(type);
361 struct gsm_bts *bts;
362
Harald Welte28307642011-06-06 17:52:56 +0200363 if (!model && type != GSM_BTS_TYPE_UNKNOWN)
Harald Welte3300c012011-06-05 13:31:33 +0200364 return NULL;
Harald Welte3300c012011-06-05 13:31:33 +0200365
366 bts = gsm_bts_alloc(net);
367 if (!bts)
368 return NULL;
369
370 bts->network = net;
371 bts->nr = net->num_bts++;
372 bts->type = type;
373 bts->model = model;
374 bts->tsc = tsc;
375 bts->bsic = bsic;
376
377 bts->neigh_list_manual_mode = 0;
378 bts->si_common.cell_sel_par.cell_resel_hyst = 2; /* 4 dB */
379 bts->si_common.cell_sel_par.rxlev_acc_min = 0;
380 bts->si_common.neigh_list.data = bts->si_common.data.neigh_list;
381 bts->si_common.neigh_list.data_len =
382 sizeof(bts->si_common.data.neigh_list);
383 bts->si_common.si5_neigh_list.data = bts->si_common.data.si5_neigh_list;
384 bts->si_common.si5_neigh_list.data_len =
385 sizeof(bts->si_common.data.si5_neigh_list);
386 bts->si_common.cell_alloc.data = bts->si_common.data.cell_alloc;
387 bts->si_common.cell_alloc.data_len =
388 sizeof(bts->si_common.data.cell_alloc);
389 bts->si_common.rach_control.re = 1; /* no re-establishment */
390 bts->si_common.rach_control.tx_integer = 9; /* 12 slots spread - 217/115 slots delay */
391 bts->si_common.rach_control.max_trans = 3; /* 7 retransmissions */
392 bts->si_common.rach_control.t2 = 4; /* no emergency calls */
393
394 llist_add_tail(&bts->list, &net->bts_list);
395
396 INIT_LLIST_HEAD(&bts->abis_queue);
397
398 return bts;
399}
400
401void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
402{
403 raid->mcc = bts->network->country_code;
404 raid->mnc = bts->network->network_code;
405 raid->lac = bts->location_area_code;
406 raid->rac = bts->gprs.rac;
407}
408
409int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts)
410{
411 struct gprs_ra_id raid;
412
413 gprs_ra_id_by_bts(&raid, bts);
414
415 return gsm48_construct_ra(buf, &raid);
416}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200417
418int gsm_parse_reg(void *ctx, regex_t *reg, char **str, int argc, const char **argv)
419{
420 int ret;
421
422 ret = 0;
423 if (*str) {
424 talloc_free(*str);
425 *str = NULL;
426 }
427 regfree(reg);
428
429 if (argc > 0) {
430 *str = talloc_strdup(ctx, argv[0]);
431 ret = regcomp(reg, argv[0], 0);
432
433 /* handle compilation failures */
434 if (ret != 0) {
435 talloc_free(*str);
436 *str = NULL;
437 }
438 }
439
440 return ret;
441}
442