48 int main(
int argc,
char *argv[])
55 "Error during initialisation of Socket or Netlink "
63 static struct option long_options[] = {
68 {
"bidirectional", no_argument, 0,
'b'},
69 {
"can-fd", no_argument, 0,
'f'},
70 {
"type", required_argument, 0,
't'},
76 c = getopt_long (argc, argv,
"bft:",
77 long_options, &option_index);
86 if (long_options[option_index].flag != 0)
88 printf (
"option %s", long_options[option_index].name);
91 printf (
" with arg %s", optarg);
104 if(!strcmp(optarg,
"none")) {
106 }
else if(!strcmp(optarg,
"eth")) {
108 }
else if (!strcmp(optarg,
"net")) {
110 }
else if (!strcmp(optarg,
"tcp")) {
112 }
else if (!strcmp(optarg,
"udp")) {
115 fprintf(stderr,
"%s: Supported Types: "
116 "none, eth, net, tcp, udp\n", argv[0]);
135 puts (
"verbose flag is set\n");
141 while (optind < argc) {
144 if(!strcmp(argv[optind],
"add") &&
145 !strcmp(argv[optind+1],
"route") && optind+4 <= argc) {
147 err =
ce_gw_add(argv[optind+3], argv[optind+2],
150 fprintf(stderr,
"%s: Error during add: %d",
156 err =
ce_gw_add(argv[optind+2], argv[optind+3],
159 fprintf(stderr,
"%s: Error during "
160 "add: %d", argv[0], err);
168 }
else if (!strcmp(argv[optind],
"add") &&
169 !strcmp(argv[optind+1],
"dev") && optind+2 <= argc) {
171 if (optind+3 <= argc) {
175 fprintf(stderr,
"%s: Error during "
176 "add: %d", argv[0], err);
185 fprintf(stderr,
"%s: Error during "
186 "add: %d", argv[0], err);
194 }
else if(!strcmp(argv[optind],
"del") &&
195 !strcmp(argv[optind+1],
"route") && optind+3 <= argc ) {
197 uintmax_t num = strtoumax(argv[optind+2], NULL, 0);
198 if (num == UINTMAX_MAX && errno == ERANGE) {
199 fprintf(stderr,
"%s: Error: Parameter "
200 "ID is not a number %d\n",
206 fprintf(stderr,
"%s: Error during del: %d\n",
214 }
else if(!strcmp(argv[optind],
"del") &&
215 !strcmp(argv[optind+1],
"dev") && optind+3 <= argc ) {
219 fprintf(stderr,
"%s: Error during del: %d\n",
227 }
else if(!strcmp(argv[optind],
"echo") && optind+2 <= argc) {
231 fprintf(stderr,
"%s: Error during echo: %d",
239 }
else if(!strcmp(argv[optind],
"route") && optind+1 <= argc) {
241 if (optind+2 <= argc) {
242 uintmax_t num = strtoumax(argv[optind+1],
244 if (num == UINTMAX_MAX && errno == ERANGE) {
245 fprintf(stderr,
"%s: Error: Parameter "
246 "ID is not a number %d\n",
259 fprintf(stderr,
"%s: Error during list: %d",
269 while(optind < argc) {
270 printf(
" %s", argv[optind]);