From: Quentin Young Date: Wed, 21 Sep 2016 22:11:53 +0000 (+0000) Subject: Merge branch 'cmaster-next' into vtysh-grammar X-Git-Tag: frr-3.0-branchpoint~129^2~225 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=844ec28cee41395cdd1cc0cdf8cf0168f9dc1adf;p=matthieu%2Ffrr.git Merge branch 'cmaster-next' into vtysh-grammar Signed-off-by: Quentin Young Conflicts: lib/.gitignore lib/command.c lib/command.h --- 844ec28cee41395cdd1cc0cdf8cf0168f9dc1adf diff --cc lib/.gitignore index ca49c1b6a3,a25bae5aae..8174bda7d8 --- a/lib/.gitignore +++ b/lib/.gitignore @@@ -16,6 -16,4 +16,7 @@@ gitversion.h.tm *.loT memtypes.h route_types.h +command_lex.c +command_parse.c +command_parse.h + refix diff --cc lib/Makefile.am index b7bb434776,5a970c881d..3dfd09e2e6 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@@ -17,9 -14,9 +17,9 @@@ libzebra_la_SOURCES = filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ zclient.c sockopt.c smux.c agentx.c snmp.c md5.c if_rmap.c keychain.c privs.c \ sigevent.c pqueue.c jhash.c memtypes.c workqueue.c nexthop.c json.c \ - ptm_lib.c csv.c bfd.c vrf.c systemd.c + ptm_lib.c csv.c bfd.c vrf.c systemd.c ns.c -BUILT_SOURCES = memtypes.h route_types.h gitversion.h +BUILT_SOURCES = memtypes.h route_types.h gitversion.h command_parse.h libzebra_la_DEPENDENCIES = @LIB_REGEX@ diff --cc lib/command.c index f7800aa724,e67007ae2f..b4ef30a300 --- a/lib/command.c +++ b/lib/command.c @@@ -1955,11 -4005,25 +1969,25 @@@ DEFUN (no_config_log_timestamp_precisio int cmd_banner_motd_file (const char *file) { - if (host.motdfile) - XFREE (MTYPE_HOST, host.motdfile); - host.motdfile = XSTRDUP (MTYPE_HOST, file); + int success = CMD_SUCCESS; + char p[PATH_MAX]; + char *rpath; + char *in; - return CMD_SUCCESS; + rpath = realpath (file, p); + if (!rpath) + return CMD_ERR_NO_FILE; + in = strstr (rpath, SYSCONFDIR); + if (in == rpath) + { + if (host.motdfile) - XFREE (MTYPE_HOST, host.motdfile); ++ XFREE (MTYPE_HOST, host.motdfile); + host.motdfile = XSTRDUP (MTYPE_HOST, file); + } + else + success = CMD_WARNING; + + return success; } DEFUN (banner_motd_file, @@@ -1970,7 -4034,15 +1998,15 @@@ "Banner from a file\n" "Filename\n") { - return cmd_banner_motd_file (argv[3]->arg); - int cmd = cmd_banner_motd_file (argv[0]); ++ int cmd = cmd_banner_motd_file (argv[3]->arg); + + if (cmd == CMD_ERR_NO_FILE) - vty_out (vty, "%s does not exist", argv[0]); ++ vty_out (vty, "%s does not exist", argv[3]->arg); + else if (cmd == CMD_WARNING) + vty_out (vty, "%s must be in %s", - argv[0], SYSCONFDIR); ++ argv[0], SYSCONFDIR); + + return cmd; } DEFUN (banner_motd_default, diff --cc lib/command.h index 786539034b,0415834b09..5e1b48c68f --- a/lib/command.h +++ b/lib/command.h @@@ -61,54 -60,56 +61,56 @@@ struct hos }; /* There are some command levels which called from command node. */ -enum node_type +enum node_type { - AUTH_NODE, /* Authentication mode of vty interface. */ - RESTRICTED_NODE, /* Restricted view mode */ - VIEW_NODE, /* View node. Default mode of vty interface. */ - AUTH_ENABLE_NODE, /* Authentication mode for change enable. */ - ENABLE_NODE, /* Enable node. */ - CONFIG_NODE, /* Config node. Default mode of config file. */ - SERVICE_NODE, /* Service node. */ - DEBUG_NODE, /* Debug node. */ + AUTH_NODE, /* Authentication mode of vty interface. */ + RESTRICTED_NODE, /* Restricted view mode */ + VIEW_NODE, /* View node. Default mode of vty interface. */ + AUTH_ENABLE_NODE, /* Authentication mode for change enable. */ + ENABLE_NODE, /* Enable node. */ + CONFIG_NODE, /* Config node. Default mode of config file. */ + SERVICE_NODE, /* Service node. */ + DEBUG_NODE, /* Debug node. */ VRF_DEBUG_NODE, /* Vrf Debug node. */ - AAA_NODE, /* AAA node. */ - KEYCHAIN_NODE, /* Key-chain node. */ - KEYCHAIN_KEY_NODE, /* Key-chain key node. */ - NS_NODE, /* Logical-Router node. */ - VRF_NODE, /* VRF mode node. */ - INTERFACE_NODE, /* Interface mode node. */ - ZEBRA_NODE, /* zebra connection node. */ - TABLE_NODE, /* rtm_table selection node. */ - RIP_NODE, /* RIP protocol mode node. */ - RIPNG_NODE, /* RIPng protocol mode node. */ - BGP_NODE, /* BGP protocol mode which includes BGP4+ */ - BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */ - BGP_VPNV6_NODE, /* BGP MPLS-VPN PE exchange. */ - BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */ - BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */ - BGP_IPV6_NODE, /* BGP IPv6 address family */ - BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */ - BGP_ENCAP_NODE, /* BGP ENCAP SAFI */ - BGP_ENCAPV6_NODE, /* BGP ENCAP SAFI */ - OSPF_NODE, /* OSPF protocol mode */ - OSPF6_NODE, /* OSPF protocol for IPv6 mode */ - ISIS_NODE, /* ISIS protocol mode */ - PIM_NODE, /* PIM protocol mode */ - MASC_NODE, /* MASC for multicast. */ - IRDP_NODE, /* ICMP Router Discovery Protocol mode. */ - IP_NODE, /* Static ip route node. */ - ACCESS_NODE, /* Access list node. */ - PREFIX_NODE, /* Prefix list node. */ - ACCESS_IPV6_NODE, /* Access list node. */ - PREFIX_IPV6_NODE, /* Prefix list node. */ - AS_LIST_NODE, /* AS list node. */ - COMMUNITY_LIST_NODE, /* Community list node. */ - RMAP_NODE, /* Route map node. */ - SMUX_NODE, /* SNMP configuration node. */ - DUMP_NODE, /* Packet dump node. */ - FORWARDING_NODE, /* IP forwarding node. */ + AAA_NODE, /* AAA node. */ + KEYCHAIN_NODE, /* Key-chain node. */ + KEYCHAIN_KEY_NODE, /* Key-chain key node. */ ++ NS_NODE, /* Logical-Router node. */ + VRF_NODE, /* VRF mode node. */ + INTERFACE_NODE, /* Interface mode node. */ + ZEBRA_NODE, /* zebra connection node. */ + TABLE_NODE, /* rtm_table selection node. */ + RIP_NODE, /* RIP protocol mode node. */ + RIPNG_NODE, /* RIPng protocol mode node. */ + BGP_NODE, /* BGP protocol mode which includes BGP4+ */ + BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */ + BGP_VPNV6_NODE, /* BGP MPLS-VPN PE exchange. */ + BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */ + BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */ + BGP_IPV6_NODE, /* BGP IPv6 address family */ + BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */ + BGP_ENCAP_NODE, /* BGP ENCAP SAFI */ + BGP_ENCAPV6_NODE, /* BGP ENCAP SAFI */ + OSPF_NODE, /* OSPF protocol mode */ + OSPF6_NODE, /* OSPF protocol for IPv6 mode */ + ISIS_NODE, /* ISIS protocol mode */ + PIM_NODE, /* PIM protocol mode */ + MASC_NODE, /* MASC for multicast. */ + IRDP_NODE, /* ICMP Router Discovery Protocol mode. */ + IP_NODE, /* Static ip route node. */ + ACCESS_NODE, /* Access list node. */ + PREFIX_NODE, /* Prefix list node. */ + ACCESS_IPV6_NODE, /* Access list node. */ + PREFIX_IPV6_NODE, /* Prefix list node. */ + AS_LIST_NODE, /* AS list node. */ + COMMUNITY_LIST_NODE, /* Community list node. */ + RMAP_NODE, /* Route map node. */ + SMUX_NODE, /* SNMP configuration node. */ + DUMP_NODE, /* Packet dump node. */ + FORWARDING_NODE, /* IP forwarding node. */ PROTOCOL_NODE, /* protocol filtering node */ - VTY_NODE, /* Vty node. */ - LINK_PARAMS_NODE, /* Link-parameters node */ + VTY_NODE, /* Vty node. */ ++ LINK_PARAMS_NODE, /* Link-parameters node */ }; /* Node which has some commands and prompt string and configuration @@@ -351,11 -513,15 +353,15 @@@ struct cmd_elemen #define ROUTE_STR "Routing Table\n" #define PREFIX_LIST_STR "Build a prefix list\n" #define OSPF6_DUMP_TYPE_LIST \ -"(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)" +"" #define ISIS_STR "IS-IS information\n" #define AREA_TAG_STR "[area tag]\n" -#define COMMUNITY_AANN_STR "Community number where AA and NN are <0-65535>\n" -#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are <0-65535>) or local-AS|no-advertise|no-export|internet or additive\n" +#define COMMUNITY_AANN_STR "Community number where AA and NN are (0-65535)\n" +#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are (0-65535)) or local-AS|no-advertise|no-export|internet or additive\n" + #define MPLS_TE_STR "MPLS-TE specific commands\n" + #define LINK_PARAMS_STR "Configure interface link parameters\n" + #define OSPF_RI_STR "OSPF Router Information specific commands\n" + #define PCE_STR "PCE Router Information specific commands\n" #define CONF_BACKUP_EXT ".sav" diff --cc vtysh/vtysh.c index 9d4061cfcf,d01a1bcebb..18ca0dca29 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@@ -40,10 -41,9 +41,11 @@@ #include "vtysh/vtysh.h" #include "log.h" #include "bgpd/bgp_vty.h" + #include "ns.h" #include "vrf.h" +#include "lib/grammar_sandbox.h" + /* Struct VTY. */ struct vty *vty;