source: src/router/shared/utils.h @ 32498

Last change on this file since 32498 was 32498, checked in by brainslayer, 4 weeks ago

just for preparation

File size: 37.3 KB
Line 
1#ifndef UTILS_H
2#define UTILS_H
3
4#ifdef CDEBUG
5#include <shutils.h>
6#include <malloc.h>
7#include <cy_conf.h>
8#endif
9#include <string.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <unistd.h>
13#include <signal.h>
14#include <syslog.h>
15#include <typedefs.h>
16
17#define sys_reboot() eval("sync"); eval("event","3","1","15")
18/*
19 * 2 byte router ID number; Eko 4.jul.06
20 *
21 * X X X X X X X X R R R P N N N N = 0xXXXX --------------- ----- - -------
22 * router num | | gpio num (1111 = f = disable resetbutton) | | | |--- resetbutton polarity (0: normal, 1 inversed) | |-------- reserved for
23 * future use (maybe USB supp)
24 */
25
26// Linksys WRT54G, WRT54GS and WRT54GL all models (v2 - v6) except WRT54G
27// v1.0, v1.1 (fccid: Linksys Q87-WRT54G..., Q87_WT54G...)
28#define ROUTER_WRT54G 0x0116
29
30// Linksys WRT54Gv8, WRT54GSv7 (BCM5354 cpu, fccid: Linksys Q87-WRT54GV8,
31// Q87-WRT54GSV7)
32// Linksys WRT54Gv8.2, WRT54GSv7.2 (BCM5354 cpu, fccid: Linksys
33// Q87-WRT54GV82, Q87-WRT54GSV72)
34// Linksys WRT54Gv7.2 (EMEA only - same hardware as v8)
35// Linksys WRT54G2v1 (BCM5354 cpu, fccid: Linksys Q87-WRT54G2V1)
36// Linksys WRT54G2v1.3 (BCM5354 cpu, fccid: Linksys Q87-WRT54G2V13)
37// Linksys WRT54GS2v1 (BCM5354 cpu, fccid: Linksys Q87-WRT54G2V1)
38#define ROUTER_WRT54G_V8 0x0216
39
40// Linksys WRT54G v1.0 and v1.1, Alnet ALL0277 (BCM4702 cpu, fccid: v1:
41// Linksys PKW-WM54G; v1.1: Linksys Q87-WRT54G11)
42#define ROUTER_WRT54G1X 0x0316
43
44// Linksys WRTSL54GS (BCM4704 cpu, BCM5325E switch, fccid: Linksys
45// Q87-WTSLGS, same without USB: Q87-WRTH54GS)
46#define ROUTER_WRTSL54GS 0x0416
47
48// Linksys WRT55AG v1 (BCM4702 cpu, dual minipci (Broadcom + Atheros), fccid:
49// Linksys PKW-WRT55AG)
50#define ROUTER_LINKSYS_WRT55AG 0x0516
51
52// Asus WL-500G-Deluxe (BCM5365 cpu), (fccid: Asus MSQWL500GD)
53#define ROUTER_ASUS_WL500GD 0x0606
54
55// Buffalo WBR-G54, WLA-G54 (BCM4702 cpu, WLA-G54 has no switch)
56#define ROUTER_BUFFALO_WBR54G 0x0704
57
58// Buffalo WBR2-G54 (BCM4712 + ADM6996 switch, fccid: Buffalo
59// FDI-04600142-0),
60// Buffalo WBR2-G54S, WLA2-G54L (= WLA2-G54 in Japan)
61#define ROUTER_BUFFALO_WBR2G54S 0x0807
62
63// Buffalo WLA2-G54C == WLI3-TX1-G54 (BCM4712 cpu, no switch, fccid: Buffalo
64// FDI-09101669-0)
65#define ROUTER_BUFFALO_WLA2G54C 0x0910
66
67// Buffalo WHR-G54S (BCM5352E cpu, fccid: Buffalo FDI-04600264-0) and
68// WHR-HP-G54 (BCM5352E cpu, fccid: Buffalo FDI-09101577-0)
69// Buffalo WHR-G125, WHR-HP-G125 (BCM5354 cpu, fccid: Buffalo FDI-09101584-0)
70// Buffalo WHR-HP-G125 new (BCM5354 cpu, fccid: FDI-09101588-0)
71#define ROUTER_BUFFALO_WHRG54S 0x0a04
72
73// Buffalo WZR-RS-G54 (BCM4704 cpu), WZR-G54, WZR-HP-G54 (4704 cpu, fccid:
74// Buffalo FDI-09101457-0),
75// Buffalo WHR3-AG54, WVR-G54-NF, WHR2-A54G54
76#define ROUTER_BUFFALO_WZRRSG54 0x0b04
77
78// Motorola WR850G v1 (BCM4702 cpu, fccid: Motorola ACQWR850G)
79#define ROUTER_MOTOROLA_V1 0x0c10
80
81// Motorola WR850G v2/v3, WR850GP (BCM4712 cpu, ADM6996 switch, fccid:
82// Motorola ACQWR850GV2)
83#define ROUTER_MOTOROLA 0x0d15
84
85// RT210W and RT211W generic and branded (BCM4702 cpu, fccid: Askey
86// H8N-RT210W, H8N-RT211W)
87// H8N-RT210W: Siemens se505 v1, Belkin F5D7230-4 v1000, v1xxx < 1444
88// H8N-RT211W: Belkin F5D7130
89#define ROUTER_RT210W 0x0e0f
90
91// RT480W generic and branded (BCM4712 cpu, ADM6996 switch, fccid: Askey
92// H8NRT480W),
93// Siemens se505 v2, Belkin F5D7230-4 v1444 (2MB flash, fccid: Belkin
94// K7S-F5D72304)
95#define ROUTER_RT480W 0x0f0f
96
97// Microtik RouterBOARD 500
98#define ROUTER_BOARD_500 0x100f
99
100// NMN A/B/G Router Protoype (266 Mhz Xscale, dual minipci)
101#define ROUTER_BOARD_XSCALE 0x1101
102
103// Generic BRCM 4702 boards
104#define ROUTER_BRCM4702_GENERIC 0x120f
105
106// Buffalo WLI_TX4_G54HP bridge
107#define ROUTER_BUFFALO_WLI_TX4_G54HP 0x1304
108
109// Microsoft MN-700 (BCM4702 cpu), (fccid: Microsoft C3KMN700)
110#define ROUTER_MICROSOFT_MN700 0x1417
111
112// Buffalo WLA-G54C == WLI-TX1-G54 (BCM4702 cpu - no switch, fccid:
113// QDS-BRCM1005)
114#define ROUTER_BUFFALO_WLAG54C 0x1510
115
116// Asus WL-500g Premium (BCM4704 cpu, BCM5325E switch, (fccid: Asus
117// MSQWL500GP)
118#define ROUTER_ASUS_WL500G_PRE 0x1600
119
120// Buffalo WZR-G300N MIMO Router (radio fccid: Buffalo FDI-09101466-0)
121#define ROUTER_BUFFALO_WZRG300N 0x1704
122
123// Linksys WRT300N v1 (BCM4704 cpu, BCM5325F switch, fccid: Linksys
124// Q87-WRT300N or Q87-WRT300NV1)
125#define ROUTER_WRT300N 0x1816
126
127// Buffalo WHR-AM54G54
128#define ROUTER_BUFFALO_WHRAM54G54 0x190f
129
130// Magicbox PowerPC board
131#define ROUTER_BOARD_MAGICBOX 0x1a01
132
133// Magicbox PowerPC board 2.0
134// #define ROUTER_BOARD_MAGICBOX20 0x1b01
135
136// Buffalo WLI2-TX1-G54 Access point (BCM4702 cpu, no switch)
137#define ROUTER_BUFFALO_WLI2_TX1_G54 0x1c10
138
139// NMN A/B/G Router Protoype (266 Mhz Xscale, four minipci)
140#define ROUTER_BOARD_GATEWORX 0x1d04
141
142// Motorola WE800G v1 (BCM4702 cpu, no switch, minipci radio, fccid: Motorola
143// ACQWE800G, F2NWE800G)
144#define ROUTER_MOTOROLA_WE800G 0x1e10
145
146// Generic x86 PC / WRAP / Soekris
147#define ROUTER_BOARD_X86 0x1f0f
148
149// ?
150#define ROUTER_SUPERGERRY 0x200f
151
152// Linksys WRT350N (BCM4705 cpu, Gbit switch, PCMCIA radio card, fccid:
153// Linksys Q87-WRT350N)
154#define ROUTER_WRT350N 0x2116
155
156// Linksys WAP54G v1 and v1.1 (BCM4702 cpu, no switch, fccid: Linksys
157// PKW-WAP54G)
158// 2 different boards (same fccid): WX5510_Vxx and WX5541_Vxx
159#define ROUTER_WAP54G_V1 0x2210
160
161// Linksys WAP54G v2 (BCM4712 cpu, no switch, fccid: Linksys Q87-WAP54GV2)
162// Linksys WRE54G v1 (BCM4712 cpu, no ethernet port, fccid: Linksys Q87-WRE54G)
163#define ROUTER_WAP54G_V2 0x2310
164
165// ViewSonic WAPBR-100 (BCM4712 cpu, no switch, fccid: Viewsonic GSS-VS10407)
166#define ROUTER_VIEWSONIC_WAPBR_100 0x2417
167
168// Dell TrueMobile 2300 v1 (BCM4702 cpu, BCM5325 switch, mini pci radio,
169// fccid: Gemtek MXF-R920401G)
170#define ROUTER_DELL_TRUEMOBILE_2300 0x2510
171
172// Dell TrueMobile 2300 v2 (BCM4712 cpu, ADM6996 switch, fccid: Gemtek
173// MXF-R921212G)
174// Sparklan WX-6615GT (4712 cpu, ADM6996 switch, fccid: Gemtek MXF-R930116G)
175#define ROUTER_DELL_TRUEMOBILE_2300_V2 0x2610
176
177// Fonera (Atheros SoC, no switch, fccid: Accton HED-FON2100)
178#define ROUTER_BOARD_FONERA 0x2701
179
180// Buffalo WHR-HP-AG108 (Atheros A+G, Kendin KS8895XA switch, fccid: Buffalo
181// FDI-09101540-0)
182#define ROUTER_BOARD_WHRAG108 0x2801
183
184// swapped phy definition
185#define ROUTER_BOARD_GATEWORX_SWAP 0x290f
186
187// Netgear WNR834Bv1 (BCM4704 cpu, BCM5325 switch, cardbus radio, fccid:
188// Netgear PY306100032)
189#define ROUTER_NETGEAR_WNR834B 0x2a17
190
191// swapped phy definition and Kendin switch
192#ifdef HAVE_MI424WR
193#define ROUTER_BOARD_GATEWORX_GW2345 0x2b0a
194#else
195#define ROUTER_BOARD_GATEWORX_GW2345 0x2b0f
196#endif
197// Linksys WRT54G3G (BCM4712 cpu, 5325E switch, PCMCIA slot, fccid: Linksys
198// Q87-WRT54G3G)
199#define ROUTER_WRT54G3G 0x2c16
200
201// Sitecom WL-105(b) (BCM4702 cpu, no switch, fccid: Gemtek MXF-A910910AB -
202// no A-band)
203#define ROUTER_SITECOM_WL105B 0x2d10
204
205// Linksys WRT150N (BCM4704 cpu, BCM5325F switch, fccid: Linksys Q87-WRT150N)
206#define ROUTER_WRT150N 0x2e16
207
208// ?
209#define ROUTER_BOARD_LS2 0x2f01
210
211// Buffalo WAPM-HP-AM54G54 (only available on japanese market, dual radio 2.4
212// and 5 GHz Broadcom)
213#define ROUTER_BUFFALO_WAPM_HP_AM54G54 0x3005
214
215// Buffalo WLAH-G54 (only available on japanese market, single radio 2.4 ghz)
216#define ROUTER_BUFFALO_WLAH_G54 0x3104
217
218// Buffalo WZR-G144HH (only available on japanese market, 802.11n, Gigabit
219// switch. Similar to WRT350N)
220#define ROUTER_BUFFALO_WZRG144NH 0x3217
221
222// U.S.Robotics USR5430 bridge (BCM4712 cpu, no switch, fccid: Gemtek
223// MXF-EB921201G)
224#define ROUTER_USR_5430 0x3310
225
226// U.S.Robotics USR5432 bridge (BCM5350 cpu, 1 port, fccid: Universal Scientific Industrial Co. IXM-APGBR02)
227// U.S.Robotics USR5441 range-ext. (BCM5350 cpu, 1 port, fccid: Universal Scientific Industrial Co. IXM-APGBR02)
228// U.S.Robotics USR5451 AP (BCM5350 cpu, 1 port, fccid: Universal Scientific Industrial Co. IXM-APGBR02)
229// U.S.Robotics USR5461 router (BCM5350 cpu, fccid: Universal Scientific Industrial Co. IXM-RTGBR02)
230#define ROUTER_USR_5461 0x340f
231
232// Meraki Mini (Atheros SoC, no switch, fccid: Meraki UDX-MERAKI-MINI)
233#define ROUTER_BOARD_MERAKI 0x350f
234
235// Asus WL300g (BCM4702 cpu, no switch, fccid: Asus MSQWL300G)
236// Asus WL500g (BCM4702 cpu, fccid: Asus MSQWL500G)
237#define ROUTER_ASUS_WL500G 0x3606
238
239// ?
240// #ifdef HAVE_ALPHA
241// #define ROUTER_BOARD_CA8 0x3706
242// #else
243#define ROUTER_BOARD_CA8 0x3706
244// #endif
245
246// Fonera (Atheros SoC,...)
247#define ROUTER_BOARD_FONERA2200 0x3801
248
249// ?
250#define ROUTER_BOARD_TW6600 0x3901
251
252// Atheros PB42 prototype (AR5416 MIMO Wifi, 400 Mhz Mips CPU, 32 MB RAM)
253#define ROUTER_BOARD_PB42 0x3a01
254
255// Asus WL-500W (MIMO, 4704 cpu, fccid: Asus MSQWL500W)
256#define ROUTER_ASUS_WL500W 0x3b06
257
258// Asus WL550gE (BCM5352E cpu, fccid: Asus MSQWL550GE)
259// Asus WL320gP/gE (BCM5352E cpu, 1 LAN only, fccid: Asus MSQWL320GP / MSQWL320GE)
260#define ROUTER_ASUS_WL550GE 0x3c01
261
262// Sitecom WL-111 (BCM4702 cpu, fccid: MXF-R920220G)
263#define ROUTER_SITECOM_WL111 0x3d10
264
265// D-Link DIR-320 (BCM5354 cpu, fccid: D Link KA2DIR320A1)
266#define ROUTER_DLINK_DIR320 0x3e17
267
268// Linksys WTR54GS travel router (BCM5350 cpu, 2 ports, fccid: v1, v2:
269// Linksys Q87-WTR54GS; v2.1 Q87-WTR54GSV21)
270#define ROUTER_LINKSYS_WTR54GS 0x3f13
271
272// Belkin F5D7230 v2000 (BCM4712 cpu, 5325E switch, serial flash, fccid:
273// Belkin K7SF5D7234A)
274#define ROUTER_BELKIN_F5D7230_V2000 0x400f
275
276// Belkin F5D7231-4 v1212UK (BCM5352E cpu, fccid: Askey H8NRT2406W)
277#define ROUTER_BELKIN_F5D7231 0x410f
278
279// Linksys WAP54G v3, WAP54G v3.1 (BCM5352E cpu, fccid: Linksys Q87-WAP54GV3,
280// Q87-WAP54GV31)
281#define ROUTER_WAP54G_V3 0x4210
282
283// Asus WL-520G (WL-500G-C in China) (BCM5350 cpu, fccid: Asus MSQWL520G)
284#define ROUTER_ASUS_WL520G 0x430f
285
286// Asus WL-520GU / WL-520GC (BCM5354 cpu, fccid: Asus MSQWL520GUGC)
287#define ROUTER_ASUS_WL520GUGC 0x4412
288
289// Netgear WG602 v3 (BCM5350 cpu, fccid: Netgear PY3WG602V3)
290#define ROUTER_NETGEAR_WG602_V3 0x4511
291
292// Netgear WG602 v4 (BCM5354 cpu, fccid: Netgear PY3WG602V4)
293#define ROUTER_NETGEAR_WG602_V4 0x4617
294
295// Linksys WRT600N (BCM4705 cpu, Gigabit switch, dual radio 2.4 and 5 GHz
296// Broadcom, fccid: Linksys Q87-WRT600NV1, Q87-WRT600NV11)
297#define ROUTER_WRT600N 0x4717
298
299// Linksys WRH54G (BCM5354 cpu, fccid: Linksys Q87-WRH54G)
300#define ROUTER_LINKSYS_WRH54G 0x4816
301
302// Linksys WRT150N v1.1 (BCM4704 cpu, BCM5325F switch, fccid: Linksys
303// Q87-WRT150NV11)
304#define ROUTER_WRT150NV11 0x4916
305
306// Linksys WRT150N v1.2 (fccid: Linksys ?)
307#define ROUTER_WRT150NV12 0x4a16
308
309// Linksys WRT160N v1 (BCM4703 cpu, ?? switch, fccid: Linksys Q87-WRT160N)
310#define ROUTER_WRT160N 0x4b16
311
312// Linksys WRT300N v1.1 (BCM4705 cpu, 5325 switch, fccid: Linksys
313// Q87-WRT300NV11)
314#define ROUTER_WRT300NV11 0x4c16
315
316// Linksys WRT310N v1 (BCM4705 cpu, fccid: Linksys Q87-WRT310N)
317#define ROUTER_WRT310N 0x4d16
318
319// Linksys WRT310N v2 (BCM4716 cpu, fccid: Linksys Q87-WRT310NV2)
320// Linksys M20 (BCM4716 cpu, fccid: Linksys Q87-M20)
321#define ROUTER_WRT310NV2 0x4e16
322
323// D-Link DIR330 (BCM5836 cpu, fccid: D Link KA2DIR330A1)
324#define ROUTER_DLINK_DIR330 0x4f13
325
326// Netgear WNDR3300 (BCM4704 cpu, BCM5325F switch, dual radio 2.4-N and 5 GHz
327// Broadcom, fccid: Netgear PY307300072)
328#define ROUTER_NETGEAR_WNDR3300 0x5016
329
330// Asus WL-330GE (BCM5354, no switch, fccid: MSQWL330GE)
331#define ROUTER_ASUS_330GE 0x5112
332
333// Linksys WRT54Gv8.1 (BCM5354 cpu, fccid: Linksys Q87-WRT54GV81)
334#define ROUTER_WRT54G_V81 0x5217
335
336// Netgear WGR614L (BCM5354 cpu, 4M serial flash - 16M ram, fccid: Netgear PY306400057)
337// Netgear WGR614 v8 - same -
338// Netgear WGR614 WW - same -
339#define ROUTER_NETGEAR_WGR614L 0x5317
340
341// Netgear WGR614L (BCM5354 cpu, 2M serial flash - 8M ram, fccid: Netgear PY306400057)
342#define ROUTER_NETGEAR_WGR614V9 0x5417
343
344// Netgear WNR834Bv2 (BCM4704 cpu, BCM5325 switch, fccid: Netgear
345// PY307100061)
346#define ROUTER_NETGEAR_WNR834BV2 0x5516
347
348// Asus WL-500g Premium v2 (BCM5354 cpu, fccid: Asus MSQWL500GPV2)
349#define ROUTER_ASUS_WL500G_PRE_V2 0x5612
350
351// Wistron CA8-PRO (RDAA-81)
352#define ROUTER_BOARD_CA8PRO 0x5706
353
354// Askey board RT2205D-D56 / RT2206D-D56 (BCM4704 cpu, mini-pci)
355// Belkin MIMO F5D8230_v2 or F5D8230_v1001ea (fccid: Airgo networks Inc.
356// SA3-AGN0901AP0100)
357#define ROUTER_ASKEY_RT220XD 0x5817
358
359// U.S.Robotics USR5455 (BCM5354 cpu, no switch, fccid: Universal Scientific
360// Industrial Co. IXM-APGBR03)
361// U.S.Robotics USR5465 (BCM5354 cpu, fccid: Universal Scientific Industrial
362// Co. IXM-RTGBR03)
363#define ROUTER_USR_5465 0x590f
364
365#define ROUTER_ALLNET01 0x5a13
366
367// Linksys WRT610N (BCM4785 cpu, Gigabit switch, dual radio 2.4 and 5 GHz
368// Broadcom, fccid: Linksys Q87-WRT610N)
369#define ROUTER_WRT610N 0x5b16
370
371// Linksys WRT610Nv2 (BCM4718 cpu, Gigabit switch, dual radio 2.4 and 5 GHz
372// Broadcom, fccid: Linksys Q87-WRT610NV2)
373// Linksys E3000 (BCM4718 cpu, Gigabit switch, dual radio 2.4 and 5 GHz
374// Broadcom, fccid: Linksys Q87-E3000)
375#define ROUTER_WRT610NV2 0x5c16
376
377// Belkin F5D7230 v3000 (BCM5350 cpu, flash ?? , fccid: Belkin PD5F5D72304)
378#define ROUTER_BELKIN_F5D7230_V3000 0x6011
379
380#ifdef HAVE_WMBR_G300NH
381#define ROUTER_BOARD_DANUBE 0x6101
382#elif HAVE_VF803
383#define ROUTER_BOARD_DANUBE 0x6101      //dummy. gpio 28
384#elif HAVE_SX763
385#define ROUTER_BOARD_DANUBE 0x6101      //dummy. gpio 28
386#else
387#define ROUTER_BOARD_DANUBE 0x610f
388#endif
389#define ROUTER_BOARD_STORM 0x6201       // value 1 is a fake to enable reset button code. real gpio is 60
390
391#define ROUTER_BOARD_ADM5120 0x630f
392
393#define ROUTER_BUFFALO_WCAG 0x6404
394
395#define ROUTER_BOARD_WHRG300N 0x651a
396
397#define ROUTER_BOARD_RT2880 0x660f
398
399// Wistron RCAA01 (RCAA-01)
400#define ROUTER_BOARD_RCAA01 0x6706
401
402// Wistron RDAT81 (RDAT81)
403#define ROUTER_BOARD_RDAT81 0x6806
404
405// Senao ECB9750
406#define ROUTER_BOARD_ECB9750 0x691b
407
408// Compex WP54G (and compatible)
409#define ROUTER_BOARD_WP54G 0x7004
410
411// Compex NP28G (and compatible)
412#define ROUTER_BOARD_NP28G 0x710f
413
414// Belkin F5D7231-4 v2000 (BCM5352E cpu, fccid: Belkin K7SF5D7231B)
415#define ROUTER_BELKIN_F5D7231_V2000 0x7213
416
417#define ROUTER_BOARD_ESR6650 0x731a
418
419// Netgear WNR3500L (BCM4718A cpu, 8MB serial flash, USB, Gigabit switch, fccid: Netgear PY308400093)
420// Netgear WNR3500v2 - same - half flash
421#define ROUTER_NETGEAR_WNR3500L 0x7414  //(18)
422// Netgear WNR3500L V2 (BCM47186B0 cpu, 128MB ram,  128MB nand flash, int. antennae can be replaced with ext)
423#define ROUTER_NETGEAR_WNR3500LV2 0x7416
424
425// Linksys WRT320N (BCM4717A cpu, 8MB serial flash, Gigabit switch, fccid: Linksys Q87-WRT320N)
426// Linksys E2000 (BCM4717A cpu, 8MB serial flash, Gigabit switch, fccid: Linksys Q87-E2000)
427#define ROUTER_WRT320N 0x7518
428
429#define ROUTER_BOARD_ESR9752 0x7610
430
431#define ROUTER_BOARD_DIR600B 0x771a
432
433#define ROUTER_BOARD_ACXNR22 0x781a
434
435#define ROUTER_BOARD_AR670W 0x7919
436
437#define ROUTER_BOARD_EAP9550 0x8010
438
439#define ROUTER_BOARD_GATEWORX_GW2369 0x8103
440
441// Linksys WRT160Nv3 (BCM4716A cpu, 4MB serial flash, 5325E switch, fccid: Linksys Q87-WRT160NV3)
442// CSE31 ports [W-1-2-3-4], CSE41 and CSE51 ports [W-4-3-2-1]
443// Cisco Valet M10 (BCM4716A cpu, 4MB serial flash, 5325E switch, fccid: Linksys Q87-M10)
444// Linksys E1000 v1 (BCM4716A cpu, 4MB serial flash, 5325E switch, fccid: Linksys Q87-E1000)
445#define ROUTER_WRT160NV3 0x8216
446
447#define ROUTER_BOARD_BS2M 0x831c        //bullet 2m
448#define ROUTER_BOARD_BS5M 0x841c        //bullet 5m
449#define ROUTER_BOARD_R2M 0x851c //rocket 2m
450#define ROUTER_BOARD_R5M 0x861c //rocket 5m
451#define ROUTER_BOARD_NS2M 0x871c        //nanostation 2m
452#define ROUTER_BOARD_NS5M 0x881c        //nanostation 5m
453
454// Asus RT-N10 (BCM5356 cpu, 4MB serial flash / 16MB ram, fccid: Asus MSQ-RTN10)
455#define ROUTER_ASUS_RTN10 0x8913
456
457// Asus RT-N12 (BCM4716B0 cpu, 4MB serial flash / 32MB ram, 5325E switch, fccid: Asus MSQ-RTN12)
458#define ROUTER_ASUS_RTN12 0x8a11
459
460// Asus RT-N16 (BCM4718A cpu, 32MB flash / 128MB ram, BCM53115 giga switch, fccid: Asus MSQRTN16)
461#define ROUTER_ASUS_RTN16 0x8b16
462
463#define ROUTER_BOARD_BR6574N 0x8c1a
464
465#ifdef HAVE_HORNET
466#define ROUTER_BOARD_WHRHPGN 0x8d1c     //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
467#elif HAVE_CARAMBOLA
468#define ROUTER_BOARD_WHRHPGN 0x8d1b     //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
469#elif HAVE_DIR825C1
470#define ROUTER_BOARD_WHRHPGN 0x8d111    //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
471#elif HAVE_WASP
472#define ROUTER_BOARD_WHRHPGN 0x8d110    //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
473#elif HAVE_WNR2200
474#define ROUTER_BOARD_WHRHPGN 0x8d126    //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
475#elif HAVE_WNR2000
476#define ROUTER_BOARD_WHRHPGN 0x8d128    //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
477#else
478#define ROUTER_BOARD_WHRHPGN 0x8d1b     //Buffalo WHR HP GN AR7240 / 4 MB Flash / 32 MB RAM
479#endif
480// Dynex DX-NRUTER (BCM4703 cpu, 4MB flash / 32MB ram, BCM5325E switch, fccid: Belkin K7SDXNRUTER)
481#define ROUTER_DYNEX_DX_NRUTER 0x8e12
482
483#define ROUTER_BOARD_OPENRISC 0x8f00
484
485#define ROUTER_BOARD_ASUS_RTN13U 0x901a
486
487// Linksys WRT160NL (Atheros 9130, 8MB flash / 32MB ram, fccid: Linksys Q87-WRT160NL)
488// Linksys E2100L (Atheros 9130, 8MB flash / 32MB ram, fccid: Linksys Q87-E2100L)
489#define ROUTER_BOARD_WRT160NL 0x9101    // fake id, reset button is gpio 21
490
491// NetCore NW618 / Rosewill RNX-GX4 (BCM5354 cpu, 4MB serial flash / 16MB ram, fccid: Rosewill W6RRNX-GX4)
492#define ROUTER_NETCORE_NW618 0x9216
493
494#define ROUTER_BOARD_W502U 0x931a
495
496#define ROUTER_BOARD_DIR615D 0x941a
497
498#define ROUTER_BOARD_AR690W 0x9519
499
500#define ROUTER_BOARD_RB600 0x960f
501
502// Netgear WNR2000 v2 (BCM4716B0 cpu, 4MB serial flash / 32MB ram, fccid: Netgear PY309100105)
503#define ROUTER_NETGEAR_WNR2000V2 0x9711
504
505#ifdef HAVE_VENTANA
506#define ROUTER_BOARD_GW2388 0x9800
507#else
508#define ROUTER_BOARD_GW2388 0x980f
509#endif
510// Belkin Share Max F5D8235v3 (BCM53115 giga switch, BCM4718 cpu, 8MB flash / 32MB ram, fccid: Belkin K7SF5D8235V3)
511#define ROUTER_BELKIN_F5D8235V3 0x9916
512
513#ifdef HAVE_VENTANA
514#define ROUTER_BOARD_GW2380 0x9a00
515#else
516#define ROUTER_BOARD_GW2380 0x9a0f
517#endif
518
519// Belkin Share Max F7D3301v1 (BCM53115 giga switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Belkin K7SF7D3301V1)
520// Belkin Share Max N300 F7D7301v1  - same
521#define ROUTER_BELKIN_F7D3301 0x9b16
522
523// Belkin Share F7D3302v1 (BCM4718 cpu, BCM5325 switch, 8MB flash / 64MB ram, fccid: Belkin K7SF7D3302V1)
524// Belkin Share N300 F7D7302v1  - same
525#define ROUTER_BELKIN_F7D3302 0x9c16
526
527// Belkin Play Max F7D4301v1 (dual radio, BCM53115 giga switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Belkin K7SF7D4301V1)
528// Belkin Play N600 HD F7D8301v1 - same
529#define ROUTER_BELKIN_F7D4301 0x9d16
530
531// Belkin Play F7D4302v1 (dual radio, BCM5325 switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Belkin K7SF7D4302V1)
532// Belkin Play N600 F7D8302v1 - same
533#define ROUTER_BELKIN_F7D4302 0x9e16
534
535// Asus RT-N10+
536#define ROUTER_ASUS_RTN10PLUS 0x9f1a
537
538// Linksys E1000 v2 (BCM5357 cpu, 4MB serial flash, 32 MB ram, fccid: Linksys Q87-E1000V2)
539// Linksys E1000 v2.1 (BCM5357 cpu, 4MB serial flash, 32 MB ram, fccid: Linksys Q87-E1000V21)
540#define ROUTER_LINKSYS_E1000V2 0xa01a
541
542// Repotec RP-WR5422
543#define ROUTER_BOARD_WR5422 0xa11a
544
545// Asus WL-700ge (BCM4780 cpu, 2MB flash, 64MB ram, BCM5325E switch)
546#define ROUTER_ASUS_WL700GE 0xa217
547
548#define ROUTER_BOARD_F5D8235 0xa31a
549
550// Asus RT-15N
551#define ROUTER_BOARD_RT15N 0xa410c
552
553#define ROUTER_BOARD_TECHNAXX 0xa50f
554
555#define ROUTER_BOARD_NEPTUNE 0xa61a
556
557#define ROUTER_ASUS_RTN12B 0xa7116
558
559// Linksys E4200 (dual radio, BCM53115 giga switch, BCM4718 cpu, 16MB flash / 64MB ram, fccid: Linksys Q87-E4200) >_60K nvram_<
560#define ROUTER_LINKSYS_E4200 0xa816
561
562#define ROUTER_BOARD_RT3352 0xa91a      // concept
563
564// Asus RT-N10U (BCM5358 cpu, 8MB serial flash / 32MB ram, USB 2.0)
565#define ROUTER_ASUS_RTN10U 0xaa115
566
567// Linksys E3200 (dual radio, BCM53125 giga switch, BCM5357 cpu, 16MB flash / 64MB ram, fccid: Linksys Q87-E3200) >_60K nvram_<
568#define ROUTER_LINKSYS_E3200 0xab15
569
570// Netgear WNDR3700v3 (dual radio, BCM53115 giga switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Netgear PY311200166) >_64K nvram_<
571// Netgear WNDR4000 (dual radio, BCM53115 giga switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Netgear PY310400144) >_64K nvram_<
572#define ROUTER_NETGEAR_WNDR4000 0xac13
573
574#define ROUTER_NETCORE_NW715P 0xad0f
575
576#define ROUTER_BOARD_UNIFI 0xae1c       //bullet 2m
577
578// Asus RT-N66U (BCM4706 @ 600MHz cpu, 32MB flash / 256MB ram, fccid: Asus MSQ-RTN66U)
579#define ROUTER_ASUS_RTN66 0xaf19
580
581// Asus RT-N53             
582#define ROUTER_ASUS_RTN53 0xb013
583
584// Netgear WNDR3400 (dual radio, BCM5325E switch, BCM4718 cpu, 8MB flash / 64MB ram, fccid: Netgear PY309300116) >_64K nvram_<
585#define ROUTER_NETGEAR_WNDR3400 0xb114
586
587// Netgear WNDRR6300(dual radio, BCM53115 giga switch, BCM4706 @ 600MHz cpu, 2MB serial + 128MB NAND flash / 128MB ram, fccid: Netgear PY312100188) >_64K nvram_<
588// Netgear WNDR4500 (dual radio, BCM53115 giga switch, BCM4706 @ 600MHz cpu, 2MB serial + 128MB NAND flash / 128MB ram, fccid: Netgear PY311200162) >_64K nvram_<
589#define ROUTER_NETGEAR_R6300 0xb216
590
591#define ROUTER_BOARD_WCRGN 0xb31a
592
593// Linksys E2500 (dual radio, BCM5358U cpu, 16MB flash / 64MB ram, fccid: Linksys Q87-E2500) >_60K nvram_<
594#define ROUTER_LINKSYS_E2500 0xb41a
595
596#define ROUTER_BOARD_TECHNAXX3G 0xb51a
597
598// Linksys E900 (BCM53572 cpu, 8MB serial flash / 32 MB ram, fccid: Linksys Q87-E900) >_64K nvram_<
599// Linksys E1200v2 (BCM53572 cpu, 8MB serial flash / 32 MB ram, fccid: Linksys Q87-E1200V2) >_64K nvram_<
600#define ROUTER_LINKSYS_E900 0xb61a
601
602// Linksys E1500 (BCM5357 cpu, 8MB serial flash / 32 MB ram, fccid: Linksys Q87-E1500) >_64K nvram_<
603// Linksys E1200v1 (BCM5357 cpu, 4MB serial flash / 32 MB ram, fccid: Linksys Q87-E1200) >_64K nvram_<
604#define ROUTER_LINKSYS_E1500 0xb71a
605
606// Linksys E1550 (BCM5358U cpu, 16MB serial flash / 64MB ram, USB, fccid: Linksys Q87-E1550) >_60K nvram_<
607#define ROUTER_LINKSYS_E1550 0xb81a
608
609#define ROUTER_D1800H 0xb919
610
611#define ROUTER_HUAWEI_B970B 0xba0f
612
613#define ROUTER_BOARD_WNR3500LV2 0xbb0f
614
615#define ROUTER_BOARD_HAMEA15 0xbc10
616
617#define ROUTER_ASUS_AC66U 0xbd19
618
619#define ROUTER_ASUS_AC56U 0xbe1b        // BCM4708 SMP 800 Mhz 128 MB Nand Flash, 128 MB Ram
620
621#define ROUTER_BOARD_NORTHSTAR 0xbf0f
622
623#define ROUTER_ASUS_AC67U 0xc01b        // BCM4708 SMP 800 Mhz 128 MB Nand Flash, 128 MB Ram
624
625#define ROUTER_ASUS_RTN10PLUSD1 0xc1115
626
627#define ROUTER_BOARD_WDR4900 0xc203
628
629#define ROUTER_BUFFALO_WZR1750 0xc31b   // BCM4708 SMP 800 Mhz 128 MB Nand Flash, 512 MB Ram
630
631#define ROUTER_BUFFALO_WZR900DHP 0xc41b // BCM4707 Single Core 800 Mhz 128 MB Nand Flash, 256 MB Ram
632
633#define ROUTER_BUFFALO_WZR600DHP2 0xc51b        // BCM4707 Single Core 800 Mhz 128 MB Nand Flash, 256 MB Ram
634
635#define ROUTER_LINKSYS_E800 0xc61a
636
637#define ROUTER_LINKSYS_EA2700 0xc715
638
639#define ROUTER_NETGEAR_WNDR4500 0xc816
640
641#define ROUTER_NETGEAR_WNDR4500V2 0xc916
642
643#define ROUTER_DLINK_DIR868 0xca1b
644
645#define ROUTER_LINKSYS_EA6500 0xcb13
646
647#define ROUTER_WHR300HP2 0xcc11
648
649#define ROUTER_NETGEAR_R6250 0xcd16
650
651#define ROUTER_NETGEAR_R6300V2 0xce16
652
653#define ROUTER_NETGEAR_R7000 0xcf16
654
655#define ROUTER_BOARD_UNIWIP 0xd001
656
657#define ROUTER_LINKSYS_EA6900 0xd11b
658
659#define ROUTER_LINKSYS_EA6500V2 0xd21b
660
661#define ROUTER_TRENDNET_TEW812 0xd31b
662
663#define ROUTER_TRENDNET_TEW811 0xd41b
664
665#define ROUTER_LINKSYS_EA6700 0xd51b
666
667#define ROUTER_BOARD_TI 0xd60f
668
669#define ROUTER_NETGEAR_AC1450 0xd716
670
671#define ROUTER_ASUS_RTN18U 0xd817       // BCM4708 SMP 800 Mhz 128 MB Nand Flash, 128 MB Ram
672
673#define ROUTER_NETGEAR_EX6200 0xd916    // BCM4708 SMP 800 Mhz 8MB SPI Flash, 128 MB Ram
674
675#define ROUTER_BUFFALO_WXR1900DHP 0xda10f       // BCM4709 SMP 1000 Mhz 128 MB Nand Flash, 512 MB Ram
676
677#define ROUTER_ASUS_AC87U 0xdb1b        // BCM4708 SMP 800 Mhz 128 MB Nand Flash, 128 MB Ram
678
679#define ROUTER_UBNT_EROUTERLITE 0xdc1b  // Edgerouter Lite  (e100) Cavium Octeon SMP
680#define ROUTER_UBNT_EROUTERPRO 0xdd10   // Edgerouter Lite  (e200) Cavium Octeon SMP
681
682#define ROUTER_NETGEAR_R8000 0xde16
683
684#define ROUTER_BOARD_E1700 0xdf11
685
686#define ROUTER_DLINK_DIR865 0xe00f
687
688#define ROUTER_BOARD_AIRROUTER 0xe11c
689
690#define ROUTER_UBNT_UNIFIAC 0xe218
691
692#define ROUTER_DIR810L 0xe311
693
694#define ROUTER_WRT_1900AC 0xe411
695
696#define ROUTER_DIR860LB1 0xe417
697
698#define ROUTER_TPLINK_ARCHERC9 0xe513
699
700#define ROUTER_DLINK_DIR890 0xe6111
701
702#define ROUTER_DLINK_DIR880 0xe71b
703
704#define ROUTER_DLINK_DIR860 0xe81b
705
706#define ROUTER_TRENDNET_TEW828 0xe91b
707
708#define ROUTER_DLINK_DIR868C 0xea1b
709
710#define ROUTER_ASUS_AC3200 0xeb1b
711
712#define ROUTER_LINKSYS_EA6400 0xec1b
713
714#define ROUTER_WRT_1200AC 0xed11
715
716#define ROUTER_WRT_1900ACV2 0xee11
717
718#define ROUTER_DLINK_DIR885 0xef111
719
720#define ROUTER_DLINK_DIR895 0xf0111
721
722#define ROUTER_ASUS_AC88U 0xf11b
723
724#define ROUTER_ASUS_AC5300 0xf21b
725
726#define ROUTER_WRT_1900ACS 0xf311
727
728#define ROUTER_LINKSYS_EA6350 0xf41b
729
730#define ROUTER_NETGEAR_R7500 0xf50e
731
732#define ROUTER_NETGEAR_R7500V2 0xf50f
733
734#define ROUTER_LINKSYS_EA8500 0xf60e
735
736#define ROUTER_TRENDNET_TEW827 0xf701
737
738#define ROUTER_NETGEAR_R8500 0xf81a
739
740#define ROUTER_UBNT_UAPAC 0xf912
741
742#define ROUTER_ASUS_AC1200 0xfa15
743
744#define ROUTER_NETGEAR_R7800 0xfb0e
745
746#define ROUTER_NETGEAR_R6400 0xfc15
747
748#define ROUTER_ASUS_AC3100 0xfd1b
749
750#define ROUTER_ASROCK_G10 0xfe01
751
752#define ROUTER_TPLINK_ARCHERC3150 0xff111
753
754#define ROUTER_NETGEAR_R9000 0x100111
755
756#define ROUTER_WRT_3200ACM 0x101101
757
758#define ROUTER_DIR882 0x10210f  // 15 reset button, 7 outer button 18. mid button
759
760#define NVROUTER "DD_BOARD"
761
762static inline int startswith(char *source, char *cmp)
763{
764        return !strncmp(source, cmp, strlen(cmp));
765}
766
767typedef struct {
768        char *tz_name;
769        const char *tz_string;
770} TIMEZONE_TO_TZSTRING;
771
772extern void update_timezone(void);
773extern TIMEZONE_TO_TZSTRING allTimezones[];
774
775extern char *getBridge(char *ifname, char *word);
776extern char *getRealBridge(char *ifname, char *word);
777extern char *getWDSSTA(void);
778extern char *getSTA(void);
779extern char *getWET(void);
780extern int wanChanged(void);
781extern void notifywanChange(void);
782extern int contains(const char *string, char value);
783extern int getcpurev(void);
784extern int nvram_used(int *space);
785extern int cpu_plltype(void);
786extern int check_vlan_support(void);
787
788extern int remove_from_list(const char *name, char *list, int listsize);
789extern int add_to_list(const char *name, char *list, int listsize);
790extern char *find_in_list(const char *haystack, const char *needle);
791extern int startswith(char *source, char *cmp);
792extern int count_occurences(char *source, int cmp);
793extern int pos_nthoccurence(char *source, int cmp, int which);
794extern char *substring(int start, int stop, const char *src, char *dst);
795extern void strtrim_right(char *p, int c);
796extern unsigned int daysformonth(unsigned int month, unsigned int year);
797const char *getifaddr(char *ifname, int family, int linklocal);
798extern int weekday(int month, int day, int year);
799extern int getRouterBrand(void);
800extern char *getRouter(void);
801extern int diag_led(int type, int act);
802extern int C_led(int i);
803extern int get_single_ip(char *ipaddr, int which);
804extern char *get_mac_from_ip(char *mac, char *ip);
805extern struct dns_lists *get_dns_list(void);
806extern int dns_to_resolv(void);
807extern char *get_wan_face(void);
808
809extern int check_wan_link(int num);
810extern char *get_wan_ipaddr(void);
811extern char *get_complete_ip(char *from, char *to);
812extern char *get_complete_lan_ip(char *ip);
813extern int get_int_len(int num);
814extern int file_to_buf(char *path, char *buf, int len);
815extern int buf_to_file(char *path, char *buf);
816extern pid_t *find_pid_by_name(char *pidName);
817extern int find_pid_by_ps(char *pidName);
818extern int *find_all_pid_by_ps(char *pidName);
819extern char *find_name_by_proc(int pid);
820extern int get_ppp_pid(char *file);
821extern int convert_ver(char *ver);
822extern int check_flash(void);
823extern int check_action(void);
824extern int check_now_boot(void);
825extern int check_hw_type(void);
826extern int is_exist(char *filename);
827extern void set_ip_forward(char c);
828struct mtu_lists *get_mtu(char *proto);
829extern void set_host_domain_name(void);
830
831extern void encode(char *buf, int len);
832extern void decode(char *buf, int len);
833#define MD5_OUT_BUFSIZE 36
834extern char *zencrypt(char *passwd, char *passout);
835
836extern void getLANMac(char *newmac);
837extern void getWirelessMac(char *newmac, int instance);
838extern void getWANMac(char *newmac);
839extern char *cpustring(void);
840extern int isap8x(void);
841extern int led_control(int type, int act);
842enum { LED_POWER, LED_DIAG, LED_DIAG_DISABLED, LED_DMZ, LED_CONNECTED, LED_DISCONNECTED, LED_BRIDGE, LED_VPN,
843        LED_SES, LED_SES2, LED_WLAN, LED_WLAN0, LED_WLAN1, LED_WLAN2, LED_USB, LED_USB1, LED_SEC0, LED_SEC1, USB_POWER, USB_POWER1, BEEPER
844};
845enum { LED_ON, LED_OFF, LED_FLASH };
846
847#ifdef CDEBUG
848extern int mcoreleft(void);
849extern int coreleft(void);
850static void cdebug(char *function)
851{
852        // FILE *in = fopen ("/tmp/console.log", "a");
853        fprintf(stderr, "free ram in %s = %d (malloc %d)\n", function, coreleft(), mcoreleft());
854        // fclose (in);
855}
856
857#else
858#define cdebug(a)
859#endif
860extern int first_time(void);
861
862extern int set_register_value(unsigned short port_addr, unsigned short option_content);
863extern unsigned int get_register_value(unsigned short id, unsigned short num);
864// extern int sys_netdev_ioctl(int family, int socket, char *if_name, int
865// cmd, struct ifreq *ifr);
866
867int ct_openlog(const char *ident, int option, int facility, char *log_name);
868void ct_syslog(int level, int enable, const char *fmt, ...);
869void ct_logger(int level, const char *fmt, ...);
870struct wl_assoc_mac *get_wl_assoc_mac(int instance, int *c);
871
872extern struct detect_wans *detect_protocol(char *wan_face, char *lan_face, char *type);
873
874enum { WL = 0,
875        DIAG = 1,
876        // SES_LED1 = 2,
877        // SES_LED2 = 3,
878        SES_BUTTON = 4,
879        DMZ = 7
880};
881
882enum { START_LED, STOP_LED, MALFUNCTION_LED };
883
884typedef enum { ACT_IDLE,
885        ACT_TFTP_UPGRADE,
886        ACT_WEB_UPGRADE,
887#ifdef HAVE_HTTPS
888        ACT_WEBS_UPGRADE,
889#endif
890        ACT_SW_RESTORE,
891        ACT_HW_RESTORE,
892        ACT_ERASE_NVRAM,
893        ACT_NVRAM_COMMIT,
894        ACT_UNKNOWN
895} WEBACTION;
896
897enum { UNKNOWN_BOOT = -1, PMON_BOOT, CFE_BOOT };
898
899enum { BCM4702_CHIP, BCM4712_CHIP, BCM5325E_CHIP, BCM5350_CHIP, BCM5365_CHIP,
900        BCM4704_BCM5325F_CHIP,
901        BCM5352E_CHIP, BCM4712_BCM5325E_CHIP, BCM4704_BCM5325F_EWC_CHIP,
902        BCM4705_BCM5397_EWC_CHIP, BCM5354G_CHIP, BCM4705L_BCM5325E_EWC_CHIP,
903        BCM4705G_BCM5395S_EWC_CHIP,
904        NO_DEFINE_CHIP
905};
906
907enum { FIRST, SECOND };
908
909enum { SYSLOG_LOG = 1, SYSLOG_DEBUG, CONSOLE_ONLY, LOG_CONSOLE, DEBUG_CONSOLE };
910
911#define ACTION(cmd)     buf_to_file(ACTION_FILE, cmd)
912
913struct dns_lists {
914        int num_servers;
915        char dns_server[4][20];
916};
917
918#define NOT_USING       0
919#define USING           1
920
921struct wl_assoc_mac {
922        char mac[18];
923};
924
925struct nvram_param {
926        char *name;
927        char *value;
928};
929
930struct mtu_lists {
931        char *proto;            /* protocol */
932        char *min;              /* min mtu */
933        char *max;              /* max mtu */
934};
935
936struct detect_wans {
937        int proto;
938        int count;
939        char *name;
940        char desc[1024];
941};
942
943#define GIF_LINKLOCAL  0x0001   /* return link-local addr */
944#define GIF_PREFIXLEN  0x0002   /* return addr & prefix */
945
946#define PROTO_DHCP      0
947#define PROTO_STATIC    1
948#define PROTO_PPPOE     2
949#define PROTO_PPTP      3
950#define PROTO_L2TP      4
951#define PROTO_HB        5
952#define PROTO_ERROR     -1
953
954#define PPP_PSEUDO_IP   "10.64.64.64"
955#define PPP_PSEUDO_NM   "255.255.255.255"
956#define PPP_PSEUDO_GW   "10.112.112.112"
957
958#define PING_TMP        "/tmp/ping.log"
959// #define TRACEROUTE_TMP "/tmp/traceroute.log"
960
961#define RESOLV_FILE     "/tmp/resolv.conf"
962#define RESOLV_FORW     "/tmp/resolv.dnsmasq"
963#define HOSTS_FILE      "/tmp/hosts"
964
965#define LOG_FILE        "/var/log/mess"
966
967#define ACTION_FILE     "/tmp/action"
968
969#define split(word, wordlist, next, delim) \
970        for (next = wordlist, \
971             strncpy(word, next, sizeof(word)), \
972             word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
973             next = next ? next + sizeof(delim) - 1 : NULL ; \
974             strlen(word); \
975             next = next ? : "", \
976             strncpy(word, next, sizeof(word)), \
977             word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
978             next = next ? next + sizeof(delim) - 1 : NULL)
979
980#define STRUCT_LEN(name)    sizeof(name)/sizeof(name[0])
981
982#define printHEX(str,len) { \
983        int i; \
984        for (i=0 ; i<len ; i++) { \
985                printf("%02X ", (unsigned char)*(str+i)); \
986                if(((i+1)%16) == 0) printf("- "); \
987                if(((i+1)%32) == 0) printf("\n"); \
988        } \
989        printf("\n\n"); \
990}
991
992#define printASC(str,len) { \
993        int i; \
994        for (i=0 ; i<len ; i++) { \
995                printf("%c", (unsigned char)*(str+i)); \
996                if(((i+1)%16) == 0) printf("- "); \
997                if(((i+1)%32) == 0) printf("\n"); \
998        } \
999        printf("\n\n"); \
1000}
1001
1002void set_gpio(int gpio, int value);
1003
1004int get_gpio(int gpio);
1005
1006#ifdef HAVE_OLED
1007void lcdmessage(char *message);
1008void initlcd(void);
1009void lcdmessaged(char *dual, char *message);
1010#else
1011#define initlcd()
1012#define lcdmessage(a)
1013#define lcdmessaged(a,b)
1014#endif
1015
1016extern char *getBridgeMTU(const char *, char *word);
1017extern char *getMTU(char *);
1018extern int getBridgeSTP(char *br);
1019extern char *get_NFServiceMark(char *service, uint32 mark);
1020
1021#ifdef HAVE_SVQOS
1022char *qos_nfmark(uint32 x);
1023
1024#if !defined(ARCH_broadcom) || defined(HAVE_BCMMODERN)
1025extern char *get_tcfmark(uint32 mark);
1026#endif
1027
1028extern char *get_wshaper_dev(void);
1029extern char *get_mtu_val(char *buf);
1030extern void add_client_dev_srvfilter(char *name, char *type, char *data, char *level, int base, char *chain);
1031extern void add_client_mac_srvfilter(char *name, char *type, char *data, char *level, int base, char *client);
1032extern void add_client_ip_srvfilter(char *name, char *type, char *data, char *level, int base, char *client);
1033#ifdef HAVE_AQOS
1034extern void add_usermac(char *mac, int idx, char *upstream, char *downstream, char *lanstream);
1035extern void add_userip(char *ip, int idx, char *upstream, char *downstream, char *lanstream);
1036extern void add_client_classes(unsigned int base, unsigned int uprate, unsigned int downrate, unsigned int lanrate, unsigned int level);
1037#else
1038extern void add_client_classes(unsigned int base, unsigned int level);
1039#endif
1040#endif
1041
1042void getHostName(char *buf, char *ip);
1043int ishexit(char c);
1044int haswifi(void);
1045int sv_valid_hwaddr(char *value);
1046int sv_valid_ipaddr(char *value);
1047int sv_valid_range(char *value, int low, int high);
1048int sv_valid_statics(char *value);
1049void get_network(char *ipaddr, char *netmask);
1050int isbridge(char *name);
1051int get_net(char *netmask);
1052void get_broadcast(char *ipaddr, char *netmask);
1053int route_manip(int cmd, char *name, int metric, char *dst, char *gateway, char *genmask);
1054int route_add(char *name, int metric, char *dst, char *gateway, char *genmask);
1055int route_del(char *name, int metric, char *dst, char *gateway, char *genmask);
1056extern char *psname(int pid, char *buffer, int maxlen);
1057extern int pidof(const char *name);
1058extern int killall(const char *name, int sig);
1059extern int getifcount(const char *ifprefix);
1060extern int getIfList(char *buffer, const char *ifprefix);
1061extern int getIfListB(char *buffer, const char *ifprefix, int bridgesonly,int nosort);
1062extern void getIfLists(char *eths, int size);
1063extern int ifexists(const char *ifname);
1064extern void getinterfacelist(const char *ifprefix, char *buffer);
1065extern int count_processes(char *pidName);
1066#ifdef HAVE_ATH5K
1067extern int is_ath5k(const char *prefix);
1068#else
1069#define is_ath5k(prefix) 0
1070#endif
1071#ifdef HAVE_WIL6210
1072int is_wil6210(const char *prefix);
1073#else
1074#define is_wil6210(prefix) 0
1075#endif
1076
1077#ifdef HAVE_ATH9K
1078extern int is_ath9k(const char *prefix);
1079extern int has_spectralscanning(const char *prefix);
1080extern int getath9kdevicecount(void);
1081#else
1082#define has_spectralscanning(prefix) 0
1083#endif
1084#ifdef HAVE_ATH10K
1085extern int is_ath10k(const char *prefix);
1086#endif
1087#ifdef HAVE_MVEBU
1088extern int is_mvebu(const char *prefix);
1089#else
1090#define is_mvebu(prefix) 0
1091#endif
1092extern char *get3GDeviceVendor(void);
1093
1094int isGrep(char *string, char *cmp);
1095int softkill(char *name);
1096
1097int getmask(char *netmask);
1098int doMultiCast(void);
1099int getMTD(char *name);
1100void getIPFromName(char *name, char *ip);
1101
1102#define DEFAULT_USER "bJ/GddyoJuiU2"
1103#define DEFAULT_PASS "bJz7PcC1rCRJQ"
1104
1105#define MAX_WDS_DEVS 10
1106
1107#define OLD_NAME_IP     "/tmp/.old_name_ip"
1108
1109#ifndef MAX_LEASES
1110#define MAX_LEASES 254
1111#endif
1112
1113struct wl_client_mac {
1114        char hostname[32];
1115        char ipaddr[20];
1116        char hwaddr[20];
1117        int status;             // 0:offline 1:online
1118        int check;
1119};
1120#include <time.h>
1121
1122extern int dd_timer_delete(timer_t timer);
1123extern int dd_timer_create(clockid_t clock_id, struct sigevent *evp, timer_t * pTimer);
1124extern int dd_timer_connect(timer_t timerid, void (*routine) (timer_t, int), int arg);
1125extern int dd_timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
1126
1127int endswith(char *str, char *cmp);
1128char *getdisc(void);
1129int isListed(char *listname, char *value);
1130void addList(char *listname, char *value);
1131int searchfor(FILE * fp, char *str, int scansize);
1132int insmod(char *module);
1133void rmmod(char *module);
1134
1135int writeint(char *path, int a);
1136int writestr(char *path, char *a);
1137
1138int nvram_backup(char *filename);
1139
1140
1141int nvram_restore(char *filename);
1142
1143void nvram_clear(void);
1144int nvram_critical(char *name);
1145void getSystemMac(char *mac);
1146
1147int do80211priv(const char *ifname, int op, void *data, size_t len);
1148int getsocket(void);
1149void closesocket(void);
1150int isEMP(char *ifname);
1151int isXR36(char *ifname);
1152int isFXXN_PRO(char *ifname);
1153char *get3GControlDevice(void);
1154int mac80211_get_maxmcs(char *interface);
1155int mac80211_get_maxvhtmcs(char *interface);
1156int get_ath9k_phy_idx(int idx);
1157int get_ath9k_phy_ifname(const char *ifname);
1158
1159char *getWifiDeviceName(char *prefix);
1160
1161void getPortMapping(int *vlanmap);
1162
1163u_int64_t freediskSpace(char *path);
1164
1165char *getIsoName(const char *country);
1166int has_gateway(void);          // return 1 if nat/gateway mode is enabled for wan
1167#if defined(HAVE_RT2880) || defined(HAVE_RT61)
1168char *getRADev(char *prefix);
1169#endif
1170
1171#ifndef HAVE_SYSLOG
1172#define dd_syslog(a, args...) do { } while(0);
1173#else
1174#define dd_syslog(a, args...) syslog( a,## args);
1175#endif
1176#endif
1177
1178void *getUEnv(char *name);
1179
1180/* gartarp */
1181
1182#ifndef unlikely
1183#define unlikely(x)     __builtin_expect((x), 0)
1184#endif
1185
1186#define IP_ALEN         4
1187
1188/*
1189struct arph {
1190        uint16_t hw_type;
1191
1192        #define ARPOP_BROADCAST         1
1193        #define ARPHDR_ETHER            1
1194        uint16_t proto_type;
1195
1196        char ha_len;
1197        char pa_len;
1198        uint16_t opcode;
1199        char source_add[ETH_ALEN];
1200        char source_ip[IP_ALEN];
1201        char dest_add[ETH_ALEN];
1202        char dest_ip[IP_ALEN];
1203
1204} __attribute__((packed));
1205*/
1206
1207#define ARP_HLEN        sizeof(struct arph) + ETH_HLEN
1208#define BCAST           "\xff\xff\xff\xff\xff\xff"
1209
1210int gratarp_main(char *iface);
1211
1212int writeproc(char *path, char *value);
1213int writeprocsysnet(char *path, char *value);
1214int writeprocsys(char *path, char *value);
1215
1216void set_smp_affinity(int irq, int cpu);
1217
1218int writevaproc(char *value, char *fmt, ...);
Note: See TracBrowser for help on using the repository browser.