2 * IGSL Command Line Utility: This utility can be used to add/remove
3 * snooping capability on desired bridge interface.
5 * Copyright (C) 2010, Broadcom Corporation
8 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
9 * the contents of this file may not be disclosed to third parties, copied
10 * or duplicated in any form, in whole or in part, without the prior
11 * written permission of Broadcom Corporation.
13 * $Id: igsu.c 241182 2011-02-17 21:50:03Z gmo $
16 #include <sys/types.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
26 #include "igsu_linux.h"
27 #else /* defined(vxworks) */
28 #error "Unsupported osl"
33 #define MAX_DATA_SIZE sizeof(igs_cfg_request_t)
35 static int igs_cfg_bridge_add(char *argv
[]);
36 static int igs_cfg_bridge_del(char *argv
[]);
37 static int igs_cfg_bridge_list(char *argv
[]);
38 static int igs_cfg_sdb_list(char *argv
[]);
39 static int igs_cfg_rtport_list(char *argv
[]);
40 static int igs_cfg_stats_show(char *argv
[]);
42 static igs_cmd_arg_t cmd_args
[] =
85 fprintf(fid
, IGS_USAGE
);
90 igs_cfg_bridge_add(char *argv
[])
92 igs_cfg_request_t req
;
94 bzero((char *)&req
, sizeof(igs_cfg_request_t
));
96 strcpy((char *)req
.inst_id
, argv
[3]);
97 req
.command_id
= IGSCFG_CMD_BR_ADD
;
98 req
.oper_type
= IGSCFG_OPER_TYPE_SET
;
100 /* Send request to kernel */
101 if (igs_cfg_request_send(&req
, sizeof(igs_cfg_request_t
)) < 0)
103 fprintf(stderr
, "Unable to send request to IGS\n");
107 if (req
.status
!= IGSCFG_STATUS_SUCCESS
)
109 fprintf(stderr
, "%s\n", req
.arg
);
117 igs_cfg_bridge_del(char *argv
[])
119 igs_cfg_request_t req
;
121 bzero((char *)&req
, sizeof(igs_cfg_request_t
));
123 strcpy((char *)req
.inst_id
, argv
[3]);
124 req
.command_id
= IGSCFG_CMD_BR_DEL
;
125 req
.oper_type
= IGSCFG_OPER_TYPE_SET
;
127 /* Send request to kernel */
128 if (igs_cfg_request_send(&req
, sizeof(igs_cfg_request_t
)) < 0)
130 fprintf(stderr
, "Unable to send request to IGS\n");
134 if (req
.status
!= IGSCFG_STATUS_SUCCESS
)
136 fprintf(stderr
, "%s\n", req
.arg
);
144 igs_cfg_bridge_list(char *argv
[])
146 fprintf(stdout
, "TBD\n");
151 igs_cfg_sdb_list(char *argv
[])
153 igs_cfg_request_t req
;
154 igs_cfg_sdb_list_t
*list
;
155 bool first_row
= TRUE
;
158 strcpy((char *)req
.inst_id
, argv
[3]);
159 req
.command_id
= IGSCFG_CMD_IGSDB_LIST
;
160 req
.oper_type
= IGSCFG_OPER_TYPE_GET
;
161 req
.size
= sizeof(req
.arg
);
162 list
= (igs_cfg_sdb_list_t
*)req
.arg
;
164 if (igs_cfg_request_send(&req
, sizeof(igs_cfg_request_t
)) < 0)
166 fprintf(stderr
, "Unable to send request to IGS\n");
170 if (req
.status
!= IGSCFG_STATUS_SUCCESS
)
172 fprintf(stderr
, "Unable to get the IGSDB list\n");
173 fprintf(stderr
, "%s\n", req
.arg
);
177 fprintf(stdout
, "Group Members Interface\n");
179 for (i
= 0; i
< list
->num_entries
; i
++)
182 fprintf(stdout
, "%08x ", list
->sdb_entry
[i
].mgrp_ip
);
185 fprintf(stdout
, "%08x ", list
->sdb_entry
[i
].mh_ip
);
186 fprintf(stdout
, "%s\n", list
->sdb_entry
[i
].if_name
);
190 fprintf(stdout
, " ");
191 fprintf(stdout
, "%08x ", list
->sdb_entry
[i
].mh_ip
);
192 fprintf(stdout
, "%s\n", list
->sdb_entry
[i
].if_name
);
199 igs_cfg_rtport_list(char *argv
[])
201 igs_cfg_request_t req
;
202 igs_cfg_rtport_list_t
*list
;
205 bzero((char *)&req
, sizeof(igs_cfg_request_t
));
207 strcpy((char *)req
.inst_id
, argv
[3]);
208 req
.command_id
= IGSCFG_CMD_RTPORT_LIST
;
209 req
.oper_type
= IGSCFG_OPER_TYPE_GET
;
210 req
.size
= sizeof(req
.arg
);
212 /* Send request to kernel */
213 if (igs_cfg_request_send(&req
, sizeof(igs_cfg_request_t
)) < 0)
215 fprintf(stderr
, "Unable to send request to IGS\n");
219 if (req
.status
!= IGSCFG_STATUS_SUCCESS
)
221 fprintf(stderr
, "%s\n", req
.arg
);
225 fprintf(stdout
, "Router Interface\n");
227 list
= (igs_cfg_rtport_list_t
*)req
.arg
;
228 for (i
= 0; i
< list
->num_entries
; i
++)
230 fprintf(stdout
, "%08x ", list
->rtport_entry
[i
].mr_ip
);
231 fprintf(stdout
, "%-15s", list
->rtport_entry
[i
].if_name
);
234 fprintf(stdout
, "\n");
240 igs_cfg_stats_show(char *argv
[])
242 igs_cfg_request_t req
;
245 strcpy((char *)req
.inst_id
, argv
[3]);
246 req
.command_id
= IGSCFG_CMD_IGS_STATS
;
247 req
.oper_type
= IGSCFG_OPER_TYPE_GET
;
248 req
.size
= sizeof(igs_stats_t
);
249 igss
= (igs_stats_t
*)req
.arg
;
251 if (igs_cfg_request_send(&req
, sizeof(igs_cfg_request_t
)) < 0)
253 fprintf(stderr
, "Unable to send request to IGS\n");
257 if (req
.status
!= IGSCFG_STATUS_SUCCESS
)
259 fprintf(stderr
, "Unable to get the IGS stats\n");
263 fprintf(stdout
, "IgmpPkts IgmpQueries "
264 "IgmpReports IgmpV2Reports IgmpLeaves\n");
265 fprintf(stdout
, "%-15d %-15d %-15d %-15d %d\n",
266 igss
->igmp_packets
, igss
->igmp_queries
,
267 igss
->igmp_reports
, igss
->igmp_v2reports
,
269 fprintf(stdout
, "IgmpNotHandled McastGroups "
270 "McastMembers MemTimeouts\n");
271 fprintf(stdout
, "%-15d %-15d %-15d %d\n",
272 igss
->igmp_not_handled
, igss
->igmp_mcast_groups
,
273 igss
->igmp_mcast_members
, igss
->igmp_mem_timeouts
);
280 main(int argc
, char *argv
[])
281 #else /* defined(vxworks) */
282 #error "Unsupported osl"
286 bool cmd_syntax
= FALSE
;
294 /* Find the command type */
295 for (j
= 0; j
< sizeof(cmd_args
)/sizeof(cmd_args
[0]); j
++)
297 if ((strcmp(argv
[1], cmd_args
[j
].cmd_oper_str
) == 0) &&
298 (argc
- 1 == cmd_args
[j
].arg_count
) &&
299 ((cmd_args
[j
].cmd_id_str
== NULL
) ||
300 ((argv
[2] != NULL
) &&
301 (strcmp(argv
[2], cmd_args
[j
].cmd_id_str
) == 0))))
314 /* Call the command processing function. This function parses
315 * prepare command request and sends it kernel.
317 if ((ret
= cmd_args
[j
].input(argv
)) < 0)
319 fprintf(stderr
, "Command failed\n");