nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +17 -2
- data/LICENSE +21 -0
- data/README.md +115 -44
- data/Rakefile +2 -6
- data/bytecode/{Commands.md → _docs/commands.md} +0 -0
- data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
- data/bytecode/_docs/grammar.pdf +0 -0
- data/bytecode/{src → _original}/README.md +0 -0
- data/bytecode/{src → _original}/lib/arp.mtl +0 -0
- data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
- data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
- data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/dns.mtl +0 -0
- data/bytecode/{src → _original}/lib/http.mtl +0 -0
- data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/udp.mtl +0 -0
- data/bytecode/{src → _original}/lib/util.mtl +0 -0
- data/bytecode/{src → _original}/lib/var.mtl +0 -0
- data/bytecode/{src → _original}/lib/wav.mtl +0 -0
- data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
- data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
- data/bytecode/main.mtl +11 -11
- data/bytecode/test/test.mtl +8 -8
- data/examples/basic/Gemfile +1 -3
- data/examples/basic/config.ru +14 -4
- data/examples/record/Gemfile +0 -5
- data/examples/record/{config.ru.example → config.ru} +2 -2
- data/examples/record/server.rb +0 -2
- data/ext/Makefile +10 -0
- data/ext/bin/mtl_comp +29 -0
- data/{bytecode → ext}/bin/mtl_merge +0 -0
- data/ext/bin/mtl_simu +29 -0
- data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
- data/ext/mtl_linux/.gitignore +7 -0
- data/ext/mtl_linux/LICENSE +21 -0
- data/ext/mtl_linux/Makefile +116 -0
- data/ext/mtl_linux/MetalC.project +196 -0
- data/ext/mtl_linux/conf.bin +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
- data/ext/mtl_linux/inc/log.h +21 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
- data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
- data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
- data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
- data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
- data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
- data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
- data/ext/mtl_linux/nominal.mtl +3959 -0
- data/ext/mtl_linux/src/comp/main.cpp +123 -0
- data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
- data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
- data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
- data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
- data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
- data/ext/mtl_linux/src/simu/log.c +340 -0
- data/ext/mtl_linux/src/simu/properties.c +368 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
- data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
- data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
- data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
- data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
- data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
- data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
- data/ext/mtl_linux/src/simu/win/simu.c +819 -0
- data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
- data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
- data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
- data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
- data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
- data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
- data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
- data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
- data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
- data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
- data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
- data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
- data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
- data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
- data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
- data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
- data/ext/mtl_linux/src/vm/vaudio.c +830 -0
- data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
- data/ext/mtl_linux/src/vm/vloader.c +139 -0
- data/ext/mtl_linux/src/vm/vlog.c +782 -0
- data/ext/mtl_linux/src/vm/vmem.c +461 -0
- data/ext/mtl_linux/src/vm/vnet.c +298 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
- data/lib/nabaztag_hack_kit/server.rb +4 -7
- data/lib/nabaztag_hack_kit/version.rb +1 -1
- data/lib/nabaztag_hack_kit.rb +2 -2
- data/nabaztag_hack_kit.gemspec +10 -11
- data/spec/integration/server_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/message_spec.rb +12 -18
- data/spec/unit/server_spec.rb +13 -10
- metadata +145 -137
- data/bytecode/bin/mtl_comp +0 -50
- data/bytecode/bin/mtl_simu +0 -49
- data/bytecode/src/mtl/Makefile +0 -42
- data/bytecode/src/mtl/README.md +0 -13
- data/bytecode/src/mtl/bc.cpp +0 -1891
- data/bytecode/src/mtl/dumpbc.c +0 -2566
- data/bytecode/src/mtl/linux_simu.c +0 -271
- data/bytecode/src/mtl/linux_simuaudio.c +0 -16
- data/bytecode/src/mtl/linux_simunet.c +0 -620
- data/bytecode/src/mtl/log.c +0 -297
- data/bytecode/src/mtl/log.h +0 -20
- data/bytecode/src/mtl/main_compiler.cpp +0 -104
- data/bytecode/src/mtl/main_simu.cpp +0 -221
- data/bytecode/src/mtl/mp3/common.c +0 -265
- data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
- data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
- data/bytecode/src/mtl/mp3/huffman.h +0 -332
- data/bytecode/src/mtl/mp3/interface.c +0 -258
- data/bytecode/src/mtl/mp3/mpglib.h +0 -44
- data/bytecode/src/mtl/properties.c +0 -293
- data/bytecode/src/mtl/simu.c +0 -750
- data/bytecode/src/mtl/simuaudio.c +0 -662
- data/bytecode/src/mtl/simunet.c +0 -400
- data/bytecode/src/mtl/vaudio.c +0 -677
- data/bytecode/src/mtl/vbc_str.h +0 -166
- data/bytecode/src/mtl/vcomp/Makefile +0 -29
- data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
- data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
- data/bytecode/src/mtl/vcomp/compiler.h +0 -200
- data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
- data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
- data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
- data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
- data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
- data/bytecode/src/mtl/vcomp/file.cpp +0 -79
- data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
- data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
- data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
- data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
- data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
- data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
- data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
- data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
- data/bytecode/src/mtl/vinterp.c +0 -1349
- data/bytecode/src/mtl/vloader.c +0 -127
- data/bytecode/src/mtl/vlog.c +0 -589
- data/bytecode/src/mtl/vmem.c +0 -424
- data/bytecode/src/mtl/vnet.c +0 -255
- data/examples/basic/Procfile +0 -2
- data/examples/basic/server.rb +0 -14
@@ -0,0 +1,298 @@
|
|
1
|
+
// VLISP Virtual Machine - 2006 - by Sylvain Huet
|
2
|
+
// Lowcost IS Powerfull
|
3
|
+
#include"vmem.h"
|
4
|
+
#include"properties.h"
|
5
|
+
|
6
|
+
#ifdef VSIMU
|
7
|
+
#include <string.h>
|
8
|
+
#include<stdio.h>
|
9
|
+
#include<time.h>
|
10
|
+
#include "log.h"
|
11
|
+
int netstatesimu=1;
|
12
|
+
#endif
|
13
|
+
#ifdef VREAL
|
14
|
+
#include "rt2501usb.h"
|
15
|
+
#endif
|
16
|
+
#include"vloader.h"
|
17
|
+
#include"vnet.h"
|
18
|
+
#include"vlog.h"
|
19
|
+
#include"vinterp.h"
|
20
|
+
int netState()
|
21
|
+
{
|
22
|
+
#ifdef VSIMU
|
23
|
+
return netstatesimu;
|
24
|
+
#endif
|
25
|
+
#ifdef VREAL
|
26
|
+
return rt2501_state();
|
27
|
+
#endif
|
28
|
+
}
|
29
|
+
|
30
|
+
int netSend(char* src,int indexsrc,int lentosend,int lensrc,char* macdst,int inddst,int lendst,int speed)
|
31
|
+
{
|
32
|
+
#ifdef VSIMU
|
33
|
+
my_printf(LOG_SIMUNET, "xxxx netSend\n");
|
34
|
+
return -1;
|
35
|
+
#endif
|
36
|
+
#ifdef VREAL
|
37
|
+
if (indexsrc<0)
|
38
|
+
{
|
39
|
+
return -1;
|
40
|
+
}
|
41
|
+
if (indexsrc+lentosend>lensrc)
|
42
|
+
{
|
43
|
+
lentosend=lensrc-indexsrc;
|
44
|
+
}
|
45
|
+
if (lentosend<=0)
|
46
|
+
{
|
47
|
+
return -1;
|
48
|
+
}
|
49
|
+
if (inddst<0)
|
50
|
+
{
|
51
|
+
return -1;
|
52
|
+
}
|
53
|
+
if (inddst+6>lendst)
|
54
|
+
{
|
55
|
+
return -1;
|
56
|
+
}
|
57
|
+
return rt2501_send((const unsigned char *)(src+indexsrc),lentosend,(const unsigned char *)(macdst+inddst),speed,1);
|
58
|
+
#endif
|
59
|
+
}
|
60
|
+
|
61
|
+
int netCb(char* src,int lensrc,char* macsrc)
|
62
|
+
{
|
63
|
+
VPUSH(PNTTOVAL(VMALLOCSTR(src,lensrc)));
|
64
|
+
VPUSH(PNTTOVAL(VMALLOCSTR(macsrc,6)));
|
65
|
+
VPUSH(VCALLSTACKGET(sys_start,SYS_CBTCP));
|
66
|
+
if (VSTACKGET(0)!=NIL)
|
67
|
+
{
|
68
|
+
interpGo();
|
69
|
+
}
|
70
|
+
else
|
71
|
+
{
|
72
|
+
VPULL();
|
73
|
+
VPULL();
|
74
|
+
}
|
75
|
+
VPULL();
|
76
|
+
return 0;
|
77
|
+
}
|
78
|
+
|
79
|
+
extern unsigned char rt2501_mac[6];
|
80
|
+
|
81
|
+
#ifdef VSIMU
|
82
|
+
int htoi2(char* src)
|
83
|
+
{
|
84
|
+
char buf[3];
|
85
|
+
buf[0]=src[0];
|
86
|
+
buf[1]=src[1];
|
87
|
+
buf[2]=0;
|
88
|
+
return sysHtoi(buf);
|
89
|
+
}
|
90
|
+
#endif
|
91
|
+
|
92
|
+
char mac[6];
|
93
|
+
|
94
|
+
char* netMac()
|
95
|
+
{
|
96
|
+
#ifdef VSIMU
|
97
|
+
int i;
|
98
|
+
char *p=PropGet("MAC");
|
99
|
+
for(i=0; i<6; i++)
|
100
|
+
{
|
101
|
+
mac[i]=htoi2(&p[i*2]);
|
102
|
+
}
|
103
|
+
return mac;
|
104
|
+
// return "abcdef";
|
105
|
+
#endif
|
106
|
+
#ifdef VREAL
|
107
|
+
return (char*) rt2501_mac;
|
108
|
+
#endif
|
109
|
+
}
|
110
|
+
|
111
|
+
int netChk(char* src,int indexsrc,int lentosend,int lensrc,unsigned int val)
|
112
|
+
{
|
113
|
+
unsigned short* p;
|
114
|
+
|
115
|
+
if (indexsrc<0)
|
116
|
+
{
|
117
|
+
return val;
|
118
|
+
}
|
119
|
+
if (indexsrc+lentosend>lensrc)
|
120
|
+
{
|
121
|
+
lentosend=lensrc-indexsrc;
|
122
|
+
}
|
123
|
+
if (lentosend<=0)
|
124
|
+
{
|
125
|
+
return val;
|
126
|
+
}
|
127
|
+
|
128
|
+
src+=indexsrc;
|
129
|
+
p=(unsigned short*)src;
|
130
|
+
|
131
|
+
val=((val<<8)&0xff00)+((val>>8)&0xff);
|
132
|
+
while(lentosend>1)
|
133
|
+
{
|
134
|
+
val+=*(p++);
|
135
|
+
lentosend-=2;
|
136
|
+
}
|
137
|
+
if (lentosend)
|
138
|
+
{
|
139
|
+
val+=*(unsigned char*)p;
|
140
|
+
}
|
141
|
+
|
142
|
+
val=(val>>16)+(val&0xffff);
|
143
|
+
val=(val>>16)+(val&0xffff);
|
144
|
+
val=((val<<8)&0xff00)+((val>>8)&0xff);
|
145
|
+
return val;
|
146
|
+
}
|
147
|
+
|
148
|
+
void netSetmode(int mode,char* ssid,int chn)
|
149
|
+
{
|
150
|
+
#ifdef VSIMU
|
151
|
+
my_printf(LOG_SIMUNET, "xxxx netSetmode %d %s %d\n",mode,ssid,chn);
|
152
|
+
netstatesimu=(mode)?5:4;
|
153
|
+
#endif
|
154
|
+
#ifdef VREAL
|
155
|
+
rt2501_setmode(mode,ssid,chn);
|
156
|
+
#endif
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
int nscan;
|
161
|
+
#ifdef VREAL
|
162
|
+
void netScan_(struct rt2501_scan_result *scan_result, void *userparam)
|
163
|
+
{
|
164
|
+
char buf[256];
|
165
|
+
sprintf(buf,">>> %s %d %d %d %d\n",scan_result->ssid,scan_result->rssi,scan_result->channel,scan_result->rateset,scan_result->encryption);
|
166
|
+
consolestr((UBYTE*)buf);
|
167
|
+
VPUSH(PNTTOVAL(VMALLOCSTR(scan_result->ssid,strlen(scan_result->ssid))));
|
168
|
+
VPUSH(PNTTOVAL(VMALLOCSTR((char*)scan_result->mac,6)));
|
169
|
+
VPUSH(PNTTOVAL(VMALLOCSTR((char*)scan_result->bssid,6)));
|
170
|
+
VPUSH(INTTOVAL(scan_result->rssi));
|
171
|
+
VPUSH(INTTOVAL(scan_result->channel));
|
172
|
+
VPUSH(INTTOVAL(scan_result->rateset));
|
173
|
+
VPUSH(INTTOVAL(scan_result->encryption));
|
174
|
+
VMKTAB(7);
|
175
|
+
nscan++;
|
176
|
+
}
|
177
|
+
#endif
|
178
|
+
|
179
|
+
void netScan(char* ssid)
|
180
|
+
{
|
181
|
+
nscan=0;
|
182
|
+
#ifdef VSIMU
|
183
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
184
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
185
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
186
|
+
VPUSH(INTTOVAL(-20));
|
187
|
+
VPUSH(INTTOVAL(11));
|
188
|
+
VPUSH(INTTOVAL(1));
|
189
|
+
VPUSH(INTTOVAL(0));
|
190
|
+
VMKTAB(7);
|
191
|
+
nscan++;
|
192
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
193
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
194
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
195
|
+
VPUSH(INTTOVAL(-10));
|
196
|
+
VPUSH(INTTOVAL(11));
|
197
|
+
VPUSH(INTTOVAL(1));
|
198
|
+
VPUSH(INTTOVAL(0));
|
199
|
+
VMKTAB(7);
|
200
|
+
nscan++;
|
201
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("zzzz",3)));
|
202
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
203
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
204
|
+
VPUSH(INTTOVAL(-10));
|
205
|
+
VPUSH(INTTOVAL(11));
|
206
|
+
VPUSH(INTTOVAL(1));
|
207
|
+
VPUSH(INTTOVAL(0));
|
208
|
+
VMKTAB(7);
|
209
|
+
nscan++;
|
210
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("",3)));
|
211
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
212
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
213
|
+
VPUSH(INTTOVAL(-10));
|
214
|
+
VPUSH(INTTOVAL(11));
|
215
|
+
VPUSH(INTTOVAL(1));
|
216
|
+
VPUSH(INTTOVAL(0));
|
217
|
+
VMKTAB(7);
|
218
|
+
nscan++;
|
219
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("a\"a<a'a a\\a",strlen("a\"a<a'a a\\a"))));
|
220
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
221
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
222
|
+
VPUSH(INTTOVAL(-10));
|
223
|
+
VPUSH(INTTOVAL(11));
|
224
|
+
VPUSH(INTTOVAL(1));
|
225
|
+
VPUSH(INTTOVAL(3));
|
226
|
+
VMKTAB(7);
|
227
|
+
nscan++;
|
228
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("foo",3)));
|
229
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("xyzxyz",6)));
|
230
|
+
VPUSH(PNTTOVAL(VMALLOCSTR("765432",6)));
|
231
|
+
VPUSH(INTTOVAL(-30));
|
232
|
+
VPUSH(INTTOVAL(11));
|
233
|
+
VPUSH(INTTOVAL(1));
|
234
|
+
VPUSH(INTTOVAL(0));
|
235
|
+
VMKTAB(7);
|
236
|
+
nscan++;
|
237
|
+
#endif
|
238
|
+
#ifdef VREAL
|
239
|
+
rt2501_scan(ssid, netScan_, NULL);
|
240
|
+
#endif
|
241
|
+
VPUSH(NIL);
|
242
|
+
while(nscan--)
|
243
|
+
{
|
244
|
+
VMKTAB(2);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
void netAuth(char* ssid,char* mac,char* bssid,int chn,int rate,int authmode,int encrypt,char* key)
|
249
|
+
{
|
250
|
+
#ifdef VSIMU
|
251
|
+
my_printf(LOG_SIMUNET, "xxxx netAuth %s %d %d %d %d\n",ssid,chn,rate,authmode,encrypt);
|
252
|
+
netstatesimu=4;
|
253
|
+
#endif
|
254
|
+
#ifdef VREAL
|
255
|
+
rt2501_auth((const char*)ssid,(const unsigned char*)mac,(const unsigned char*)bssid,chn,rate,authmode,encrypt,(const unsigned char*)key);
|
256
|
+
#endif
|
257
|
+
}
|
258
|
+
|
259
|
+
void netSeqAdd(unsigned char* seq,int n)
|
260
|
+
{
|
261
|
+
unsigned char res[4];
|
262
|
+
unsigned int val;
|
263
|
+
val=(seq[0]<<24)+(seq[1]<<16)+(seq[2]<<8)+seq[3];
|
264
|
+
val+=n;
|
265
|
+
res[3]=val;
|
266
|
+
val>>=8;
|
267
|
+
res[2]=val;
|
268
|
+
val>>=8;
|
269
|
+
res[1]=val;
|
270
|
+
val>>=8;
|
271
|
+
res[0]=val;
|
272
|
+
VPUSH(PNTTOVAL(VMALLOCSTR((char*)res,4)));
|
273
|
+
}
|
274
|
+
|
275
|
+
void mypassword_to_pmk(const char *password, char *ssid, int ssidlength, unsigned char *pmk);
|
276
|
+
|
277
|
+
void netPmk(char* ssid,char* key,char* buf)
|
278
|
+
{
|
279
|
+
#ifdef VSIMU
|
280
|
+
my_printf(LOG_SIMUNET, "xxxx netPmk %s %s\n",ssid,key);
|
281
|
+
strcpy(buf,"01234567012345670123456701234567");
|
282
|
+
#endif
|
283
|
+
#ifdef VREAL
|
284
|
+
// strcpy(buf,"01234567012345670123456701234567");
|
285
|
+
mypassword_to_pmk(key,ssid,strlen(ssid), (unsigned char*)buf);
|
286
|
+
#endif
|
287
|
+
}
|
288
|
+
|
289
|
+
int netRssi()
|
290
|
+
{
|
291
|
+
#ifdef VSIMU
|
292
|
+
return -20;
|
293
|
+
#endif
|
294
|
+
#ifdef VREAL
|
295
|
+
return rt2501_rssi_average();
|
296
|
+
#endif
|
297
|
+
}
|
298
|
+
|
File without changes
|
@@ -12,16 +12,13 @@ module NabaztagHackKit
|
|
12
12
|
def initialize(opts = {})
|
13
13
|
super
|
14
14
|
@base_file = opts.fetch(:base_file, __FILE__)
|
15
|
-
@bytecode_file = opts.fetch(:bytecode_file, public_file('bytecode.bin'))
|
15
|
+
@bytecode_file = opts.fetch(:bytecode_file, public_file('bytecode.bin')).to_s
|
16
|
+
abort("Couldn't find Bytecode file. Pls compile first") unless File.exists?(@bytecode_file)
|
17
|
+
puts "Serving Bytecode from #{@bytecode_file}"
|
16
18
|
end
|
17
19
|
|
18
20
|
get "/bc.jsp" do
|
19
|
-
|
20
|
-
logger.info "Serving Bytecode from #{@bytecode_file}"
|
21
|
-
send_file @bytecode_file
|
22
|
-
else
|
23
|
-
status 404
|
24
|
-
end
|
21
|
+
send_file @bytecode_file
|
25
22
|
end
|
26
23
|
|
27
24
|
get "/" do
|
data/lib/nabaztag_hack_kit.rb
CHANGED
data/nabaztag_hack_kit.gemspec
CHANGED
@@ -6,25 +6,24 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "nabaztag_hack_kit"
|
7
7
|
s.version = NabaztagHackKit::VERSION
|
8
8
|
s.authors = ["RngTng - Tobias Bielohlawek"]
|
9
|
-
s.email = ["tobi@
|
10
|
-
s.homepage = "https://github.com/rngtng/
|
9
|
+
s.email = ["tobi@rngtng.com"]
|
10
|
+
s.homepage = "https://github.com/rngtng/NabaztagHackKit"
|
11
11
|
s.summary = %q{Sinatra server to run custom Nabaztag bytecode}
|
12
12
|
s.description = %q{Sinatra server api framework to run custom bytecode on Nabaztag v1/v2. Sources + Compiler included (linux only)}
|
13
13
|
|
14
|
-
s.files = `git ls-files`.split("\n")
|
14
|
+
s.files = `git ls-files --recurse-submodules`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
s.extensions = ['
|
16
|
+
s.extensions = ['ext/extconf.rb']
|
17
17
|
|
18
|
-
s.bindir = '
|
18
|
+
s.bindir = 'ext/bin'
|
19
19
|
s.executables = ['mtl_comp', 'mtl_simu', 'mtl_merge']
|
20
20
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
23
|
+
s.add_dependency 'sinatra', '>= 2.0'
|
24
|
+
s.add_dependency 'rack', '>= 2.0'
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
s.add_development_dependency 'rake', '>= 11.2'
|
27
|
+
s.add_development_dependency 'rspec', '>= 3.5'
|
28
|
+
s.add_development_dependency 'rack-test', '>= 0.6'
|
30
29
|
end
|
@@ -6,14 +6,14 @@ require "rack/test"
|
|
6
6
|
shared_examples_for :successful_route do
|
7
7
|
it "returns 200" do
|
8
8
|
get route
|
9
|
-
last_response.
|
9
|
+
expect(last_response).to be_ok
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
shared_examples_for :notfound_route do
|
14
14
|
it "returns 404" do
|
15
15
|
get route
|
16
|
-
last_response.status.
|
16
|
+
expect(last_response.status).to eq 404
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -53,7 +53,7 @@ describe NabaztagHackKit::Server do
|
|
53
53
|
|
54
54
|
it "execute callback" do
|
55
55
|
get route
|
56
|
-
last_response.body.
|
56
|
+
expect(last_response.body).to eq ""
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/message_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "nabaztag_hack_kit/message"
|
4
3
|
|
5
4
|
describe NabaztagHackKit::Message do
|
@@ -9,58 +8,53 @@ describe NabaztagHackKit::Message do
|
|
9
8
|
let(:size) { NabaztagHackKit::Message.to_3b(data.size) }
|
10
9
|
|
11
10
|
before do
|
12
|
-
NabaztagHackKit::Message.
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
NabaztagHackKit::Message.stub!(:pack).and_return do |data|
|
17
|
-
data
|
18
|
-
end
|
11
|
+
allow(NabaztagHackKit::Message).to receive(:full_message) { |data| data }
|
12
|
+
allow(NabaztagHackKit::Message).to receive(:pack) { |data| data }
|
19
13
|
end
|
20
14
|
|
21
15
|
describe ".build" do
|
22
16
|
it "accepts single input" do
|
23
|
-
NabaztagHackKit::Message.build(*[["40"], ["40", "2", "3", "4"]]).
|
17
|
+
expect(NabaztagHackKit::Message.build(*[["40"], ["40", "2", "3", "4"]])).to eq [[40, 0, 0, 0], [40, 0, 0, 1, 50]]
|
24
18
|
end
|
25
19
|
|
26
20
|
it "accepts single input" do
|
27
|
-
NabaztagHackKit::Message.build(CMD).
|
21
|
+
expect(NabaztagHackKit::Message.build(CMD)).to eq [[CMD, 0, 0, 0]]
|
28
22
|
end
|
29
23
|
|
30
24
|
it "accepts flat input" do
|
31
|
-
NabaztagHackKit::Message.build(CMD, *data).
|
25
|
+
expect(NabaztagHackKit::Message.build(CMD, *data)).to eq [[CMD, *size, *data]]
|
32
26
|
end
|
33
27
|
|
34
28
|
it "accepts array input" do
|
35
|
-
NabaztagHackKit::Message.build([CMD, *data]).
|
29
|
+
expect(NabaztagHackKit::Message.build([CMD, *data])).to eq [[CMD, *size, *data]]
|
36
30
|
end
|
37
31
|
|
38
32
|
it "accepts multiple array input" do
|
39
|
-
NabaztagHackKit::Message.build([CMD, *data], [CMD1, *data]).
|
33
|
+
expect(NabaztagHackKit::Message.build([CMD, *data], [CMD1, *data])).to eq [[CMD, *size, *data], [CMD1, *size, *data]]
|
40
34
|
end
|
41
35
|
|
42
36
|
it "accepts hash input" do
|
43
|
-
NabaztagHackKit::Message.build(CMD => data, CMD1 => data).
|
37
|
+
expect(NabaztagHackKit::Message.build(CMD => data, CMD1 => data)).to eq [[CMD, *size, *data], [CMD1, *size, *data]]
|
44
38
|
end
|
45
39
|
|
46
40
|
context "as string" do
|
47
41
|
it "accepts hash input" do
|
48
|
-
NabaztagHackKit::Message.build(CMD.to_s => data.map(&:to_s), CMD1.to_s => data).
|
42
|
+
expect(NabaztagHackKit::Message.build(CMD.to_s => data.map(&:to_s), CMD1.to_s => data)).to eq [[CMD, *size, *data], [CMD1, *size, *data]]
|
49
43
|
end
|
50
44
|
end
|
51
45
|
end
|
52
46
|
|
53
47
|
describe ".to_3b" do
|
54
48
|
it "accepts zero" do
|
55
|
-
NabaztagHackKit::Message.to_3b(0).
|
49
|
+
expect(NabaztagHackKit::Message.to_3b(0)).to eq [0, 0, 0]
|
56
50
|
end
|
57
51
|
|
58
52
|
it "accepts 2 byte input" do
|
59
|
-
NabaztagHackKit::Message.to_3b(511).
|
53
|
+
expect(NabaztagHackKit::Message.to_3b(511)).to eq [0, 1, 255]
|
60
54
|
end
|
61
55
|
|
62
56
|
it "accepts 3 byte input" do
|
63
|
-
NabaztagHackKit::Message.to_3b(6334239).
|
57
|
+
expect(NabaztagHackKit::Message.to_3b(6334239)).to eq [96, 167, 31]
|
64
58
|
end
|
65
59
|
end
|
66
60
|
end
|
data/spec/unit/server_spec.rb
CHANGED
@@ -14,27 +14,30 @@ describe NabaztagHackKit::Server do
|
|
14
14
|
})
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
xit "reads from public/bytecode.bin" do
|
18
|
+
expect(app).to_receive(:send_file).with("public/bytecode.bin")
|
19
|
+
begin
|
20
|
+
do_action '/bc.jsp'
|
21
|
+
rescue SystemExit
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
context "with custom bin code route" do
|
24
26
|
let(:app) { NabaztagHackKit::Server.new(custom_route) }
|
25
27
|
let(:custom_route) { "bytecode.bin" }
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
xit "reads from" do
|
30
|
+
expect(app).to_receive(:send_file).with(custom_route)
|
31
|
+
begin
|
32
|
+
do_action '/bc.jsp'
|
33
|
+
rescue SystemExit
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
describe "#on" do
|
36
|
-
|
37
|
-
pending
|
40
|
+
xit "accepts" do
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|