-.TH NGCLI "1" "October 2013" "NgAdmin 0.1" "User Commands"
+.TH NGCLI "1" "September 2014" "NgAdmin 0.1" "User Commands"
.SH NAME
ngcli \- command line interface tool for GS10[58]E administration
.
attempt is successful or not.
.
.TP
+\fBloop disable
+Disable loop detection.
+.
+.TP
+\fBloop enable
+Enable loop detection.
+.
+.TP
+\fBloop show
+Show loop detection configuration.
+.
+.TP
\fBmirror disable
Disable port mirroring.
.
noinst_HEADERS = commands.h common.h
ngcli_SOURCES = admin.c com_bitrate.c com_cabletest.c com_defaults.c com_firmware.c \
- com_help.c com_igmp.c com_list.c com_login.c commands.c com_mirror.c \
- common.c com_name.c com_netconf.c com_password.c com_ports.c com_qos.c \
- com_quit.c com_restart.c com_scan.c com_stormfilter.c com_tree.c com_vlan.c
+ com_help.c com_igmp.c com_list.c com_login.c com_loop.c commands.c \
+ com_mirror.c common.c com_name.c com_netconf.c com_password.c \
+ com_ports.c com_qos.c com_quit.c com_restart.c com_scan.c \
+ com_stormfilter.c com_tree.c com_vlan.c
ngcli_CPPFLAGS = -I$(top_srcdir)/raw/include/ -I$(top_srcdir)/lib/include/
ngcli_LDADD = $(top_builddir)/raw/src/librawnsdp.la $(top_builddir)/lib/src/libngadmin.la $(READLINE_LIBS)
--- /dev/null
+
+#include "commands.h"
+
+
+int do_loop_enable (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+ int i;
+
+
+ if (argc > 0) {
+ printf("this command takes no argument\n");
+ return 1;
+ }
+
+ i = ngadmin_setLoopDetectionState(nga, 1);
+ printErrCode(i);
+
+
+ return 0;
+}
+
+
+int do_loop_disable (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+ int i;
+
+
+ if (argc > 0) {
+ printf("this command takes no argument\n");
+ return 1;
+ }
+
+ i = ngadmin_setLoopDetectionState(nga, 0);
+ printErrCode(i);
+
+
+ return 0;
+}
+
+
+int do_loop_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+ int i, s;
+ const struct swi_attr *sa;
+
+
+ if (argc > 0) {
+ printf("this command takes no argument\n");
+ return 1;
+ }
+
+ sa = ngadmin_getCurrentSwitch(nga);
+ if (sa == NULL) {
+ printf("must be logged\n");
+ return 1;
+ }
+
+ i = ngadmin_getLoopDetectionState(nga, &s);
+ if (i != ERR_OK) {
+ printErrCode(i);
+ return 1;
+ }
+
+ printf("loop detection is %s\n", s ? "enabled" : "disabled");
+
+ return 0;
+}
+
+
int do_login (int argc, const char **argv, struct ngadmin *nga);
+/* loop */
+int do_loop_enable (int argc, const char **argv, struct ngadmin *nga);
+int do_loop_disable (int argc, const char **argv, struct ngadmin *nga);
+int do_loop_show (int argc, const char **argv, struct ngadmin *nga);
+
+
/* mirror */
int do_mirror_disable (int argc, const char **argv, struct ngadmin *nga);
int do_mirror_set (int argc, const char **argv, struct ngadmin *nga);
COM_TERM(login, do_login)
+ COM_START(loop)
+ COM_TERM(disable, do_loop_disable)
+ COM_TERM(enable, do_loop_enable)
+ COM_TERM(show, do_loop_show)
+ COM_END
+
COM_START(mirror)
COM_TERM(disable, do_mirror_disable)
COM_TERM(set, do_mirror_set)
int ngadmin_setPVID (struct ngadmin *nga, unsigned char port, unsigned short vlan);
+/**
+ * Get the loop detection state.
+ * Retrieves the loop detection state.
+ * @note You must be logged on a switch.
+ * @param nga A pointer to the ngadmin structure.
+ * @param s A pointer to an integer which will receive 0 or 1.
+ * @return ERR_OK when everything is well or an error code otherwise.
+ **/
+int ngadmin_getLoopDetectionState (struct ngadmin *nga, int *s);
+
+
+/**
+ * Set the loop detection state.
+ * Changes the loop detection state.
+ * @note You must be logged on a switch.
+ * @param nga A pointer to the ngadmin structure.
+ * @param s An integer with value 0 or 1.
+ * @return ERR_OK when everything is well or an error code otherwise.
+ **/
+int ngadmin_setLoopDetectionState (struct ngadmin *nga, int s);
+
+
#ifdef __cplusplus
}
#endif
}
+int ngadmin_getLoopDetectionState (struct ngadmin *nga, int *s)
+{
+ List *attr;
+ ListNode *ln;
+ struct attr *at;
+ int ret = ERR_OK;
+
+
+ if (nga == NULL || s == NULL)
+ return ERR_INVARG;
+ else if (nga->current == NULL)
+ return ERR_NOTLOG;
+
+ attr = createEmptyList();
+ pushBackList(attr, newEmptyAttr(ATTR_LOOP_DETECT));
+ ret = readRequest(nga, attr);
+ if (ret != ERR_OK)
+ goto end;
+
+ filterAttributes(attr, ATTR_LOOP_DETECT, ATTR_END);
+
+ *s = 0;
+
+ if (attr->first == NULL) {
+ ret = ERR_BADREPLY;
+ goto end;
+ }
+ at = attr->first->data;
+ if (at->size != 1) {
+ ret = ERR_BADREPLY;
+ goto end;
+ }
+ *s = *(char *)at->data;
+
+
+end:
+ destroyList(attr, (void(*)(void*))freeAttr);
+
+
+ return ret;
+}
+
+
+int ngadmin_setLoopDetectionState (struct ngadmin *nga, int s)
+{
+ List *attr;
+
+
+ attr = createEmptyList();
+ pushBackList(attr, newByteAttr(ATTR_LOOP_DETECT, s != 0));
+
+
+ return writeRequest(nga, attr);
+}
+
+
#define ATTR_IGMP_BLOCK_UNK 0x6C00
#define ATTR_IGMP_VALID_V3 0x7000
#define ATTR_TLV_BITMAP 0x7400
+#define ATTR_LOOP_DETECT 0x9000
#define ATTR_END 0xFFFF
case ATTR_STORM_ENABLE:
case ATTR_IGMP_BLOCK_UNK:
case ATTR_IGMP_VALID_V3:
+ case ATTR_LOOP_DETECT:
if (at->size != 1)
return -EMSGSIZE;
printf("\tvalidate IGMPv3 = %s\n", *byte ? "yes" : "no");
break;
+ case ATTR_LOOP_DETECT:
+ printf("\tloop detection = %s\n", *byte ? "yes" : "no");
+ break;
+
default:
printf("\tunknown\n");
}
[0x6C00] = {name = "Block Unknown IGMP Addresses", dissect = "uint"},
[0x7000] = {name = "Validate IGMPv3 Headers", dissect = "uint"},
[0x7400] = {name = "TLV Bitmap", dissect = nill},
+ [0x9000] = {name = "Loop Detection", dissect = "uint"},
[0xFFFF] = {name = "End", dissect = nill}
}