summaryrefslogtreecommitdiff
path: root/staging/cli_interface.c
blob: 65cb46d59c3d20230a80f18797418320eb3c1050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 * Mausezahn - A fast versatile traffic generator
 * Copyright (C) 2008-2010 Herbert Haas
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 2 as published by the 
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with 
 * this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
 * 
*/


#include "mz.h"
#include "cli.h"
#include "mops.h"




// Enter interface config mode:
//   
int enter_interface (struct cli_def *cli, const char *command, char *argv[], int argc)
{
   int i, j=0;
   char prompt[10];
   
   if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) )
     {
	cli_print(cli, "Specify an interface to configure\n");
	return CLI_OK;
     }

   if (argc)
     {
	for (i=0; i<device_list_entries; i++)
	  {
	     if (strncmp(device_list[i].dev, argv[0], 16)==0)
	       {
		  j=1;
		  sprintf(prompt, "if-%s", device_list[i].dev);
		  clidev = i;
		  break;
	       }
	  }
	
	if (j)
	  {
	     cli_set_configmode(cli, MZ_MODE_INTERFACE, prompt);
	  }
	else
	  {
	     cli_print(cli, "Unknown device!\n");
	  }
     }
   else
     {
	cli_print(cli, "Specify an interface to configure\n");
     }
   
   return CLI_OK;
}



int conf_ip_address (struct cli_def *cli, const char *command, char *argv[], int argc)
{
   if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) )
     {
	cli_print(cli, "A.B.C.D      Specify a default interface IP address\n");
	return CLI_OK;
     }
   
   if (argc)
     {
	if (mops_pdesc_ip (device_list[clidev].ip_mops, argv[0]))
	  { 
	     cli_print(cli,"Invalid IP address (use format: A.B.C.D)\n");
	  }
     }
   else
     cli_print(cli, "A.B.C.D      Specify a default interface IP address\n");
   
   return CLI_OK;
}



int conf_mac_address (struct cli_def *cli, const char *command, char *argv[], int argc)
{
   if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) )
     {
	cli_print(cli, "XX:XX:XX:XX:XX:XX      Configure a default interface MAC address\n");
	return CLI_OK;
     }
   
   if (argc)
     {
	if (mops_pdesc_mac (device_list[clidev].mac_mops, argv[0]))
	  { 
	     cli_print(cli,"Invalid MAC address (use format: XX:XX:XX:XX:XX:XX)\n");
	  }
     }
   else
     cli_print(cli, "A.B.C.D      Specify a default interface IP address\n");
   
   return CLI_OK;
}



int conf_tag_dot1q (struct cli_def *cli, const char *command, char *argv[], int argc)
{
   if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) )
     {
	cli_print(cli, "Specify one or more 802.1Q (and optionally 802.1P) tags\n");
	return CLI_OK;
     }
   cli_print(cli, "Not supported in this version\n");
   return CLI_OK;
}

int conf_tag_mpls (struct cli_def *cli, const char *command, char *argv[], int argc)
{
   if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) )
     {
	cli_print(cli, "Specify one or more MPLS labels (and parameters)\n");
	return CLI_OK;
     }
   cli_print(cli, "Not supported in this version\n");
   return CLI_OK;
}