diff -urN ./uClinux-dist/user/busybox/init/halt.c ./busybox/init/halt.c --- ./uClinux-dist/user/busybox/init/halt.c 2009-08-25 13:44:18.000000000 +0900 +++ ./busybox/init/halt.c 2009-12-17 11:25:13.279830000 +0900 @@ -35,7 +35,7 @@ #ifdef CONFIG_USER_FLATFSD_FLATFSD static const char *flatfsd[] = { "exec /bin/flatfsd -H", - "exec /bin/flatfsd -P", + "exec /bin/flatfsd -H", "exec /bin/flatfsd -b", }; #endif diff -urN ./uClinux-dist/user/busybox/install-romfs.sh ./busybox/install-romfs.sh --- ./uClinux-dist/user/busybox/install-romfs.sh 2010-03-24 13:17:43.000000000 +0900 +++ ./busybox/install-romfs.sh 2009-12-17 11:25:13.279830000 +0900 @@ -78,7 +78,4 @@ fi done -romfs-inst.sh -e CONFIG_USER_BUSYBOX_TELNETD \ - -a "telnet stream tcp nowait root /bin/telnetd telnetd" /etc/inetd.conf - exit 0 diff -urN ./uClinux-dist/user/busybox/loginutils/login.c ./busybox/loginutils/login.c --- ./uClinux-dist/user/busybox/loginutils/login.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/loginutils/login.c 2010-09-08 02:46:40.110008000 +0900 @@ -284,6 +284,9 @@ short_tty = full_tty + 5; } + if (strncmp(short_tty, "ttyS", 4) == 0) + alarm(0); + read_or_build_utent(&utent, !amroot); if (opt & LOGIN_OPT_h) { diff -urN ./uClinux-dist/user/busybox/Makefile ./busybox/Makefile --- ./uClinux-dist/user/busybox/Makefile 2009-05-22 13:09:35.000000000 +0900 +++ ./busybox/Makefile 2010-12-20 15:21:10.960652000 +0900 @@ -307,6 +307,36 @@ LDFLAGS := $(LDFLAGS) LDLIBS := +## +ifeq ("$(CONFIG_PRODUCT_NAME_IMW_C615W)", "y") +CFLAGS += -DISPOT_RESTRICT +endif + + +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C600W) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C610W) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C620W) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C210W) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C230W) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_M2M) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C710) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_V100) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_KTEGG) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C210) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C220) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C230) += "y" +RANDOM_LEASE_$(CONFIG_PRODUCT_NAME_IMW_C260) += "y" +ifdef RANDOM_LEASE_y +CFLAGS += -DRANDOM_LEASE +endif + + +## defined in $(ROOTDIR)/user/Makefile +ifdef DISABLE_TELNETD_y +CFLAGS += -DDISABLE_TELNETD +endif +## + # Read KERNELRELEASE from .kernelrelease (if it exists) KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) @@ -556,6 +586,24 @@ libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) libs-y := $(libs-y1) $(libs-y2) + +## +## MMC +## +ifdef CONFIG_USE_MMC_WIFI +CFLAGS += -DUSE_MMC_WIFI +endif + +## +## ATA +## +ifdef CONFIG_PRODUCT_NAME_IMW_V100 +CFLAGS += -DUSE_ATA +endif + + + + # Build busybox # --------------------------------------------------------------------------- # busybox is build from the objects selected by $(busybox-init) and diff -urN ./uClinux-dist/user/busybox/networking/brctl.c ./busybox/networking/brctl.c --- ./uClinux-dist/user/busybox/networking/brctl.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/brctl.c 2010-03-25 21:14:08.008741000 +0900 @@ -40,8 +40,9 @@ { double secs; #if BRCTL_USE_INTERNAL - secs = /*bb_*/strtod(time_str, NULL); - if (!secs) + char *endptr; + secs = /*bb_*/strtod(time_str, &endptr); + if (endptr == time_str) #else if (sscanf(time_str, "%lf", &secs) != 1) #endif diff -urN ./uClinux-dist/user/busybox/networking/telnetd.c ./busybox/networking/telnetd.c --- ./uClinux-dist/user/busybox/networking/telnetd.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/telnetd.c 2010-12-20 15:21:10.960652000 +0900 @@ -375,6 +375,12 @@ portnbr = 23, }; #endif + +//khj +#ifdef DISABLE_TELNETD + return 0; +#endif + /* Even if !STANDALONE, we accept (and ignore) -i, thus people * don't need to guess whether it's ok to pass -i to us */ opt = getopt32(argv, "f:l:Ki" USE_FEATURE_TELNETD_STANDALONE("p:b:F"), diff -urN ./uClinux-dist/user/busybox/networking/udhcp/dhcpd.c ./busybox/networking/udhcp/dhcpd.c --- ./uClinux-dist/user/busybox/networking/udhcp/dhcpd.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/udhcp/dhcpd.c 2010-12-06 17:54:30.070749000 +0900 @@ -9,7 +9,7 @@ * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ - +#include #include #include "common.h" #include "dhcpc.h" @@ -22,6 +22,11 @@ /* struct server_config_t server_config is in bb_common_bufsiz1 */ +#ifdef RANDOM_LEASE +uint32_t *random_addr_pool = NULL; +#endif + + int udhcpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int udhcpd_main(int argc ATTRIBUTE_UNUSED, char **argv) { @@ -36,6 +41,7 @@ unsigned opt; struct option_set *option; struct dhcpOfferedAddr *lease, static_lease; + USE_FEATURE_UDHCP_PORT(char *str_P;) #if ENABLE_FEATURE_UDHCP_PORT @@ -84,16 +90,46 @@ } /* Sanity check */ - num_ips = server_config.end_ip - server_config.start_ip + 1; + num_ips = server_config.end_ip - server_config.start_ip + 1; + + // + // hjkoh: num_ips add static leases + // + { + struct static_lease *cur = server_config.static_leases; + uint8_t start_num, end_num, cur_num; + + start_num = server_config.start_ip & 0xFF; + end_num = server_config.end_ip & 0xFF; + + while (cur) { + cur_num = *(cur->ip) & 0xFF; + if( cur_num < start_num || cur_num > end_num ) + num_ips ++; + cur = cur->next; + } + } + if (server_config.max_leases > num_ips) { bb_error_msg("max_leases=%u is too big, setting to %u", (unsigned)server_config.max_leases, num_ips); server_config.max_leases = num_ips; } + +#ifdef ISPOT_RESTRICT + idev_init (); + // overriding udhcpd.conf + server_config.auto_time = 1; // 60 seconds + server_config.lease = 2*60*60; // 2 hours + // server_config.lease = 4*60; // 4 minuites +#endif leases = xzalloc(server_config.max_leases * sizeof(*leases)); read_leases(server_config.lease_file); +#ifdef ISPOT_RESTRICT + idev_check_devices (1); +#endif if (read_interface(server_config.interface, &server_config.ifindex, &server_config.server, server_config.arp)) { retval = 1; @@ -103,9 +139,17 @@ /* Setup the signal pipe */ udhcp_sp_setup(); + +#ifdef RANDOM_LEASE + // khj : create random pool + init_random_addr_pool(); +#endif // ifdef RANDOM_LEASE + + + + timeout_end = monotonic_sec() + server_config.auto_time; while (1) { /* loop until universe collapses */ - if (server_socket < 0) { server_socket = listen_socket(/*INADDR_ANY,*/ SERVER_PORT, server_config.interface); @@ -122,6 +166,9 @@ server_config.auto_time ? &tv : NULL); } if (retval == 0) { +#ifdef ISPOT_RESTRICT + idev_check_devices (0); // -sdongs- +#endif write_leases(); timeout_end = monotonic_sec() + server_config.auto_time; continue; @@ -236,6 +283,8 @@ || r > server_config.end_ip ) { sendNAK(&packet); + } else { + sendNAK(&packet); // -sdongs- } /* else remain silent */ } @@ -248,13 +297,13 @@ DEBUG("Received DECLINE"); if (lease) { memset(lease->chaddr, 0, 16); - lease->expires = time(0) + server_config.decline_time; + lease->expires = monotonic_sec() + server_config.decline_time; } break; case DHCPRELEASE: DEBUG("Received RELEASE"); if (lease) - lease->expires = time(0); + lease->expires = monotonic_sec(); break; case DHCPINFORM: DEBUG("Received INFORM"); @@ -264,6 +313,9 @@ bb_info_msg("Unsupported DHCP message (%02x) - ignoring", state[0]); } } +#ifdef RANDOM_LEASE + free( random_addr_pool ); +#endif // ifdef RANDOM_LEASE ret0: retval = 0; ret: diff -urN ./uClinux-dist/user/busybox/networking/udhcp/dhcpd.h ./busybox/networking/udhcp/dhcpd.h --- ./uClinux-dist/user/busybox/networking/udhcp/dhcpd.h 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/udhcp/dhcpd.h 2010-12-06 17:54:30.070749000 +0900 @@ -76,13 +76,25 @@ uint8_t chaddr[16]; uint32_t yiaddr; /* network order */ uint32_t expires; /* host order */ + uint32_t flags; /* -sdongs- for iDevice detection */ }; -struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease); +struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease, int idev); int lease_expired(struct dhcpOfferedAddr *lease); struct dhcpOfferedAddr *find_lease_by_chaddr(const uint8_t *chaddr); struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr); uint32_t find_address(int check_expired); +// -sdongs- +int idev_add_device (uint8_t *mac, uint32_t yiaddr); +int idev_check_devices (int r); +int idev_check_packet (struct dhcpMessage *packet, uint32_t yiaddr); + +// khj +#ifdef RANDOM_LEASE +extern uint32_t *random_addr_pool; +int shuffle_addr_pool( void ); +int init_random_addr_pool( void ); +#endif /*** static_leases.h ***/ diff -urN ./uClinux-dist/user/busybox/networking/udhcp/files.c ./busybox/networking/udhcp/files.c --- ./uClinux-dist/user/busybox/networking/udhcp/files.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/udhcp/files.c 2010-09-30 13:44:21.422575000 +0900 @@ -5,6 +5,7 @@ */ #include +#include #include "common.h" #include "dhcpd.h" @@ -366,7 +367,7 @@ { int fp; unsigned i; - time_t curr = time(0); + time_t curr = monotonic_sec(); unsigned long tmp_time; fp = open_or_warn(server_config.lease_file, O_WRONLY|O_CREAT|O_TRUNC); @@ -422,11 +423,17 @@ if (y >= server_config.start_ip && y <= server_config.end_ip) { lease.expires = ntohl(lease.expires); if (!server_config.remaining) - lease.expires -= time(0); - if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) { + lease.expires -= monotonic_sec(); + if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires, lease.flags))) { bb_error_msg("too many leases while loading %s", file); break; } +#ifdef ISPOT_RESTRICT + else { + if (lease.flags) + idev_add_device (lease.chaddr, lease.yiaddr); + } +#endif i++; } } diff -urN ./uClinux-dist/user/busybox/networking/udhcp/leases.c ./busybox/networking/udhcp/leases.c --- ./uClinux-dist/user/busybox/networking/udhcp/leases.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/udhcp/leases.c 2010-12-06 17:54:30.070749000 +0900 @@ -3,17 +3,17 @@ * leases.c -- tools to manage DHCP leases * Russ Dill July 2001 */ - +#include #include "common.h" #include "dhcpd.h" - +#include "options.h" /* Find the oldest expired lease, NULL if there are no expired leases */ static struct dhcpOfferedAddr *oldest_expired_lease(void) { struct dhcpOfferedAddr *oldest = NULL; // TODO: use monotonic_sec() - unsigned long oldest_lease = time(0); + unsigned long oldest_lease = monotonic_sec(); unsigned i; for (i = 0; i < server_config.max_leases; i++) @@ -43,7 +43,7 @@ /* add a lease into the table, clearing out any old ones */ -struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease) +struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease, int idev) { struct dhcpOfferedAddr *oldest; @@ -55,7 +55,8 @@ if (oldest) { memcpy(oldest->chaddr, chaddr, 16); oldest->yiaddr = yiaddr; - oldest->expires = time(0) + lease; + oldest->expires = monotonic_sec() + lease; + oldest->flags = idev; } return oldest; @@ -65,7 +66,7 @@ /* true if a lease has expired */ int lease_expired(struct dhcpOfferedAddr *lease) { - return (lease->expires < (unsigned long) time(0)); + return (lease->expires < (unsigned long) monotonic_sec()); } @@ -112,20 +113,31 @@ temp.s_addr = addr; bb_info_msg("%s belongs to someone, reserving it for %u seconds", inet_ntoa(temp), (unsigned)server_config.conflict_time); - add_lease(blank_chaddr, addr, server_config.conflict_time); + add_lease(blank_chaddr, addr, server_config.conflict_time, 0 /* flags */); return 0; } /* find an assignable address, if check_expired is true, we check all the expired leases as well. * Maybe this should try expired leases by age... */ + uint32_t find_address(int check_expired) { uint32_t addr, ret; struct dhcpOfferedAddr *lease = NULL; +#ifdef RANDOM_LEASE + int i; + shuffle_addr_pool(); + for( i = 0 ; i < server_config.max_leases ; i++) + { + addr = random_addr_pool[i]; +#else addr = server_config.start_ip; /* addr is in host order here */ - for (; addr <= server_config.end_ip; addr++) { + for (; addr <= server_config.end_ip; addr++) + { +#endif // ifdef RANDOM_LEASE + /* ie, 192.168.55.0 */ if (!(addr & 0xFF)) continue; @@ -145,5 +157,700 @@ } } } + return 0; } + + + + + + + + +#ifdef ISPOT_RESTRICT +#include +#include +#include +#include + +#define RESTRICT_TREE_CONF_FILE "/var/config/restrict_tree.conf" +#define RESTRICT_CONF_FILE "/var/config/restrict.conf" +#define ALLOW_IP_CONF "/var/config/allow_ip.conf" +#define SH_NAT_CONFIG "/etc/init.d/script/nat_conf.sh restrict > /dev/null" +#define APV_MAC_CONF "/var/config/apv_mac.conf" +#define MAX_HOTLINE_IP 16 + +#define IDEV_MAX_NUM 256 + +struct restrict_info { + char enable; + int maxnum; + char hotline_uri[1024]; + char hotline_ip[MAX_HOTLINE_IP][20]; + unsigned short hotline_port; +}; + +struct idev_lists { + unsigned char mac[6]; + unsigned int ip; + unsigned int time; +}; + +struct arp_lists { + unsigned char mac[6]; + unsigned int ip; +}; + +static struct idev_lists idev_list[IDEV_MAX_NUM+1]; +struct arp_lists arp_list[IDEV_MAX_NUM]; +static struct restrict_info info; +static unsigned int idev_list_index = 0; +static unsigned int idev_nat_setup = 0; +static unsigned int idev_hotline_setup = 0; +static unsigned int idev_url_setup = 0; + +unsigned int idev_if_addr (char *if_name) +{ + int fd, r; + struct ifreq ifr; + unsigned char *d; + struct sockaddr_in *p = (struct sockaddr_in *)&(ifr.ifr_addr);; + + fd = socket (AF_INET, SOCK_DGRAM, 0); + if (fd<0) + return 0; + + memset (&ifr, 0, sizeof (ifr)); + strcpy(ifr.ifr_name, if_name); + ifr.ifr_addr.sa_family = AF_INET; + + r = ioctl (fd, SIOCGIFADDR, &ifr); + + close (fd); + + return (unsigned int)p->sin_addr.s_addr; +} + +int util_parse_line( const char * str, char * prm, char * val ) +{ + char * p; + char * p1; + char * p2; + char quotes = 0; + + p = str; + p1 = prm; + p2 = val; + + *p1 = *p2 = '\0'; + while ( *p ) { + if( *p == '\n' )break; + if( *p == '\t' && ++p) continue; + if( *p != ' ' ) break; + p++; + } + + if( *p == '#' || *p == '\n') + return -1; + + while( *p ) { + if( *p == '\n' ) return -1; + if( *p == '=' ) break; + if( (*p == ' ' || *p == '\t') && ++p) continue; + *p1 = *p; + p1++;p++; + } + + if( *p != '=' ) return -1; + + *p1 = '\0'; + p++; + + while( *p ) { + if( *p == '\n' || *p == '#' ) break; + if( *p == '"' ) { + if(quotes == 1) break; + quotes = 1; + p++; + continue; + } + if( *p == ' ' && quotes == 0 && ++p) continue; + *p2 = *p; + p2++;p++; + } + *p2 = '\0'; + + if( strlen(prm) > 0 ) + return 0; + + return -1; +} + +int idev_arp_table (struct arp_lists *l) +{ + FILE *f; + int num, type, flags, i; + char line[128]; + char ip[128]; + char hwa[128]; + char mask[128]; + char dev[128]; + + f = fopen("/proc/net/arp", "r"); + if (f==NULL) return 0; + + fgets(line, sizeof(line), f); + + i = 0; + while (fgets(line, sizeof(line), f)) { + mask[0] = '-'; mask[1] = '\0'; + dev[0] = '-'; dev[1] = '\0'; + num = sscanf(line, "%s 0x%x 0x%x %s %s %s\n", + ip, &type, &flags, hwa, mask, dev); + if (num < 4) + break; + + if( flags == 2 && ih_addr_list; + if( addr_list[0] == NULL ) { + bb_info_msg ("[APP] gethostbyname Fail for Allow URI (%s)", url_list[i] ); + return -1; + } + for ( j = 0 ; addr_list[j] ; j++) { + p += sprintf( p, "%s ", inet_ntoa(*addr_list[j])); + bb_info_msg("[APP] URL=%s IP=%s", url_list[i], inet_ntoa(*addr_list[j])); + } + + ret++; + } + + if( ret == 0 ) + return -1; + + p += sprintf( p, "\"\n"); + + fp = fopen( ALLOW_IP_CONF, "w"); + + if( fp == NULL ) { + bb_info_msg ("[APP] File Open Error (%s)", ALLOW_IP_CONF ); + return -1; + } + + fprintf(fp, "%s", buf ); + fclose(fp); + + bb_info_msg ("[APP] Apply Allow IP"); + return 0; +} + + +static int idev_load_info (struct restrict_info *info) +{ + FILE *fp; + char buff[128] = {0,}; + char p1[128]; + char p2[128]; + int idx; + + if ( access ( RESTRICT_TREE_CONF_FILE, F_OK) < 0 ) { + bb_info_msg ("[APP] file not found(%s)", RESTRICT_TREE_CONF_FILE); + return 0; + } + + fp = fopen (RESTRICT_TREE_CONF_FILE, "r"); + if( fp == NULL ) + return 0; + + memset (info, 0, sizeof (struct restrict_info)); + while ( fgets( buff, 127, fp) != NULL ) { + if( util_parse_line(buff, p1, p2) == 0) { + if( strncmp(p1, "ENABLE_RESTRICT", strlen("ENABLE_RESTRICT")) == 0 ) + info->enable = atoi( p2 ); + else if( strncmp( p1, "MAX_NUM_DEVICE_RESTRICT", strlen("MAX_NUM_DEVICE_RESTRICT")) == 0) + info->maxnum = atoi( p2 ); + else if( strncmp( p1, "HOTLINE_URI", strlen("HOTLINE_URI")) == 0 ) + strcpy( info->hotline_uri, p2); + } + } + + fclose(fp); + + return 1; +} + +static int idev_init_nat(struct restrict_info *info) +{ + struct hostent * hotline; + struct in_addr **addr_list; + char * p; + FILE * fp; + char host[1024]; + struct default_oui_list * def_oui; + int i,k,n; + + if( info->enable == 0 ) { + bb_info_msg ("[APP] Enabled false. skip\n"); + if( access ( RESTRICT_CONF_FILE, F_OK) >= 0 ) { + unlink ( RESTRICT_CONF_FILE ); + sync (); + // system (SH_NAT_CONFIG); + // unlink (RESTRICT_TREE_CONF_FILE); + } + return 1; + } +#if 0 + if( strstr(info->hotline_uri, "http://") ) { + info->hotline_port = 80; + strcpy( host, info->hotline_uri + strlen("http://")); + } + else if ( strstr( info->hotline_uri, "https://") ) { + info->hotline_port = 443; + strcpy( host, info->hotline_uri + strlen("https://")); + } + else { + bb_info_msg ("[APP] BAD Restrict HotLine URI (%s)", info->hotline_uri ); + return 0; + } + + p = strchr( host , '/' ); + if( p ) + *p = '\0'; + + hotline = gethostbyname( host ); + if( hotline == NULL ) { + bb_info_msg ("[APP] gethostbyname Fail for Hotline URI (%s)", p ); + return 0; + } + addr_list = (struct in_addr **) hotline->h_addr_list; + if( addr_list[0] == NULL ) { + bb_info_msg ("[APP] gethostbyname Fail for Hotline URI (%s)", p ); + return 0; + } + strcpy( info->hotline_ip, inet_ntoa(*addr_list[0]) ); + + // Make allow ip conf file + if( apply_allow_url() != 0 ) + return 0; +#endif + // Make restrict conf file + fp = fopen ( RESTRICT_CONF_FILE, "w"); + if( fp == NULL ) { + bb_info_msg("[APP] File open Error(%s)", RESTRICT_CONF_FILE); + return 0; + } + + fprintf(fp, "\n\n"); + fprintf(fp, "ENABLE_RESTRICT=%d\n", info->enable); + fprintf(fp, "MAX_NUM_DEVICE_RESTRICT=%d\n", info->maxnum); + fprintf(fp, "HOTLINE_URI=%s\n", info->hotline_uri); + + // khj : support for multiple IP + if (strlen(info->hotline_ip[0]) > 0 ) + { + fprintf(fp, "HOTLINE_IP=\""); + for( i = 0 ; info->hotline_ip[i][0] ; i++) + fprintf(fp, "%s ", info->hotline_ip[i]); + fprintf(fp, "\"\n"); + } + + fprintf(fp, "HOTLINE_PORT=%d\n", info->hotline_port); + + fprintf(fp,"\n\n"); + fclose(fp); + + // system (SH_NAT_CONFIG); + // unlink (RESTRICT_TREE_CONF_FILE); + + bb_info_msg("[APP] Apply Restricted Mode"); + + return 1; +} + +static int idev_hotline_init (struct restrict_info *info) +{ + struct hostent * hotline; + struct in_addr **addr_list; + char *p; + int i; + char host[1024]; + + bb_info_msg ("[APP] idev_hotline_init (%s)", info->hotline_uri ); + + if( strstr(info->hotline_uri, "http://") ) { + info->hotline_port = 80; + strcpy( host, info->hotline_uri + strlen("http://")); + } + else if ( strstr( info->hotline_uri, "https://") ) { + info->hotline_port = 443; + strcpy( host, info->hotline_uri + strlen("https://")); + } + else { + bb_info_msg ("[APP] BAD Restrict HotLine URI (%s)", info->hotline_uri ); + return 0; + } + + p = strchr( host , '/' ); + if( p ) + *p = '\0'; + + hotline = gethostbyname( host ); + if( hotline == NULL ) { + bb_info_msg ("[APP] gethostbyname Fail for Hotline URI (%s)", p ); + return 0; + } + addr_list = (struct in_addr **) hotline->h_addr_list; + if( addr_list[0] == NULL ) { + bb_info_msg ("[APP] gethostbyname Fail for Hotline URI (%s)", p ); + return 0; + } + + // khj : support for multiple IP + memset( info->hotline_ip, 0, sizeof(info->hotline_ip)); + for( i = 0 ; addr_list[i]; i++) + { + strcpy( info->hotline_ip[i], inet_ntoa(*addr_list[i]) ); + bb_info_msg ("[APP] hotline ip = (%s)", info->hotline_ip[i] ); + } + + + return 1; +} + +static int idev_url_init (void) +{ + if (0==apply_allow_url ()) return 1; + + return 0; +} + +static void idev_dump_list (void) +{ + int i; + unsigned char mac0[6] = {0, }; + for (i=0; i=0) { + bb_info_msg ("DEL: %02x:%02x:%02x:%02x:%02x:%02x, %08x", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], yiaddr); + for (i=index; i=0 && idev_list[index].ip!=arp_list[i].ip) { + count_del++; + idev_del_device (idev_list[index].mac, idev_list[index].ip); + + } + } + return count_del; +} + +static int idev_nat_apply (struct restrict_info *info) +{ + FILE *fp; + struct in_addr iaddr; + int i, size, ip_addr; +#if 0 + ip_addr = idev_if_addr ("wimax"); + if (ip_addr==0) return; + iaddr.s_addr = ip_addr; +#endif + + fp = fopen( APV_MAC_CONF, "w"); + if( fp == NULL ) + return 0; + + size = (idev_list_indexmaxnum)? idev_list_index:info->maxnum; + fprintf( fp, "\n\n## APPROVED DEVICE LIST \n\n"); + for (i=0; i0) { + bb_info_msg("Expired: %02x:%02x:%02x:%02x:%02x:%02x", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + } + } + } + } + + idev_dump_list (); + + // DEL mac addresses with IPs not assigned by DHCP + // r += idev_check_arplist (); + + // First setup RestrictedUse + if (idev_nat_setup==0 || idev_hotline_setup==0 || idev_url_setup==0) { + if (0!=idev_if_addr ("wimax")) { + if (idev_load_info (&info)) { + if (idev_nat_setup==0) { + q = idev_init_nat (&info); + r += q; + if (q>0) { + idev_nat_setup = 1; + server_config.auto_time = 10; + } + } + if (idev_hotline_setup==0) { + q = idev_hotline_init (&info); + r += q; + if (q>0) { + idev_hotline_setup = 1; + idev_init_nat (&info); + } + } + if (idev_url_setup==0) { + q = idev_url_init (); + r += q; + if (q>0) { + idev_url_setup = 1; + } + } + if (r>0) idev_nat_apply (&info); + } + } + } + else { + // Check if anything changed with RestrictedUse + if (1==idev_load_info (&info_temp)) { + if (info_temp.enable!=info.enable || info_temp.maxnum!=info.maxnum || + 0!=strcmp (info_temp.hotline_uri, info.hotline_uri)) { + memcpy (&info, &info_temp, sizeof (info)); + r += idev_hotline_init (&info); + r += idev_init_nat (&info); + } + } + if (r>0) idev_nat_apply (&info); + } +} + +int idev_check_packet (struct dhcpMessage *packet, uint32_t yiaddr) +{ + int idev, r = 0; + uint8_t *mac = packet->chaddr;; + // if (yiaddr!=0) { //sendACK + idev = idev_check_allow (packet, yiaddr); + if (idev) + { + if( yiaddr != 0 ) + r += idev_add_device (mac, yiaddr); + } + else + r += idev_del_device (mac, yiaddr); + //} + //else { // sendNAK + // r += idev_del_device (mac, yiaddr); + //} + idev_check_devices (r); + + return idev; +} + +void idev_init (void) +{ + int i; + + idev_list_index = 0; + for (i=0; i<(IDEV_MAX_NUM+1); i++) + memset (&(idev_list[i]), 0, sizeof (struct idev_lists)); +} +#endif + +#ifdef RANDOM_LEASE +int init_random_addr_pool( void ) +{ + uint32_t addr; + int i; + + if( server_config.max_leases <= 0 ) + return -1; + + if ( random_addr_pool == NULL ) + random_addr_pool = xzalloc(server_config.max_leases * sizeof(uint32_t)); + + addr = server_config.start_ip; + for( i = 0 ; addr <= server_config.end_ip; addr++, i++) + { + random_addr_pool[i] = addr; + } + return 0; +} +int shuffle_addr_pool( void ) +{ + uint32_t addr; + int i; + + if ( random_addr_pool == NULL ) + return -1; + + + srand( (unsigned)time( NULL )); + if( server_config.max_leases >= 3 ) + { + int max = server_config.max_leases * 3; + int t1,t2; + for( i = 0 ; i < max ; i++) + { + t1 = rand() % server_config.max_leases; + t2 = rand() % server_config.max_leases; + + if( t1 != t2 ) + { + addr = random_addr_pool[t1]; + random_addr_pool[t1] = random_addr_pool[t2]; + random_addr_pool[t2] = addr; + } + } + } + + + + +} +#endif // #ifdef RANDOM_LEASE diff -urN ./uClinux-dist/user/busybox/networking/udhcp/serverpacket.c ./busybox/networking/udhcp/serverpacket.c --- ./uClinux-dist/user/busybox/networking/udhcp/serverpacket.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/udhcp/serverpacket.c 2010-09-30 13:44:21.422575000 +0900 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#include #include "common.h" #include "dhcpc.h" #include "dhcpd.h" @@ -121,7 +121,7 @@ lease = find_lease_by_chaddr(oldpacket->chaddr); if (lease) { if (!lease_expired(lease)) - lease_time_align = lease->expires - time(0); + lease_time_align = lease->expires - monotonic_sec(); packet.yiaddr = lease->yiaddr; /* Or the client has a requested ip */ } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) @@ -150,7 +150,7 @@ bb_error_msg("no IP addresses to give - OFFER abandoned"); return -1; } - if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) { + if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time, 0)) { bb_error_msg("lease pool is full - OFFER abandoned"); return -1; } @@ -190,17 +190,23 @@ int sendNAK(struct dhcpMessage *oldpacket) { + int ret; struct dhcpMessage packet; init_packet(&packet, oldpacket, DHCPNAK); - +#ifdef ISPOT_RESTRICT + idev_check_packet (oldpacket, 0); +#endif DEBUG("Sending NAK"); - return send_packet(&packet, 1); + ret = send_packet(&packet, 1); + + return ret; } int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) { + int idev = 0; struct dhcpMessage packet; struct option_set *curr; uint8_t *lease_time; @@ -233,16 +239,19 @@ addr.s_addr = packet.yiaddr; bb_info_msg("Sending ACK to %s", inet_ntoa(addr)); - +#ifdef ISPOT_RESTRICT + idev = idev_check_packet (oldpacket, yiaddr); // -sdongs- + send_packet(&packet, 0); +#else if (send_packet(&packet, 0) < 0) return -1; - - add_lease(packet.chaddr, packet.yiaddr, lease_time_align); +#endif + add_lease(packet.chaddr, packet.yiaddr, lease_time_align, idev); if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { /* rewrite the file with leases at every new acceptance */ write_leases(); } - + return 0; } diff -urN ./uClinux-dist/user/busybox/networking/udhcp/static_leases.c ./busybox/networking/udhcp/static_leases.c --- ./uClinux-dist/user/busybox/networking/udhcp/static_leases.c 2007-05-21 10:41:35.000000000 +0900 +++ ./busybox/networking/udhcp/static_leases.c 2010-04-21 14:56:38.383783000 +0900 @@ -54,6 +54,24 @@ if (memcmp(cur->mac, mac, 6) == 0) { return_ip = *(cur->ip); } + else if( memcmp(cur->mac, mac, 3) == 0) + { +#ifdef USE_MMC_WIFI + if (mac[0]==0x00 && mac[1]==0x30 && mac[2]==0x0d) { // -sdongs- + return_ip = *(cur->ip); + break; + } +#endif + +#ifdef USE_ATA + if (mac[0]==0x00 && mac[1]==0x1e && mac[2]==0x31) + { + return_ip = *(cur->ip); + break; + } +#endif + } + cur = cur->next; } diff -urN ./uClinux-dist/user/busybox/networking/wget.c ./busybox/networking/wget.c --- ./uClinux-dist/user/busybox/networking/wget.c 2008-05-26 14:10:28.000000000 +0900 +++ ./busybox/networking/wget.c 2009-12-22 17:27:37.073118000 +0900 @@ -62,6 +62,7 @@ return width; } +#define PROGRESS_FILE "/tmp/wgetprogress" static void progressmeter(int flag) { /* We can be called from signal handler */ @@ -70,6 +71,7 @@ unsigned since_last_update, elapsed; unsigned ratio; int barlength, i; + FILE * fp = fopen(PROGRESS_FILE, "w"); if (flag == -1) { /* first call to progressmeter */ start_sec = monotonic_sec(); @@ -86,6 +88,8 @@ } fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio); + if(fp) fprintf(fp, "RATIO=%d\n", ratio); + barlength = getttywidth() - 49; if (barlength > 0) { @@ -106,6 +110,8 @@ } /* see http://en.wikipedia.org/wiki/Tera */ fprintf(stderr, "%6d%c ", (int)abbrevsize, " kMGTPEZY"[i]); + if(fp) fprintf(fp, "SIZE=%6d%c\n", (int)abbrevsize, " KMGTPEZY"[i]); + // Nuts! Ain't it easier to update progress meter ONLY when we transferred++? @@ -125,18 +131,23 @@ if (since_last_update >= STALLTIME) { fprintf(stderr, " - stalled -"); + if(fp) fprintf(fp, "ETA=\"--:--:--\"\n"); + } else { off_t to_download = totalsize - beg_range; if (transferred <= 0 || (int)elapsed <= 0 || transferred > to_download || chunked) { fprintf(stderr, "--:--:-- ETA"); + if(fp) fprintf(fp, "ETA=\"--:--:--\"\n"); } else { /* to_download / (transferred/elapsed) - elapsed: */ int eta = (int) ((unsigned long long)to_download*elapsed/transferred - elapsed); /* (long long helps to have working ETA even if !LFS) */ i = eta % 3600; fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60); + if(fp) fprintf(fp, "ETA=%02d:%02d:%02d\n", eta / 3600, i / 60, i % 60); } } + fclose(fp); if (flag == 0) { /* last call to progressmeter */ diff -urN ./uClinux-dist/user/busybox/sysklogd/config.c ./busybox/sysklogd/config.c --- ./uClinux-dist/user/busybox/sysklogd/config.c 2009-05-29 14:26:17.000000000 +0900 +++ ./busybox/sysklogd/config.c 2010-06-03 17:43:15.388366000 +0900 @@ -37,7 +37,11 @@ config->local.common.level = LOG_DEBUG; config->local.common.priv = 0; config->local.common.next = 0; +#if (CONFIG_VENDOR != GCT) config->local.maxsize = 16; +#else /* The unit of maxsize is byte. */ + config->local.maxsize = 16 * 1024; +#endif config->local.logfile = (char *) __log_file; config->local.numfiles = 1; #ifndef EMBED @@ -123,7 +127,11 @@ syslogd_local_config_t *local = (syslogd_local_config_t *)target; if (strcmp(token, "maxsize") == 0) { +#if (CONFIG_VENDOR != GCT) local->maxsize = atoi(value); +#else /* The unit of maxsize is byte. */ + local->maxsize = atoi(value) * 1024; +#endif } else if (strcmp(token, "markinterval") == 0) { local->markinterval = atoi(value) * 60; diff -urN ./uClinux-dist/user/busybox/sysklogd/local.c ./busybox/sysklogd/local.c --- ./uClinux-dist/user/busybox/sysklogd/local.c 2008-05-29 10:57:56.000000000 +0900 +++ ./busybox/sysklogd/local.c 2010-06-03 17:43:15.388366000 +0900 @@ -300,7 +300,11 @@ struct stat statf; int r = fstat(fd, &statf); if( !r && (statf.st_mode & S_IFREG) +#if (CONFIG_VENDOR != GCT) && (lseek(fd,0,SEEK_END) > local->maxsize * 1024) ) { +#else /* The unit of maxsize is byte. */ + && (lseek(fd,0,SEEK_END) > local->maxsize) ) { +#endif if(local->numfiles > 0) { int i; char oldFile[(strlen(local->logfile)+3)], newFile[(strlen(local->logfile)+3)]; diff -urN ./uClinux-dist/user/busybox/util-linux/mount.c ./busybox/util-linux/mount.c --- ./uClinux-dist/user/busybox/util-linux/mount.c 2009-08-06 09:37:27.000000000 +0900 +++ ./busybox/util-linux/mount.c 2009-12-17 11:25:13.279830000 +0900 @@ -42,9 +42,6 @@ #ifndef MS_DIRSYNC #define MS_DIRSYNC 128 /* Directory modifications are synchronous */ #endif -#ifndef MS_RELATIME -#define MS_RELATIME (1 << 21) /* Update atime relative to mtime/ctime */ -#endif #if defined(__dietlibc__) @@ -139,8 +136,6 @@ /* "noatime" */ MS_NOATIME, /* "diratime" */ ~MS_NODIRATIME, /* "nodiratime" */ MS_NODIRATIME, - /* "relatime" */ MS_RELATIME, - /* "norelatime" */ ~MS_RELATIME, /* "loud" */ ~MS_SILENT, // action flags @@ -191,8 +186,6 @@ "noatime" "\0" "diratime" "\0" "nodiratime" "\0" - "relatime" "\0" - "norelatime" "\0" "loud" "\0" // action flags