blob: da260a89508a3df481f93f82b2c0408063c9646b [file] [log] [blame]
Harald Welte338e3b32012-11-20 22:22:04 +01001/* SMPP vty interface */
2
3/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
Harald Weltee07b6a72012-11-23 19:02:37 +010021#include <ctype.h>
Harald Welte338e3b32012-11-20 22:22:04 +010022#include <string.h>
Harald Weltee07b6a72012-11-23 19:02:37 +010023#include <errno.h>
Harald Welte338e3b32012-11-20 22:22:04 +010024#include <netdb.h>
25#include <sys/socket.h>
26
27#include <osmocom/vty/command.h>
28#include <osmocom/vty/buffer.h>
29#include <osmocom/vty/vty.h>
30
31#include <osmocom/core/linuxlist.h>
32#include <osmocom/core/utils.h>
Max1470d0b2022-07-27 20:41:00 +070033#include <osmocom/core/socket.h>
Harald Welte338e3b32012-11-20 22:22:04 +010034#include <osmocom/core/talloc.h>
35
Neels Hofmeyr90843962017-09-04 15:04:35 +020036#include <osmocom/msc/vty.h>
Harald Welte338e3b32012-11-20 22:22:04 +010037
38#include "smpp_smsc.h"
39
40struct smsc *smsc_from_vty(struct vty *v);
41
42static struct cmd_node smpp_node = {
43 SMPP_NODE,
44 "%s(config-smpp)# ",
45 1,
46};
47
48static struct cmd_node esme_node = {
49 SMPP_ESME_NODE,
50 "%s(config-smpp-esme)# ",
51 1,
52};
53
54DEFUN(cfg_smpp, cfg_smpp_cmd,
55 "smpp", "Configure SMPP SMS Interface")
56{
57 vty->node = SMPP_NODE;
58
59 return CMD_SUCCESS;
60}
61
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +020062DEFUN(cfg_smpp_first, cfg_smpp_first_cmd,
63 "smpp-first",
64 "Try SMPP routes before the subscriber DB\n")
65{
66 struct smsc *smsc = smsc_from_vty(vty);
67 smsc->smpp_first = 1;
68 return CMD_SUCCESS;
69}
70
71DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd,
72 "no smpp-first",
73 NO_STR "Try SMPP before routes before the subscriber DB\n")
74{
75 struct smsc *smsc = smsc_from_vty(vty);
76 smsc->smpp_first = 0;
77 return CMD_SUCCESS;
78}
79
Neels Hofmeyr1b0e5542016-02-24 19:15:39 +010080static int smpp_local_tcp(struct vty *vty,
81 const char *bind_addr, uint16_t port)
82{
83 struct smsc *smsc = smsc_from_vty(vty);
84 int is_running = smsc->listen_ofd.fd > 0;
85 int same_bind_addr;
86 int rc;
87
88 /* If it is not up yet, don't rebind, just set values. */
89 if (!is_running) {
90 rc = smpp_smsc_conf(smsc, bind_addr, port);
91 if (rc < 0) {
92 vty_out(vty, "%% Cannot configure new address:port%s",
93 VTY_NEWLINE);
94 return CMD_WARNING;
95 }
96 return CMD_SUCCESS;
97 }
98
99 rc = smpp_smsc_restart(smsc, bind_addr, port);
100 if (rc < 0) {
101 vty_out(vty, "%% Cannot bind to new port %s:%u nor to"
102 " old port %s:%u%s",
103 bind_addr? bind_addr : "0.0.0.0",
104 port,
105 smsc->bind_addr? smsc->bind_addr : "0.0.0.0",
106 smsc->listen_port,
107 VTY_NEWLINE);
108 return CMD_WARNING;
109 }
110
111 same_bind_addr = (bind_addr == smsc->bind_addr)
112 || (bind_addr && smsc->bind_addr
113 && (strcmp(bind_addr, smsc->bind_addr) == 0));
114
115 if (!same_bind_addr || port != smsc->listen_port) {
116 vty_out(vty, "%% Cannot bind to new port %s:%u, staying on"
117 " old port %s:%u%s",
118 bind_addr? bind_addr : "0.0.0.0",
119 port,
120 smsc->bind_addr? smsc->bind_addr : "0.0.0.0",
121 smsc->listen_port,
122 VTY_NEWLINE);
123 return CMD_WARNING;
124 }
125
126 return CMD_SUCCESS;
127}
128
Harald Welte338e3b32012-11-20 22:22:04 +0100129DEFUN(cfg_smpp_port, cfg_smpp_port_cmd,
130 "local-tcp-port <1-65535>",
131 "Set the local TCP port on which we listen for SMPP\n"
132 "TCP port number")
133{
134 struct smsc *smsc = smsc_from_vty(vty);
135 uint16_t port = atoi(argv[0]);
Neels Hofmeyr1b0e5542016-02-24 19:15:39 +0100136 return smpp_local_tcp(vty, smsc->bind_addr, port);
137}
Harald Welte338e3b32012-11-20 22:22:04 +0100138
Neels Hofmeyr1b0e5542016-02-24 19:15:39 +0100139DEFUN(cfg_smpp_addr_port, cfg_smpp_addr_port_cmd,
140 "local-tcp-ip A.B.C.D <1-65535>",
141 "Set the local IP address and TCP port on which we listen for SMPP\n"
142 "Local IP address\n"
143 "TCP port number")
144{
145 const char *bind_addr = argv[0];
146 uint16_t port = atoi(argv[1]);
147 return smpp_local_tcp(vty, bind_addr, port);
Harald Welte338e3b32012-11-20 22:22:04 +0100148}
149
150DEFUN(cfg_smpp_sys_id, cfg_smpp_sys_id_cmd,
Harald Welteb4b21f52013-07-21 16:00:28 +0800151 "system-id ID",
152 "Set the System ID of this SMSC\n"
153 "Alphanumeric SMSC System ID\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100154{
155 struct smsc *smsc = smsc_from_vty(vty);
156
157 if (strlen(argv[0])+1 > sizeof(smsc->system_id))
158 return CMD_WARNING;
159
160 strcpy(smsc->system_id, argv[0]);
161
162 return CMD_SUCCESS;
163}
164
165DEFUN(cfg_smpp_policy, cfg_smpp_policy_cmd,
166 "policy (accept-all|closed)",
167 "Set the authentication policy of this SMSC\n"
Keith72520f82019-01-17 01:08:33 +0100168 "Accept all SMPP connections independent of system ID / password\n"
Harald Welte338e3b32012-11-20 22:22:04 +0100169 "Accept only SMPP connections from ESMEs explicitly configured")
170{
171 struct smsc *smsc = smsc_from_vty(vty);
172
173 if (!strcmp(argv[0], "accept-all"))
174 smsc->accept_all = 1;
175 else
176 smsc->accept_all = 0;
177
178 return CMD_SUCCESS;
179}
180
181
182static int config_write_smpp(struct vty *vty)
183{
184 struct smsc *smsc = smsc_from_vty(vty);
185
186 vty_out(vty, "smpp%s", VTY_NEWLINE);
Neels Hofmeyr1b0e5542016-02-24 19:15:39 +0100187 if (smsc->bind_addr)
188 vty_out(vty, " local-tcp-ip %s %u%s", smsc->bind_addr,
189 smsc->listen_port, VTY_NEWLINE);
190 else
191 vty_out(vty, " local-tcp-port %u%s", smsc->listen_port,
192 VTY_NEWLINE);
Holger Hans Peter Freytherae9d8d32013-07-14 08:50:57 +0200193 if (strlen(smsc->system_id) > 0)
Harald Welteb862cef2013-01-24 09:54:04 +0100194 vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE);
Harald Welte338e3b32012-11-20 22:22:04 +0100195 vty_out(vty, " policy %s%s",
196 smsc->accept_all ? "accept-all" : "closed", VTY_NEWLINE);
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200197 vty_out(vty, " %ssmpp-first%s",
198 smsc->smpp_first ? "" : "no ", VTY_NEWLINE);
Harald Welte338e3b32012-11-20 22:22:04 +0100199
200 return CMD_SUCCESS;
201}
202
203DEFUN(cfg_esme, cfg_esme_cmd,
Harald Welteb4b21f52013-07-21 16:00:28 +0800204 "esme NAME",
205 "Configure a particular ESME\n"
206 "Alphanumeric System ID of the ESME to be configured\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100207{
208 struct smsc *smsc = smsc_from_vty(vty);
209 struct osmo_smpp_acl *acl;
210 const char *id = argv[0];
211
212 if (strlen(id) > 16) {
213 vty_out(vty, "%% System ID cannot be more than 16 "
214 "characters long%s", VTY_NEWLINE);
215 return CMD_WARNING;
216 }
217 acl = smpp_acl_by_system_id(smsc, id);
218 if (!acl) {
219 acl = smpp_acl_alloc(smsc, id);
220 if (!acl)
221 return CMD_WARNING;
222 }
223
224 vty->index = acl;
225 vty->index_sub = &acl->description;
226 vty->node = SMPP_ESME_NODE;
227
228 return CMD_SUCCESS;
229}
230
231DEFUN(cfg_no_esme, cfg_no_esme_cmd,
Harald Welteb4b21f52013-07-21 16:00:28 +0800232 "no esme NAME",
233 NO_STR "Remove ESME configuration\n"
234 "Alphanumeric System ID of the ESME to be removed\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100235{
236 struct smsc *smsc = smsc_from_vty(vty);
237 struct osmo_smpp_acl *acl;
238 const char *id = argv[0];
239
240 acl = smpp_acl_by_system_id(smsc, id);
241 if (!acl) {
242 vty_out(vty, "%% ESME with system id '%s' unknown%s",
243 id, VTY_NEWLINE);
244 return CMD_WARNING;
245 }
246
247 /* FIXME: close the connection, free data structure, etc. */
248
249 smpp_acl_delete(acl);
250
251 return CMD_SUCCESS;
252}
253
254
255DEFUN(cfg_esme_passwd, cfg_esme_passwd_cmd,
Harald Welteb4b21f52013-07-21 16:00:28 +0800256 "password PASSWORD",
257 "Set the password for this ESME\n"
258 "Alphanumeric password string\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100259{
260 struct osmo_smpp_acl *acl = vty->index;
261
262 if (strlen(argv[0])+1 > sizeof(acl->passwd))
263 return CMD_WARNING;
264
265 strcpy(acl->passwd, argv[0]);
266
267 return CMD_SUCCESS;
268}
269
270DEFUN(cfg_esme_no_passwd, cfg_esme_no_passwd_cmd,
Harald Welteb4b21f52013-07-21 16:00:28 +0800271 "no password",
272 NO_STR "Remove the password for this ESME\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100273{
274 struct osmo_smpp_acl *acl = vty->index;
275
276 memset(acl->passwd, 0, sizeof(acl->passwd));
277
278 return CMD_SUCCESS;
279}
280
Harald Weltee07b6a72012-11-23 19:02:37 +0100281static int osmo_is_digits(const char *str)
282{
283 int i;
284 for (i = 0; i < strlen(str); i++) {
285 if (!isdigit(str[i]))
286 return 0;
287 }
288 return 1;
289}
290
291static const struct value_string route_errstr[] = {
292 { -EEXIST, "Route already exists" },
293 { -ENODEV, "Route does not exist" },
294 { -ENOMEM, "No memory" },
295 { -EINVAL, "Invalid" },
296 { 0, NULL }
297};
298
299static const struct value_string smpp_ton_str_short[] = {
300 { TON_Unknown, "unknown" },
301 { TON_International, "international" },
302 { TON_National, "national" },
303 { TON_Network_Specific, "network" },
304 { TON_Subscriber_Number,"subscriber" },
305 { TON_Alphanumeric, "alpha" },
306 { TON_Abbreviated, "abbrev" },
307 { 0, NULL }
308};
309
310static const struct value_string smpp_npi_str_short[] = {
311 { NPI_Unknown, "unknown" },
312 { NPI_ISDN_E163_E164, "isdn" },
313 { NPI_Data_X121, "x121" },
314 { NPI_Telex_F69, "f69" },
315 { NPI_Land_Mobile_E212, "e212" },
316 { NPI_National, "national" },
317 { NPI_Private, "private" },
318 { NPI_ERMES, "ermes" },
319 { NPI_Internet_IP, "ip" },
320 { NPI_WAP_Client_Id, "wap" },
321 { 0, NULL }
322};
323
324
325#define SMPP_ROUTE_STR "Configure a route for MO-SMS to be sent to this ESME\n"
Harald Welteb4b21f52013-07-21 16:00:28 +0800326#define SMPP_ROUTE_P_STR SMPP_ROUTE_STR "Prefix-match route\n"
Harald Weltee07b6a72012-11-23 19:02:37 +0100327#define SMPP_PREFIX_STR "Destination number prefix\n"
328
329#define TON_CMD "(unknown|international|national|network|subscriber|alpha|abbrev)"
330#define NPI_CMD "(unknown|isdn|x121|f69|e212|national|private|ermes|ip|wap)"
Harald Welteb4b21f52013-07-21 16:00:28 +0800331#define TON_STR "Unknown type-of-number\n" \
332 "International type-of-number\n" \
333 "National type-of-number\n" \
334 "Network specific type-of-number\n" \
335 "Subscriber type-of-number\n" \
336 "Alphanumeric type-of-number\n" \
337 "Abbreviated type-of-number\n"
338#define NPI_STR "Unknown numbering plan\n" \
339 "ISDN (E.164) numbering plan\n" \
340 "X.121 numbering plan\n" \
341 "F.69 numbering plan\n" \
342 "E.212 numbering plan\n" \
343 "National numbering plan\n" \
344 "Private numbering plan\n" \
345 "ERMES numbering plan\n" \
346 "IP numbering plan\n" \
347 "WAP numbeing plan\n"
Harald Weltee07b6a72012-11-23 19:02:37 +0100348
349DEFUN(cfg_esme_route_pfx, cfg_esme_route_pfx_cmd,
350 "route prefix " TON_CMD " " NPI_CMD " PREFIX",
351 SMPP_ROUTE_P_STR TON_STR NPI_STR SMPP_PREFIX_STR)
Harald Welte338e3b32012-11-20 22:22:04 +0100352{
353 struct osmo_smpp_acl *acl = vty->index;
Harald Weltee07b6a72012-11-23 19:02:37 +0100354 struct osmo_smpp_addr pfx;
355 int rc;
Harald Welte338e3b32012-11-20 22:22:04 +0100356
Harald Weltee07b6a72012-11-23 19:02:37 +0100357 /* check if DESTINATION is all-digits */
358 if (!osmo_is_digits(argv[2])) {
359 vty_out(vty, "%% PREFIX has to be numeric%s", VTY_NEWLINE);
360 return CMD_WARNING;
361 }
362
363 pfx.ton = get_string_value(smpp_ton_str_short, argv[0]);
364 pfx.npi = get_string_value(smpp_npi_str_short, argv[1]);
365 snprintf(pfx.addr, sizeof(pfx.addr), "%s", argv[2]);
366
367 rc = smpp_route_pfx_add(acl, &pfx);
368 if (rc < 0) {
369 vty_out(vty, "%% error adding prefix route: %s%s",
370 get_value_string(route_errstr, rc), VTY_NEWLINE);
371 return CMD_WARNING;
372 }
Harald Welte338e3b32012-11-20 22:22:04 +0100373
374 return CMD_SUCCESS;
375}
376
Harald Weltee07b6a72012-11-23 19:02:37 +0100377DEFUN(cfg_esme_no_route_pfx, cfg_esme_no_route_pfx_cmd,
378 "no route prefix " TON_CMD " " NPI_CMD " PREFIX",
379 NO_STR SMPP_ROUTE_P_STR TON_STR NPI_STR SMPP_PREFIX_STR)
380{
381 struct osmo_smpp_acl *acl = vty->index;
382 struct osmo_smpp_addr pfx;
383 int rc;
384
385 /* check if DESTINATION is all-digits */
386 if (!osmo_is_digits(argv[2])) {
387 vty_out(vty, "%% PREFIX has to be numeric%s", VTY_NEWLINE);
388 return CMD_WARNING;
389 }
390
391 pfx.ton = get_string_value(smpp_ton_str_short, argv[0]);
392 pfx.npi = get_string_value(smpp_npi_str_short, argv[1]);
393 snprintf(pfx.addr, sizeof(pfx.addr), "%s", argv[2]);
394
395 rc = smpp_route_pfx_del(acl, &pfx);
396 if (rc < 0) {
397 vty_out(vty, "%% error removing prefix route: %s%s",
398 get_value_string(route_errstr, rc), VTY_NEWLINE);
399 return CMD_WARNING;
400 }
401
402 return CMD_SUCCESS;
403
404}
405
406
Harald Welte338e3b32012-11-20 22:22:04 +0100407DEFUN(cfg_esme_defaultroute, cfg_esme_defaultroute_cmd,
408 "default-route",
409 "Set this ESME as default-route for all SMS to unknown destinations")
410{
411 struct osmo_smpp_acl *acl = vty->index;
412
413 acl->default_route = 1;
414
Harald Weltee07b6a72012-11-23 19:02:37 +0100415 if (!acl->smsc->def_route)
416 acl->smsc->def_route = acl;
417
Harald Welte338e3b32012-11-20 22:22:04 +0100418 return CMD_SUCCESS;
419}
420
421DEFUN(cfg_no_esme_defaultroute, cfg_esme_no_defaultroute_cmd,
422 "no default-route", NO_STR
Harald Welteb4b21f52013-07-21 16:00:28 +0800423 "Remove this ESME as default-route for all SMS to unknown destinations")
Harald Welte338e3b32012-11-20 22:22:04 +0100424{
425 struct osmo_smpp_acl *acl = vty->index;
426
427 acl->default_route = 0;
428
429 /* remove currently active default route, if it was created by
430 * this ACL */
Harald Weltee07b6a72012-11-23 19:02:37 +0100431 if (acl->smsc->def_route && acl->smsc->def_route == acl)
Harald Welte338e3b32012-11-20 22:22:04 +0100432 acl->smsc->def_route = NULL;
433
434 return CMD_SUCCESS;
435}
436
Harald Welte6a399ef2013-09-02 16:41:00 +0200437DEFUN(cfg_esme_del_src_imsi, cfg_esme_del_src_imsi_cmd,
438 "deliver-src-imsi",
Ruben Undheim59d57da2016-12-20 17:38:31 +0100439 "Enable the use of IMSI as source address in DELIVER")
Harald Welte6a399ef2013-09-02 16:41:00 +0200440{
441 struct osmo_smpp_acl *acl = vty->index;
442
443 acl->deliver_src_imsi = 1;
444
445 return CMD_SUCCESS;
446}
447
448DEFUN(cfg_esme_no_del_src_imsi, cfg_esme_no_del_src_imsi_cmd,
449 "no deliver-src-imsi", NO_STR
Ruben Undheim59d57da2016-12-20 17:38:31 +0100450 "Disable the use of IMSI as source address in DELIVER")
Harald Welte6a399ef2013-09-02 16:41:00 +0200451{
452 struct osmo_smpp_acl *acl = vty->index;
453
454 acl->deliver_src_imsi = 0;
455
456 return CMD_SUCCESS;
457}
458
Harald Welte3f786002013-03-13 15:29:27 +0100459DEFUN(cfg_esme_osmo_ext, cfg_esme_osmo_ext_cmd,
460 "osmocom-extensions",
461 "Enable the use of Osmocom SMPP Extensions for this ESME")
462{
463 struct osmo_smpp_acl *acl = vty->index;
464
465 acl->osmocom_ext = 1;
466
467 return CMD_SUCCESS;
468}
469
470DEFUN(cfg_esme_no_osmo_ext, cfg_esme_no_osmo_ext_cmd,
471 "no osmocom-extensions", NO_STR
472 "Disable the use of Osmocom SMPP Extensions for this ESME")
473{
474 struct osmo_smpp_acl *acl = vty->index;
475
476 acl->osmocom_ext = 0;
477
478 return CMD_SUCCESS;
479}
480
Harald Weltec75ed6d2013-05-28 20:58:02 +0200481DEFUN(cfg_esme_dcs_transp, cfg_esme_dcs_transp_cmd,
482 "dcs-transparent",
483 "Enable the transparent pass-through of TP-DCS to SMPP DataCoding")
484{
485 struct osmo_smpp_acl *acl = vty->index;
486
487 acl->dcs_transparent = 1;
488
489 return CMD_SUCCESS;
490}
491
492DEFUN(cfg_esme_no_dcs_transp, cfg_esme_no_dcs_transp_cmd,
493 "no dcs-transparent", NO_STR
494 "Disable the transparent pass-through of TP-DCS to SMPP DataCoding")
495{
496 struct osmo_smpp_acl *acl = vty->index;
497
498 acl->dcs_transparent = 0;
499
500 return CMD_SUCCESS;
501}
502
Keithc6d219c2019-01-17 01:01:59 +0100503DEFUN(cfg_esme_alert_notif, cfg_esme_alert_notif_cmd,
504 "alert-notifications",
Harald Welte30811f82021-09-25 18:42:23 +0200505 "Enable sending of SMPP Alert Notifications for this ESME")
Keithc6d219c2019-01-17 01:01:59 +0100506{
507 struct osmo_smpp_acl *acl = vty->index;
508
509 acl->alert_notifications = 1;
510
511 return CMD_SUCCESS;
512}
513
514DEFUN(cfg_esme_no_alert_notif, cfg_esme_no_alert_notif_cmd,
515 "no alert-notifications", NO_STR
516 "Disable sending of SMPP Alert Notifications for this ESME")
517{
518 struct osmo_smpp_acl *acl = vty->index;
519
520 acl->alert_notifications = 0;
521
522 return CMD_SUCCESS;
523}
524
Harald Weltec75ed6d2013-05-28 20:58:02 +0200525
Harald Welte338e3b32012-11-20 22:22:04 +0100526static void dump_one_esme(struct vty *vty, struct osmo_esme *esme)
527{
Harald Welte338e3b32012-11-20 22:22:04 +0100528 vty_out(vty, "ESME System ID: %s, Password: %s, SMPP Version %02x%s",
Harald Weltee07b6a72012-11-23 19:02:37 +0100529 esme->system_id, esme->acl ? esme->acl->passwd : "",
530 esme->smpp_version, VTY_NEWLINE);
Max1470d0b2022-07-27 20:41:00 +0700531 vty_out(vty, " Connection %s%s", osmo_sock_get_name(tall_vty_ctx, esme->wqueue.bfd.fd), VTY_NEWLINE);
Harald Weltee07b6a72012-11-23 19:02:37 +0100532 if (esme->smsc->def_route == esme->acl)
533 vty_out(vty, " Is current default route%s", VTY_NEWLINE);
Harald Welte338e3b32012-11-20 22:22:04 +0100534}
535
536DEFUN(show_esme, show_esme_cmd,
537 "show smpp esme",
Keith72520f82019-01-17 01:08:33 +0100538 SHOW_STR "SMPP Interface\n" "SMPP External SMS Entity\n")
Harald Welte338e3b32012-11-20 22:22:04 +0100539{
540 struct smsc *smsc = smsc_from_vty(vty);
541 struct osmo_esme *esme;
542
543 llist_for_each_entry(esme, &smsc->esme_list, list)
544 dump_one_esme(vty, esme);
545
546 return CMD_SUCCESS;
547}
548
Harald Weltee07b6a72012-11-23 19:02:37 +0100549static void write_esme_route_single(struct vty *vty, struct osmo_smpp_route *r)
550{
551 switch (r->type) {
552 case SMPP_ROUTE_PREFIX:
553 vty_out(vty, " route prefix %s ",
554 get_value_string(smpp_ton_str_short, r->u.prefix.ton));
555 vty_out(vty, "%s %s%s",
556 get_value_string(smpp_npi_str_short, r->u.prefix.npi),
557 r->u.prefix.addr, VTY_NEWLINE);
558 break;
559 case SMPP_ROUTE_NONE:
560 break;
561 }
562}
563
Harald Welte338e3b32012-11-20 22:22:04 +0100564static void config_write_esme_single(struct vty *vty, struct osmo_smpp_acl *acl)
565{
Harald Weltee07b6a72012-11-23 19:02:37 +0100566 struct osmo_smpp_route *r;
567
Harald Welte338e3b32012-11-20 22:22:04 +0100568 vty_out(vty, " esme %s%s", acl->system_id, VTY_NEWLINE);
569 if (strlen(acl->passwd))
570 vty_out(vty, " password %s%s", acl->passwd, VTY_NEWLINE);
571 if (acl->default_route)
572 vty_out(vty, " default-route%s", VTY_NEWLINE);
Harald Weltee07b6a72012-11-23 19:02:37 +0100573 if (acl->deliver_src_imsi)
574 vty_out(vty, " deliver-src-imsi%s", VTY_NEWLINE);
Harald Welte3f786002013-03-13 15:29:27 +0100575 if (acl->osmocom_ext)
576 vty_out(vty, " osmocom-extensions%s", VTY_NEWLINE);
Harald Weltec75ed6d2013-05-28 20:58:02 +0200577 if (acl->dcs_transparent)
578 vty_out(vty, " dcs-transparent%s", VTY_NEWLINE);
Keith18f11382019-03-19 15:14:19 +0100579 if (!acl->alert_notifications)
580 vty_out(vty, " no alert-notifications%s", VTY_NEWLINE);
Harald Weltee07b6a72012-11-23 19:02:37 +0100581
582 llist_for_each_entry(r, &acl->route_list, list)
583 write_esme_route_single(vty, r);
Harald Welte338e3b32012-11-20 22:22:04 +0100584}
585
586static int config_write_esme(struct vty *v)
587{
588 struct smsc *smsc = smsc_from_vty(v);
589 struct osmo_smpp_acl *acl;
590
591 llist_for_each_entry(acl, &smsc->acl_list, list)
592 config_write_esme_single(v, acl);
593
594 return CMD_SUCCESS;
595}
596
597int smpp_vty_init(void)
598{
599 install_node(&smpp_node, config_write_smpp);
Harald Welte338e3b32012-11-20 22:22:04 +0100600 install_element(CONFIG_NODE, &cfg_smpp_cmd);
601
Holger Hans Peter Freyther42cf2e02015-07-06 16:41:30 +0200602 install_element(SMPP_NODE, &cfg_smpp_first_cmd);
603 install_element(SMPP_NODE, &cfg_no_smpp_first_cmd);
Harald Welte338e3b32012-11-20 22:22:04 +0100604 install_element(SMPP_NODE, &cfg_smpp_port_cmd);
Neels Hofmeyr1b0e5542016-02-24 19:15:39 +0100605 install_element(SMPP_NODE, &cfg_smpp_addr_port_cmd);
Harald Welte338e3b32012-11-20 22:22:04 +0100606 install_element(SMPP_NODE, &cfg_smpp_sys_id_cmd);
607 install_element(SMPP_NODE, &cfg_smpp_policy_cmd);
608 install_element(SMPP_NODE, &cfg_esme_cmd);
609 install_element(SMPP_NODE, &cfg_no_esme_cmd);
610
611 install_node(&esme_node, config_write_esme);
Harald Welte338e3b32012-11-20 22:22:04 +0100612 install_element(SMPP_ESME_NODE, &cfg_esme_passwd_cmd);
613 install_element(SMPP_ESME_NODE, &cfg_esme_no_passwd_cmd);
Harald Weltee07b6a72012-11-23 19:02:37 +0100614 install_element(SMPP_ESME_NODE, &cfg_esme_route_pfx_cmd);
615 install_element(SMPP_ESME_NODE, &cfg_esme_no_route_pfx_cmd);
Harald Welte338e3b32012-11-20 22:22:04 +0100616 install_element(SMPP_ESME_NODE, &cfg_esme_defaultroute_cmd);
617 install_element(SMPP_ESME_NODE, &cfg_esme_no_defaultroute_cmd);
Harald Welte6a399ef2013-09-02 16:41:00 +0200618 install_element(SMPP_ESME_NODE, &cfg_esme_del_src_imsi_cmd);
619 install_element(SMPP_ESME_NODE, &cfg_esme_no_del_src_imsi_cmd);
Harald Welte3f786002013-03-13 15:29:27 +0100620 install_element(SMPP_ESME_NODE, &cfg_esme_osmo_ext_cmd);
621 install_element(SMPP_ESME_NODE, &cfg_esme_no_osmo_ext_cmd);
Harald Weltec75ed6d2013-05-28 20:58:02 +0200622 install_element(SMPP_ESME_NODE, &cfg_esme_dcs_transp_cmd);
623 install_element(SMPP_ESME_NODE, &cfg_esme_no_dcs_transp_cmd);
Keithc6d219c2019-01-17 01:01:59 +0100624 install_element(SMPP_ESME_NODE, &cfg_esme_alert_notif_cmd);
625 install_element(SMPP_ESME_NODE, &cfg_esme_no_alert_notif_cmd);
Harald Welte338e3b32012-11-20 22:22:04 +0100626
627 install_element_ve(&show_esme_cmd);
628
629 return 0;
630}