cli_entry
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cli_entry [2009/06/13 20:04] – andrei | cli_entry [2009/06/13 20:31] (current) – andrei | ||
|---|---|---|---|
| Line 122: | Line 122: | ||
| The position of the entry in the code reflects its position in the actual menu. That is, if the first entry in the subtree of config_main is the struct menu_node rstp then it will also be the first entry in the CLI menu. Notice than when one of the entries is selected then the cmd_rstp_run routine is called. | The position of the entry in the code reflects its position in the actual menu. That is, if the first entry in the subtree of config_main is the struct menu_node rstp then it will also be the first entry in the CLI menu. Notice than when one of the entries is selected then the cmd_rstp_run routine is called. | ||
| - | == Step 3: implementing the called | + | == Step 3: implementing the global RSTP enable |
| The //run// field from struct menu_node represents a pointer to a function having the following signature : int (struct cli_context *, int, char **, struct menu_node **). For a detailed description see the struct menu_node definition in **cli/ | The //run// field from struct menu_node represents a pointer to a function having the following signature : int (struct cli_context *, int, char **, struct menu_node **). For a detailed description see the struct menu_node definition in **cli/ | ||
| Line 215: | Line 215: | ||
| Notice that the routine called when the entries are selected is cmd_rstp_if_set. So... | Notice that the routine called when the entries are selected is cmd_rstp_if_set. So... | ||
| - | == Step 5 : implementing | + | == Step 5 : implementing |
| - | The //run// field from struct menu_node represents | + | The cmd_rstp_if_set routine' |
| - | + | ||
| - | The routine's implementation will reside in **cli/ | + | |
| - | <code c> | + | |
| - | int cmd_rstp_if_set(struct cli_context *ctx, int argc, char **argv, struct menu_node **nodev) | + | |
| - | { | + | |
| - | struct rstp_session *rstp; | + | |
| - | struct rstp_configuration cfg; | + | |
| - | struct swcli_context *uc = SWCLI_CTX(ctx); | + | |
| - | int enable = 1; | + | |
| - | int err; | + | |
| - | + | ||
| - | shared_get_rstp(& | + | |
| - | if (!cfg.enabled) | + | |
| - | return 0; | + | |
| - | + | ||
| - | if (!strcmp(nodev[0]-> | + | |
| - | enable = 0; | + | |
| - | + | ||
| - | if (!RSTP_SESSION_OPEN(ctx, | + | |
| - | EX_STATUS_REASON(ctx, | + | |
| - | return CLI_EX_REJECTED; | + | |
| - | } | + | |
| - | err = rstp_set_interface(rstp, | + | |
| - | RSTP_SESSION_CLOSE(ctx, | + | |
| - | + | ||
| - | return err; | + | |
| - | } | + | |
| - | </ | + | |
cli_entry.1244912678.txt.gz · Last modified: by andrei
