1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <signal.h>
5#include <fcntl.h>
6#include <netinet/in.h>
7#include <sys/types.h>
8#include <sys/socket.h>
9#include <net/if.h>
10#include <bcmnvram.h>
11#include <shutils.h>
12#include <wlutils.h>
13#include <syslog.h>
14#include "iboxcom.h"
15
16#include <endian.h>
17#if __BYTE_ORDER == __BIG_ENDIAN
18#include <linux/byteorder/big_endian.h>
19#elif __BYTE_ORDER == __LITTLE_ENDIAN
20#include <linux/byteorder/little_endian.h>
21#else
22#error Unknown endian
23#endif
24
25int getStorageStatus(STORAGE_INFO_T *st)
26{
27	memset(st, sizeof(st), 0);
28
29	st->AppHttpPort = __cpu_to_le16(nvram_get_int("dm_http_port"));
30
31	/*
32	if(nvram_get_int("sw_mode")!=SW_MODE_ROUTER) {
33		return 0;
34	}
35	*/
36
37	st->MagicWord = __cpu_to_le16(EXTEND_MAGIC);
38	st->AppAPILevel = EXTEND_API_LEVEL;
39	st->ExtendCap = 0;
40
41#ifdef RTCONFIG_WEBDAV
42	st->ExtendCap |= __cpu_to_le16(EXTEND_CAP_WEBDAV);
43#else
44	st->ExtendCap = 0;
45	if(check_if_file_exist("/opt/etc/init.d/S50aicloud"))
46		st->ExtendCap |= __cpu_to_le16(EXTEND_CAP_WEBDAV);
47#endif
48
49
50#ifdef RTCONFIG_TUNNEL
51	st->ExtendCap |= __cpu_to_le16(EXTEND_CAP_AAE_BASIC);
52#endif
53
54	st->ExtendCap |= __cpu_to_le16(EXTEND_CAP_SWCTRL);
55
56	if(nvram_get_int("enable_webdav"))
57		st->u.wt.EnableWebDav = 1;
58	else
59		st->u.wt.EnableWebDav = 0;
60
61	st->u.wt.HttpType = nvram_get_int("st_webdav_mode");
62	st->u.wt.HttpPort = htons(nvram_get_int("webdav_http_port"));
63	st->u.wt.HttpsPort = htons(nvram_get_int("webdav_https_port"));
64
65	if(nvram_get_int("ddns_enable_x")) {
66		st->u.wt.EnableDDNS = 1;
67		snprintf(st->u.wt.HostName, sizeof(st->u.wt.HostName), nvram_safe_get("ddns_hostname_x"));
68	}
69	else {
70		st->u.wt.EnableDDNS = 0;
71	}
72
73	st->u.dev.sw.AiHOMEAPILevel = EXTEND_AIHOME_API_LEVEL;
74
75	// setup st->u.WANIPAddr
76	st->u.wt.WANIPAddr = __cpu_to_le32(inet_network(get_wanip()));
77
78	st->u.wt.isNotDefault = nvram_get_int("x_Setting");
79
80
81#ifdef RTCONFIG_TUNNEL
82	if(nvram_get_int("aae_enable"))
83	{
84		st->EnableAAE = 1;
85		const char* tnl_devid = nvram_get("aae_deviceid");
86		if(tnl_devid) {
87			strcpy(st->AAEDeviceID, tnl_devid);
88			printf("AAE DeviceID =%s <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", st->AAEDeviceID);
89		}
90	}
91#endif
92
93
94	return 0;
95}
96
97
98