blob: 42fc0256079266dbdf9348b439b3ed139bbc30f3 [file] [log] [blame]
Harald Welte144e0292010-05-13 11:45:07 +02001/* VTY interface for our GPRS Networks Service (NS) implementation */
2
3/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Weltee4cbb3f2011-01-01 15:25:50 +01008 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
Harald Welte144e0292010-05-13 11:45:07 +020010 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Weltee4cbb3f2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Harald Welte144e0292010-05-13 11:45:07 +020016 *
Harald Weltee4cbb3f2011-01-01 15:25:50 +010017 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte144e0292010-05-13 11:45:07 +020019 *
20 */
21
22#include <stdlib.h>
23#include <unistd.h>
24#include <errno.h>
25#include <stdint.h>
26
27#include <arpa/inet.h>
28
29#include <openbsc/gsm_data.h>
30#include <osmocore/msgb.h>
31#include <osmocore/tlv.h>
32#include <osmocore/talloc.h>
33#include <osmocore/select.h>
34#include <osmocore/rate_ctr.h>
35#include <openbsc/debug.h>
36#include <openbsc/signal.h>
37#include <openbsc/gprs_ns.h>
38#include <openbsc/gprs_bssgp.h>
Harald Welte804fc812010-05-14 18:59:17 +020039#include <openbsc/vty.h>
Harald Welte144e0292010-05-13 11:45:07 +020040
Harald Welteac1a7152010-05-19 19:45:32 +020041#include <osmocom/vty/vty.h>
42#include <osmocom/vty/command.h>
43#include <osmocom/vty/logging.h>
44#include <osmocom/vty/telnet_interface.h>
Harald Welte144e0292010-05-13 11:45:07 +020045
46static struct gprs_ns_inst *vty_nsi = NULL;
47
48/* FIXME: this should go to some common file as it is copied
49 * in vty_interface.c of the BSC */
50static const struct value_string gprs_ns_timer_strs[] = {
51 { 0, "tns-block" },
52 { 1, "tns-block-retries" },
53 { 2, "tns-reset" },
54 { 3, "tns-reset-retries" },
55 { 4, "tns-test" },
56 { 5, "tns-alive" },
57 { 6, "tns-alive-retries" },
58 { 0, NULL }
59};
60
61static struct cmd_node ns_node = {
62 NS_NODE,
63 "%s(ns)#",
64 1,
65};
66
67static int config_write_ns(struct vty *vty)
68{
69 struct gprs_nsvc *nsvc;
70 unsigned int i;
Harald Welte7fb05232010-05-19 15:09:09 +020071 struct in_addr ia;
Harald Welte144e0292010-05-13 11:45:07 +020072
73 vty_out(vty, "ns%s", VTY_NEWLINE);
74
75 llist_for_each_entry(nsvc, &vty_nsi->gprs_nsvcs, list) {
76 if (!nsvc->persistent)
77 continue;
78 vty_out(vty, " nse %u nsvci %u%s",
79 nsvc->nsei, nsvc->nsvci, VTY_NEWLINE);
80 vty_out(vty, " nse %u remote-role %s%s",
81 nsvc->nsei, nsvc->remote_end_is_sgsn ? "sgsn" : "bss",
82 VTY_NEWLINE);
Harald Welteb3ee2652010-05-19 14:38:50 +020083 switch (nsvc->ll) {
84 case GPRS_NS_LL_UDP:
85 vty_out(vty, " nse %u encapsulation udp%s", nsvc->nsei,
86 VTY_NEWLINE);
Harald Welte144e0292010-05-13 11:45:07 +020087 vty_out(vty, " nse %u remote-ip %s%s",
88 nsvc->nsei,
89 inet_ntoa(nsvc->ip.bts_addr.sin_addr),
90 VTY_NEWLINE);
91 vty_out(vty, " nse %u remote-port %u%s",
92 nsvc->nsei, ntohs(nsvc->ip.bts_addr.sin_port),
93 VTY_NEWLINE);
Harald Welteb3ee2652010-05-19 14:38:50 +020094 break;
95 case GPRS_NS_LL_FR_GRE:
96 vty_out(vty, " nse %u encapsulation framerelay-gre%s",
97 nsvc->nsei, VTY_NEWLINE);
98 vty_out(vty, " nse %u remote-ip %s%s",
99 nsvc->nsei,
100 inet_ntoa(nsvc->frgre.bts_addr.sin_addr),
101 VTY_NEWLINE);
102 vty_out(vty, " nse %u fr-dlci %u%s",
103 nsvc->nsei, ntohs(nsvc->frgre.bts_addr.sin_port),
104 VTY_NEWLINE);
105 default:
106 break;
Harald Welte144e0292010-05-13 11:45:07 +0200107 }
108 }
109
110 for (i = 0; i < ARRAY_SIZE(vty_nsi->timeout); i++)
111 vty_out(vty, " timer %s %u%s",
112 get_value_string(gprs_ns_timer_strs, i),
113 vty_nsi->timeout[i], VTY_NEWLINE);
114
Harald Welte7fb05232010-05-19 15:09:09 +0200115 if (vty_nsi->nsip.local_ip) {
116 ia.s_addr = htonl(vty_nsi->nsip.local_ip);
117 vty_out(vty, " encapsulation udp local-ip %s%s",
118 inet_ntoa(ia), VTY_NEWLINE);
Harald Welte7fb05232010-05-19 15:09:09 +0200119 }
Harald Weltece4ccbc2010-05-19 17:02:57 +0200120 if (vty_nsi->nsip.local_port)
121 vty_out(vty, " encapsulation udp local-port %u%s",
122 vty_nsi->nsip.local_port, VTY_NEWLINE);
123
Harald Welte7fb05232010-05-19 15:09:09 +0200124 vty_out(vty, " encapsulation framerelay-gre enabled %u%s",
125 vty_nsi->frgre.enabled ? 1 : 0, VTY_NEWLINE);
Harald Weltece4ccbc2010-05-19 17:02:57 +0200126 if (vty_nsi->frgre.local_ip) {
Harald Welte7fb05232010-05-19 15:09:09 +0200127 ia.s_addr = htonl(vty_nsi->frgre.local_ip);
128 vty_out(vty, " encapsulation framerelay-gre local-ip %s%s",
129 inet_ntoa(ia), VTY_NEWLINE);
130 }
131
Harald Welte144e0292010-05-13 11:45:07 +0200132 return CMD_SUCCESS;
133}
134
135DEFUN(cfg_ns, cfg_ns_cmd,
136 "ns",
137 "Configure the GPRS Network Service")
138{
139 vty->node = NS_NODE;
140 return CMD_SUCCESS;
141}
142
Harald Welte92883342010-05-15 23:04:03 +0200143static void dump_nse(struct vty *vty, struct gprs_nsvc *nsvc, int stats)
144{
145 vty_out(vty, "NSEI %5u, NS-VC %5u, Remote: %-4s, %5s %9s",
146 nsvc->nsei, nsvc->nsvci,
147 nsvc->remote_end_is_sgsn ? "SGSN" : "BSS",
148 nsvc->state & NSE_S_ALIVE ? "ALIVE" : "DEAD",
149 nsvc->state & NSE_S_BLOCKED ? "BLOCKED" : "UNBLOCKED");
Harald Welteb3ee2652010-05-19 14:38:50 +0200150 if (nsvc->ll == GPRS_NS_LL_UDP || nsvc->ll == GPRS_NS_LL_FR_GRE)
151 vty_out(vty, ", %s %15s:%u",
Harald Weltece4ccbc2010-05-19 17:02:57 +0200152 nsvc->ll == GPRS_NS_LL_UDP ? "UDP " : "FR-GRE",
Harald Welte92883342010-05-15 23:04:03 +0200153 inet_ntoa(nsvc->ip.bts_addr.sin_addr),
154 ntohs(nsvc->ip.bts_addr.sin_port));
155 vty_out(vty, "%s", VTY_NEWLINE);
156 if (stats)
157 vty_out_rate_ctr_group(vty, " ", nsvc->ctrg);
158}
159
Harald Welteaf1d4cb2010-05-13 12:32:30 +0200160static void dump_ns(struct vty *vty, struct gprs_ns_inst *nsi, int stats)
Harald Welte144e0292010-05-13 11:45:07 +0200161{
Harald Welte144e0292010-05-13 11:45:07 +0200162 struct gprs_nsvc *nsvc;
Harald Welte7fb05232010-05-19 15:09:09 +0200163 struct in_addr ia;
164
165 ia.s_addr = htonl(vty_nsi->nsip.local_ip);
Harald Weltece4ccbc2010-05-19 17:02:57 +0200166 vty_out(vty, "Encapsulation NS-UDP-IP Local IP: %s, UDP Port: %u%s",
Harald Welte7fb05232010-05-19 15:09:09 +0200167 inet_ntoa(ia), vty_nsi->nsip.local_port, VTY_NEWLINE);
168
169 ia.s_addr = htonl(vty_nsi->frgre.local_ip);
Harald Weltece4ccbc2010-05-19 17:02:57 +0200170 vty_out(vty, "Encapsulation NS-FR-GRE-IP Local IP: %s%s",
Harald Welte7fb05232010-05-19 15:09:09 +0200171 inet_ntoa(ia), VTY_NEWLINE);
Harald Welte144e0292010-05-13 11:45:07 +0200172
173 llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
Harald Weltedd1c83c2010-05-13 13:58:08 +0200174 if (nsvc == nsi->unknown_nsvc)
175 continue;
Harald Welte92883342010-05-15 23:04:03 +0200176 dump_nse(vty, nsvc, stats);
Harald Welte144e0292010-05-13 11:45:07 +0200177 }
Harald Welteaf1d4cb2010-05-13 12:32:30 +0200178}
Harald Welte144e0292010-05-13 11:45:07 +0200179
Harald Welteaf1d4cb2010-05-13 12:32:30 +0200180DEFUN(show_ns, show_ns_cmd, "show ns",
181 SHOW_STR "Display information about the NS protocol")
182{
183 struct gprs_ns_inst *nsi = vty_nsi;
184 dump_ns(vty, nsi, 0);
Harald Welte144e0292010-05-13 11:45:07 +0200185 return CMD_SUCCESS;
186}
187
Harald Welteaf1d4cb2010-05-13 12:32:30 +0200188DEFUN(show_ns_stats, show_ns_stats_cmd, "show ns stats",
189 SHOW_STR
190 "Display information about the NS protocol\n"
191 "Include statistics\n")
192{
193 struct gprs_ns_inst *nsi = vty_nsi;
194 dump_ns(vty, nsi, 1);
195 return CMD_SUCCESS;
196}
Harald Welte144e0292010-05-13 11:45:07 +0200197
Harald Welte92883342010-05-15 23:04:03 +0200198DEFUN(show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]",
199 SHOW_STR "Display information about the NS protocol\n"
200 "Select one NSE by its NSE Identifier\n"
201 "Select one NSE by its NS-VC Identifier\n"
202 "The Identifier of selected type\n"
203 "Include Statistics\n")
204{
205 struct gprs_ns_inst *nsi = vty_nsi;
206 struct gprs_nsvc *nsvc;
207 uint16_t id = atoi(argv[1]);
208 int show_stats = 0;
209
210 if (!strcmp(argv[0], "nsei"))
211 nsvc = nsvc_by_nsei(nsi, id);
212 else
213 nsvc = nsvc_by_nsvci(nsi, id);
214
215 if (!nsvc) {
216 vty_out(vty, "No such NS Entity%s", VTY_NEWLINE);
217 return CMD_WARNING;
218 }
219
220 if (argc >= 3)
221 show_stats = 1;
222
223 dump_nse(vty, nsvc, show_stats);
224 return CMD_SUCCESS;
225}
226
Harald Welte24133c32010-05-15 23:06:26 +0200227#define NSE_CMD_STR "Persistent NS Entity\n" "NS Entity ID (NSEI)\n"
Harald Welte144e0292010-05-13 11:45:07 +0200228
229DEFUN(cfg_nse_nsvc, cfg_nse_nsvci_cmd,
230 "nse <0-65535> nsvci <0-65534>",
231 NSE_CMD_STR
232 "NS Virtual Connection\n"
233 "NS Virtual Connection ID (NSVCI)\n"
234 )
235{
236 uint16_t nsei = atoi(argv[0]);
237 uint16_t nsvci = atoi(argv[1]);
238 struct gprs_nsvc *nsvc;
239
240 nsvc = nsvc_by_nsei(vty_nsi, nsei);
241 if (!nsvc) {
242 nsvc = nsvc_create(vty_nsi, nsvci);
243 nsvc->nsei = nsei;
244 }
245 nsvc->nsvci = nsvci;
246 /* All NSVCs that are explicitly configured by VTY are
247 * marked as persistent so we can write them to the config
248 * file at some later point */
249 nsvc->persistent = 1;
250
251 return CMD_SUCCESS;
252}
253
254DEFUN(cfg_nse_remoteip, cfg_nse_remoteip_cmd,
255 "nse <0-65535> remote-ip A.B.C.D",
256 NSE_CMD_STR
257 "Remote IP Address\n"
258 "Remote IP Address\n")
259{
260 uint16_t nsei = atoi(argv[0]);
261 struct gprs_nsvc *nsvc;
262
263 nsvc = nsvc_by_nsei(vty_nsi, nsei);
264 if (!nsvc) {
265 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
266 return CMD_WARNING;
267 }
268 inet_aton(argv[1], &nsvc->ip.bts_addr.sin_addr);
269
270 return CMD_SUCCESS;
271
272}
273
274DEFUN(cfg_nse_remoteport, cfg_nse_remoteport_cmd,
275 "nse <0-65535> remote-port <0-65535>",
276 NSE_CMD_STR
277 "Remote UDP Port\n"
278 "Remote UDP Port Number\n")
279{
280 uint16_t nsei = atoi(argv[0]);
281 uint16_t port = atoi(argv[1]);
282 struct gprs_nsvc *nsvc;
283
284 nsvc = nsvc_by_nsei(vty_nsi, nsei);
285 if (!nsvc) {
286 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
287 return CMD_WARNING;
288 }
289
Harald Welteb3ee2652010-05-19 14:38:50 +0200290 if (nsvc->ll != GPRS_NS_LL_UDP) {
291 vty_out(vty, "Cannot set UDP Port on non-UDP NSE%s",
292 VTY_NEWLINE);
293 return CMD_WARNING;
294 }
295
Harald Welte144e0292010-05-13 11:45:07 +0200296 nsvc->ip.bts_addr.sin_port = htons(port);
297
298 return CMD_SUCCESS;
299}
300
Harald Welteb3ee2652010-05-19 14:38:50 +0200301DEFUN(cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd,
Harald Welte188bda62010-05-28 14:11:49 +0200302 "nse <0-65535> fr-dlci <16-1007>",
Harald Welteb3ee2652010-05-19 14:38:50 +0200303 NSE_CMD_STR
304 "Frame Relay DLCI\n"
305 "Frame Relay DLCI Number\n")
306{
307 uint16_t nsei = atoi(argv[0]);
308 uint16_t dlci = atoi(argv[1]);
309 struct gprs_nsvc *nsvc;
310
311 nsvc = nsvc_by_nsei(vty_nsi, nsei);
312 if (!nsvc) {
313 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
314 return CMD_WARNING;
315 }
316
317 if (nsvc->ll != GPRS_NS_LL_FR_GRE) {
318 vty_out(vty, "Cannot set FR DLCI on non-FR NSE%s",
319 VTY_NEWLINE);
320 return CMD_WARNING;
321 }
322
323 nsvc->frgre.bts_addr.sin_port = htons(dlci);
324
325 return CMD_SUCCESS;
326}
327
328DEFUN(cfg_nse_encaps, cfg_nse_encaps_cmd,
329 "nse <0-65535> encapsulation (udp|framerelay-gre)",
330 NSE_CMD_STR
331 "Encapsulation for NS\n"
332 "UDP/IP Encapsulation\n" "Frame-Relay/GRE/IP Encapsulation\n")
333{
334 uint16_t nsei = atoi(argv[0]);
335 struct gprs_nsvc *nsvc;
336
337 nsvc = nsvc_by_nsei(vty_nsi, nsei);
338 if (!nsvc) {
339 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
340 return CMD_WARNING;
341 }
342
343 if (!strcmp(argv[1], "udp"))
344 nsvc->ll = GPRS_NS_LL_UDP;
345 else
346 nsvc->ll = GPRS_NS_LL_FR_GRE;
347
348 return CMD_SUCCESS;
349}
350
351
Harald Welte144e0292010-05-13 11:45:07 +0200352DEFUN(cfg_nse_remoterole, cfg_nse_remoterole_cmd,
353 "nse <0-65535> remote-role (sgsn|bss)",
354 NSE_CMD_STR
355 "Remote NSE Role\n"
356 "Remote Peer is SGSN\n"
357 "Remote Peer is BSS\n")
358{
359 uint16_t nsei = atoi(argv[0]);
360 struct gprs_nsvc *nsvc;
361
362 nsvc = nsvc_by_nsei(vty_nsi, nsei);
363 if (!nsvc) {
364 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
365 return CMD_WARNING;
366 }
367
368 if (!strcmp(argv[1], "sgsn"))
369 nsvc->remote_end_is_sgsn = 1;
370 else
371 nsvc->remote_end_is_sgsn = 0;
372
373 return CMD_SUCCESS;
374}
375
376DEFUN(cfg_no_nse, cfg_no_nse_cmd,
377 "no nse <0-65535>",
Harald Welte24133c32010-05-15 23:06:26 +0200378 "Delete Persistent NS Entity\n"
Harald Welte144e0292010-05-13 11:45:07 +0200379 "Delete " NSE_CMD_STR)
380{
381 uint16_t nsei = atoi(argv[0]);
382 struct gprs_nsvc *nsvc;
383
384 nsvc = nsvc_by_nsei(vty_nsi, nsei);
385 if (!nsvc) {
386 vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
387 return CMD_WARNING;
388 }
389
Harald Welte24133c32010-05-15 23:06:26 +0200390 if (!nsvc->persistent) {
391 vty_out(vty, "NSEI %u is not a persistent NSE%s",
392 nsei, VTY_NEWLINE);
393 return CMD_WARNING;
394 }
395
396 nsvc->persistent = 0;
Harald Welte144e0292010-05-13 11:45:07 +0200397
398 return CMD_SUCCESS;
399}
400
401DEFUN(cfg_ns_timer, cfg_ns_timer_cmd,
402 "timer " NS_TIMERS " <0-65535>",
403 "Network Service Timer\n"
404 NS_TIMERS_HELP "Timer Value\n")
405{
406 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
407 int val = atoi(argv[1]);
408
409 if (idx < 0 || idx >= ARRAY_SIZE(vty_nsi->timeout))
410 return CMD_WARNING;
411
412 vty_nsi->timeout[idx] = val;
413
414 return CMD_SUCCESS;
415}
416
Harald Welte7fb05232010-05-19 15:09:09 +0200417#define ENCAPS_STR "NS encapsulation options\n"
418
419DEFUN(cfg_nsip_local_ip, cfg_nsip_local_ip_cmd,
420 "encapsulation udp local-ip A.B.C.D",
421 ENCAPS_STR "NS over UDP Encapsulation\n"
422 "Set the IP address on which we listen for NS/UDP\n"
423 "IP Address\n")
424{
425 struct in_addr ia;
426
427 inet_aton(argv[0], &ia);
428 vty_nsi->nsip.local_ip = ntohl(ia.s_addr);
429
430 return CMD_SUCCESS;
431}
432
433DEFUN(cfg_nsip_local_port, cfg_nsip_local_port_cmd,
434 "encapsulation udp local-port <0-65535>",
435 ENCAPS_STR "NS over UDP Encapsulation\n"
436 "Set the UDP port on which we listen for NS/UDP\n"
437 "UDP port number\n")
438{
439 unsigned int port = atoi(argv[0]);
440
441 vty_nsi->nsip.local_port = port;
442
443 return CMD_SUCCESS;
444}
445
446DEFUN(cfg_frgre_local_ip, cfg_frgre_local_ip_cmd,
447 "encapsulation framerelay-gre local-ip A.B.C.D",
448 ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n"
449 "Set the IP address on which we listen for NS/FR/GRE\n"
450 "IP Address\n")
451{
452 struct in_addr ia;
453
454 if (!vty_nsi->frgre.enabled) {
455 vty_out(vty, "FR/GRE is not enabled%s", VTY_NEWLINE);
456 return CMD_WARNING;
457 }
458 inet_aton(argv[0], &ia);
459 vty_nsi->frgre.local_ip = ntohl(ia.s_addr);
460
461 return CMD_SUCCESS;
462}
463
464DEFUN(cfg_frgre_enable, cfg_frgre_enable_cmd,
465 "encapsulation framerelay-gre enabled (1|0)",
466 ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n"
467 "Enable or disable Frame Relay over GRE\n"
468 "Enable\n" "Disable\n")
469{
470 int enabled = atoi(argv[0]);
471
472 vty_nsi->frgre.enabled = enabled;
473
474 return CMD_SUCCESS;
475}
476
Harald Welte43f3b692010-05-14 19:36:59 +0200477DEFUN(nsvc_nsei, nsvc_nsei_cmd,
478 "nsvc nsei <0-65535> (block|unblock|reset)",
479 "Perform an operation on a NSVC\n"
480 "NS-VC Identifier (NS-VCI)\n"
481 "Initiate BLOCK procedure\n"
482 "Initiate UNBLOCK procedure\n"
483 "Initiate RESET procedure\n")
484{
485 uint16_t nsvci = atoi(argv[0]);
486 const char *operation = argv[1];
487 struct gprs_nsvc *nsvc;
488
489 nsvc = nsvc_by_nsei(vty_nsi, nsvci);
490 if (!nsvc) {
491 vty_out(vty, "No such NSVCI (%u)%s", nsvci, VTY_NEWLINE);
492 return CMD_WARNING;
493 }
494
495 if (!strcmp(operation, "block"))
496 gprs_ns_tx_block(nsvc, NS_CAUSE_OM_INTERVENTION);
497 else if (!strcmp(operation, "unblock"))
498 gprs_ns_tx_unblock(nsvc);
499 else if (!strcmp(operation, "reset"))
500 gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION);
501 else
502 return CMD_WARNING;
503
504 return CMD_SUCCESS;
505}
506
Harald Welte91f7f4b2010-05-15 23:52:02 +0200507DEFUN(logging_fltr_nsvc,
508 logging_fltr_nsvc_cmd,
509 "logging filter nsvc (nsei|nsvci) <0-65535>",
Harald Welte6703bf72010-05-16 00:00:04 +0200510 LOGGING_STR FILTER_STR
Harald Welte91f7f4b2010-05-15 23:52:02 +0200511 "Filter based on NS Virtual Connection\n"
512 "Identify NS-VC by NSEI\n"
513 "Identify NS-VC by NSVCI\n"
514 "Numeric identifier\n")
515{
516 struct telnet_connection *conn;
517 struct gprs_nsvc *nsvc;
518 uint16_t id = atoi(argv[1]);
519
520 conn = (struct telnet_connection *) vty->priv;
521 if (!conn->dbg) {
522 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
523 return CMD_WARNING;
524 }
525
526 if (!strcmp(argv[0], "nsei"))
527 nsvc = nsvc_by_nsei(vty_nsi, id);
528 else
529 nsvc = nsvc_by_nsvci(vty_nsi, id);
530
531 if (!nsvc) {
532 vty_out(vty, "No NS-VC by that identifier%s", VTY_NEWLINE);
533 return CMD_WARNING;
534 }
535
536 log_set_nsvc_filter(conn->dbg, nsvc);
537 return CMD_SUCCESS;
538}
Harald Welte43f3b692010-05-14 19:36:59 +0200539
Harald Welte144e0292010-05-13 11:45:07 +0200540int gprs_ns_vty_init(struct gprs_ns_inst *nsi)
541{
542 vty_nsi = nsi;
543
544 install_element_ve(&show_ns_cmd);
Harald Welteaf1d4cb2010-05-13 12:32:30 +0200545 install_element_ve(&show_ns_stats_cmd);
Harald Welte92883342010-05-15 23:04:03 +0200546 install_element_ve(&show_nse_cmd);
Harald Welte91f7f4b2010-05-15 23:52:02 +0200547 install_element_ve(&logging_fltr_nsvc_cmd);
Harald Welte144e0292010-05-13 11:45:07 +0200548
549 install_element(CONFIG_NODE, &cfg_ns_cmd);
550 install_node(&ns_node, config_write_ns);
551 install_default(NS_NODE);
Harald Welte804fc812010-05-14 18:59:17 +0200552 install_element(NS_NODE, &ournode_exit_cmd);
Harald Weltea52ff452010-05-14 19:11:04 +0200553 install_element(NS_NODE, &ournode_end_cmd);
Harald Welte144e0292010-05-13 11:45:07 +0200554 install_element(NS_NODE, &cfg_nse_nsvci_cmd);
555 install_element(NS_NODE, &cfg_nse_remoteip_cmd);
556 install_element(NS_NODE, &cfg_nse_remoteport_cmd);
Harald Welteb3ee2652010-05-19 14:38:50 +0200557 install_element(NS_NODE, &cfg_nse_fr_dlci_cmd);
558 install_element(NS_NODE, &cfg_nse_encaps_cmd);
Harald Welte144e0292010-05-13 11:45:07 +0200559 install_element(NS_NODE, &cfg_nse_remoterole_cmd);
560 install_element(NS_NODE, &cfg_no_nse_cmd);
561 install_element(NS_NODE, &cfg_ns_timer_cmd);
Harald Welte7fb05232010-05-19 15:09:09 +0200562 install_element(NS_NODE, &cfg_nsip_local_ip_cmd);
563 install_element(NS_NODE, &cfg_nsip_local_port_cmd);
564 install_element(NS_NODE, &cfg_frgre_enable_cmd);
565 install_element(NS_NODE, &cfg_frgre_local_ip_cmd);
Harald Welte144e0292010-05-13 11:45:07 +0200566
Harald Welte43f3b692010-05-14 19:36:59 +0200567 install_element(ENABLE_NODE, &nsvc_nsei_cmd);
568
Harald Welte144e0292010-05-13 11:45:07 +0200569 return 0;
570}