FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etm/ffs2.c @ 258:ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 04 Feb 2014 07:43:12 +0000 |
parents | |
children | 35113b1964d3 |
rev | line source |
---|---|
258
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * In this module we are going to implement TMFFS2 functionality. |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <string.h> |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <strings.h> |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "../include/pktmux.h" |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "../include/limits.h" |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "localtypes.h" |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "etm.h" |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "tmffs2.h" |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 void |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 cmd_ffs2_version() |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 u_char cmdpkt[4]; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 cmdpkt[1] = ETM_FFS2; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 cmdpkt[2] = TMFFS_VERSION; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 send_etm_cmd(cmdpkt, 2); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 } |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 static struct cmdtab { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 char *cmd; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 int minargs; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 int maxargs; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 void (*func)(); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } ffs2_cmds[] = { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 {"version", 0, 0, cmd_ffs2_version}, |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 {0, 0, 0, 0} |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 }; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 void |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 cmd_ffs2(argc, argv) |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 char **argv; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 struct cmdtab *tp; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 int extargs; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 for (tp = ffs2_cmds; tp->cmd; tp++) |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 if (!strcmp(tp->cmd, argv[1])) |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 break; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 if (!tp->func) { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 printf("error: no such ffs2 command\n"); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 return; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 extargs = argc - 2; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 if (extargs > tp->maxargs) { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 printf("error: too many arguments\n"); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 return; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 } |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (extargs < tp->minargs) { |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 printf("error: too few arguments\n"); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 return; |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 tp->func(argc - 1, argv + 1); |
ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |