tes1amint
tes1amint
Reputation Top 1%
Jaehoon You
14 Snippets  (59th place)
Published
1 Channel
Created
4 Channels
Following
315 points  (94th place)
Reputation
Top 10% Publisher
Serious Code Generator
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Senior Autobiographer
Serious Famous Coder
Senior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by tes1amint

public by shirkbot  128483  0  4  0

Hamming Weight

Hamming Weight: HamminItUp
public class IterRek {

	public static void main(String[] args) {
		int x = 5; //test x, real x is user input
		int i = 0;
		
		while (x != 0){
			if (x % 2 == 0){
				x = x/2;
			}
			else if (x % 2 == 1){
				i++; x = x/2;
			}
		}

		System.out.println(i);
		
	}
}

// searching for number of 1's in binary for x
//privided algorithm:
	// as long as x != 0
	//Determine the lowest bit value with x % 2
		//if it is 1, counter++
		//divide by x 2

;

public by danny8376  1164  0  4  0

my .screenrc

my .screenrc: .screenrc
# Start message
startup_message off

# Set hardstatus always on
caption always "%{=u .R} %-w%{=ub .m}%n %t%{=u .R}%+w "
hardstatus alwayslastline "%{= .Y} [%l] %<%=%{= .g}@%H (%n %t) %=%{G}%e %{= .c}%Y/%m/%d%{= .M} %C %A"

# Set default encoding using utf8
defutf8 on

# Refresh the display when exiting programs
altscreen on

# reload screenrc OwO
bind R eval "source $HOME/.screenrc" "echo '.screenrc reloaded!'"

# Disable vbell
vbell off

# === Keboard binding ===
# bind Shift+left/right to prev/next win
bindkey ^[[1;2D prev
bindkey ^[[1;2C next

# bind Shift + F1~F10 to screen0~9
bindkey ^[[1;2P select 0
bindkey ^[[1;2Q select 1
bindkey ^[[1;2R select 2
bindkey ^[[1;2S select 3
bindkey ^[[15;2~ select 4
bindkey ^[[17;2~ select 5
bindkey ^[[18;2~ select 6
bindkey ^[[19;2~ select 7
bindkey ^[[20;2~ select 8
bindkey ^[[21;2~ select 9

# bind F7 to detach screen session (to background)
bindkey -k k7 detach
# bind F8 to kill current screen window
bindkey -k k8 kill
# bind F9 to create a new screen
bindkey -k k9 screen
# bind F10 to rename current screen window
bindkey -k k; title

;

public by teslamint  3642  2  4  -1

[PATCH][package] AA: update coova-chilli to 1.3.0 and add kmod-coova package

[PATCH][package] AA: update coova-chilli to 1.3.0 and add kmod-coova package: 0001-update-coova-chilli-to-1.3.0-add-kmod-coova-package.patch
From 2a7568d17915edd283a71f4cc4d4c71d066df912 Mon Sep 17 00:00:00 2001
From: Jaehoon You <jhyou@waffle.at>
Date: Fri, 25 Apr 2014 17:00:48 +0900
Subject: [PATCH] update coova-chilli to 1.3.0; add kmod-coova package;

---
 net/coova-chilli/Config.in                         | 56 +++++++++++++
 net/coova-chilli/Makefile                          | 94 ++++++++++++++++++++--
 net/coova-chilli/files/chilli.firewall             | 41 ++++++++++
 net/coova-chilli/files/chilli.init                 | 61 ++++++++++++++
 .../patches/100-fix-sysinfo-redeclaration.patch    | 24 ++++++
 .../patches/200-fix_compile_kmod.patch             | 24 ++++++
 6 files changed, 292 insertions(+), 8 deletions(-)
 create mode 100644 net/coova-chilli/Config.in
 create mode 100644 net/coova-chilli/files/chilli.firewall
 create mode 100644 net/coova-chilli/files/chilli.init
 create mode 100644 net/coova-chilli/patches/100-fix-sysinfo-redeclaration.patch
 create mode 100644 net/coova-chilli/patches/200-fix_compile_kmod.patch

diff --git a/net/coova-chilli/Config.in b/net/coova-chilli/Config.in
new file mode 100644
index 0000000..8057d87
--- /dev/null
+++ b/net/coova-chilli/Config.in
@@ -0,0 +1,56 @@
+# CoovaChilli advanced configuration
+
+menu "Configuration"
+       depends on PACKAGE_coova-chilli
+
+config COOVACHILLI_REDIR
+       bool "Enable support for redir server. Required for uamregex"
+       default n
+
+config COOVACHILLI_MINIPORTAL
+       bool "Enable support Coova miniportal"
+       default n
+
+config COOVACHILLI_USERAGENT
+       bool "Enable recording user-agent"
+       default n
+
+config COOVACHILLI_DNSLOG
+       bool "Enable support to log DNS name queries"
+       default n
+
+config COOVACHILLI_UAMDOMAINFILE
+       bool "Enable loading of mass uamdomains from file"
+       default n
+
+config COOVACHILLI_PROXY
+       bool "Enable proxy"
+       default n
+
+config COOVACHILLI_MINICONFIG
+       bool "Enable mini configuration file"
+       default n
+
+config COOVACHILLI_BINSTATUSFILE
+       bool "Enable binary status file"
+       default n
+
+choice
+       prompt "SSL library"
+       default COOVACHILLI_NOSSL
+
+config COOVACHILLI_NOSSL
+       bool "No SSL support"
+
+config COOVACHILLI_MATRIXSSL
+       bool "MatrixSSL"
+
+config COOVACHILLI_CYASSL
+       bool "CyaSSL"
+
+config COOVACHILLI_OPENSSL
+       bool "OpenSSL"
+
+endchoice
+
+endmenu
diff --git a/net/coova-chilli/Makefile b/net/coova-chilli/Makefile
index 3b350cb..b5bd93c 100644
--- a/net/coova-chilli/Makefile
+++ b/net/coova-chilli/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2007-2010 OpenWrt.org
+# Copyright (C) 2007-2013 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,25 +8,42 @@
 include $(TOPDIR)/rules.mk

 PKG_NAME:=coova-chilli
-PKG_VERSION:=1.2.9
-PKG_RELEASE:=1
+PKG_VERSION:=1.3.0
+PKG_RELEASE:=3

 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://ap.coova.org/chilli
-PKG_MD5SUM:=a493d0562fc3b05fe86d8ad65f7f2dc0
+PKG_MD5SUM:=dc0037e3cdebcb60508081b4e42e984a

-PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1

+
+PKG_CONFIG_DEPENDS := \
+  COOVACHILLI_MINIPORTAL \
+  COOVACHILLI_REDIR \
+  COOVACHILLI_USERAGENT \
+  COOVACHILLI_DNSLOG \
+  COOVACHILLI_UAMDOMAINFILE \
+  COOVACHILLI_NOSSL \
+  COOVACHILLI_MATRIXSSL \
+  COOVACHILLI_CYASSL \
+  COOVACHILLI_OPENSSL \
+  COOVACHILLI_BINSTATUSFILE \
+  COOVACHILLI_PROXY \
+  COOVACHILLI_MINICONFIG
+
 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk

 define Package/coova-chilli
   SUBMENU:=Captive Portals
   SECTION:=net
   CATEGORY:=Network
-  DEPENDS:=+kmod-tun +librt
+  DEPENDS:=+kmod-tun +librt +COOVACHILLI_MATRIXSSL:libmatrixssl +COOVACHILLI_CYASSL:libcyassl +COOVACHILLI_OPENSSL:libopenssl
   TITLE:=Wireless LAN HotSpot controller (Coova Chilli Version)
   URL:=http://www.coova.org/CoovaChilli
+  MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
+  MENU:=1
 endef

 define Package/coova-chilli/description
@@ -39,8 +56,59 @@ define Package/coova-chilli/description
        favorite radius server.
 endef

-define Package/coova-chilli/conffiles
-/etc/chilli.conf
+define Package/coova-chilli/config
+  source "$(SOURCE)/Config.in"
+endef
+
+define KernelPackage/coova
+  URL:=http://www.coova.org/CoovaChilli
+  SUBMENU:=Network Support
+  DEPENDS:=+coova-chilli
+  TITLE:=Coova kernel module
+  FILES:=$(PKG_BUILD_DIR)/src/linux/xt_coova.$(LINUX_KMOD_SUFFIX)
+  AUTOLOAD:=$(call AutoLoad,90,coova)
+endef
+
+define KernelPackage/coova/description
+Kernel module for CoovaChilli
+endef
+
+DISABLE_NLS=
+
+CONFIGURE_VARS += \
+       ac_cv_func_malloc_0_nonnull=yes \
+       ac_cv_func_realloc_0_nonnull=yes \
+       ac_cv_func_memcmp_working=yes \
+       ac_cv_func_setvbuf_reversed=no \
+       KERNEL_DIR="$(LINUX_DIR)"
+
+CONFIGURE_ARGS += \
+       $(if $(CONFIG_COOVACHILLI_REDIR),--enable,--disable)-chilliredir \
+       $(if $(CONFIG_COOVACHILLI_DNSLOG),--enable,--disable)-dnslog \
+       $(if $(CONFIG_COOVACHILLI_MINIPORTAL),--enable,--disable)-miniportal \
+       $(if $(CONFIG_COOVACHILLI_USERAGENT),--enable,--disable)-useragent \
+       $(if $(CONFIG_COOVACHILLI_UAMDOMAINFILE),--enable,--disable)-uamdomainfile \
+       $(if $(CONFIG_COOVACHILLI_MATRIXSSL),--with,--without)-matrixssl \
+       $(if $(CONFIG_COOVACHILLI_CYASSL),--with,--without)-cyassl \
+       $(if $(CONFIG_COOVACHILLI_OPENSSL),--with,--without)-openssl \
+       $(if $(CONFIG_COOVACHILLI_BINSTATUSFILE),--enable,--disable)-binstatusfile \
+       $(if $(CONFIG_COOVACHILLI_PROXY),--enable,--disable)-chilliproxy \
+       $(if $(CONFIG_COOVACHILLI_MINICONFIG),--enable,--disable)-miniconfig \
+       $(if $(CONFIG_PACKAGE_kmod-coova),--with-nfcoova,)
+
+MAKE_FLAGS += \
+       KERNEL_DIR="$(LINUX_DIR)"
+
+MAKE_INSTALL_FLAGS += \
+       KERNEL_DIR="$(LINUX_DIR)" \
+       INSTALL_MOD_PATH="$(PKG_INSTALL_DIR)"
+
+define Build/Configure
+( \
+               cd $(PKG_BUILD_DIR); \
+               rm -rf config.{cache,status} ; \
+               $(call Build/Configure/Default) \
+)
 endef

 define Package/coova-chilli/install
@@ -52,6 +120,16 @@ define Package/coova-chilli/install
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/chilli* $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/usr/lib/
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(CP) files/chilli.init $(1)/etc/init.d/chilli
+       $(INSTALL_DIR) $(1)/lib/firewall
+       $(CP) files/chilli.firewall $(1)/lib/firewall/chilli.sh
+       $(if $(CONFIG_PACKAGE_kmod-coova), \
+               $(INSTALL_DIR) $(1)/usr/lib/iptables; \
+               $(CP) $(PKG_BUILD_DIR)/src/linux/lib*.so $(1)/usr/lib/iptables/ \
+       )
 endef

 $(eval $(call BuildPackage,coova-chilli))
+$(eval $(call KernelPackage,coova))
+
diff --git a/net/coova-chilli/files/chilli.firewall b/net/coova-chilli/files/chilli.firewall
new file mode 100644
index 0000000..e3856c4
--- /dev/null
+++ b/net/coova-chilli/files/chilli.firewall
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+chilli_firewall() {
+    local cfg="$1"
+
+    local network ifname tun
+
+    config_get network "$cfg" network
+
+    . /lib/functions/network.sh
+    network_get_device ifname ${network:-lan}
+
+    if [ "$ifname" = "" ]
+    then
+       config_get ifname "$cfg" dhcpif
+    fi
+
+    config_get tun "$cfg" tundev
+
+    for n in ACCEPT DROP REJECT
+    do
+       iptables -F zone_${network}_${n}
+       iptables -I zone_${network}_${n} -i $tun -j $n
+       iptables -I zone_${network}_${n} -o $tun -j $n
+    done
+
+    iptables -D forward -i ${ifname} -j zone_${network}_forward
+    iptables -A forward -i ${ifname} -j DROP
+    iptables -A forward -i $tun -j zone_${network}_forward
+
+    iptables -D input -i ${ifname} -j zone_${network}
+    iptables -A input -i $tun -j zone_${network}
+
+    iptables -I zone_${network} -p tcp --dport 3990 -j ACCEPT
+    iptables -I zone_${network} -p tcp --dport 3991 -j ACCEPT
+}
+
+chilli_post_core_cb() {
+    config_load chilli
+    config_foreach chilli_firewall chilli
+}
diff --git a/net/coova-chilli/files/chilli.init b/net/coova-chilli/files/chilli.init
new file mode 100644
index 0000000..a72f4f4
--- /dev/null
+++ b/net/coova-chilli/files/chilli.init
@@ -0,0 +1,61 @@
+#!/bin/sh /etc/rc.common
+
+START=30
+STOP=90
+
+config_cb() {
+    chilli_inst=$2
+    if [ "$chilli_inst" != "" ]
+    then
+       rm -f /var/run/chilli_${chilli_inst}*
+       chilli_conf=/var/run/chilli_${chilli_inst}.conf
+       eval "start_chilli_$chilli_inst=1"
+    fi
+}
+
+option_cb() {
+    case "$1" in
+        # UCI settings
+       network)
+           . /lib/functions/network.sh
+           local ifname
+           network_get_device ifname $2
+           echo "dhcpif=\"$ifname\"" >> $chilli_conf
+           ;;
+       disabled)
+           eval "start_chilli_$chilli_inst=0"
+           ;;
+        # boolean settings
+       dhcpbroadcast|nodynip|vlanlocation|locationstopstart|locationcopycalled|locationimmediateupdate|locationopt82|coanoipcheck|noradallow|proxymacaccept|proxyonacct|dhcpmacset|dhcpradius|noc2c|eapolenable|uamanydns|uamanyip|uamnatanyip|nouamsuccess|nowispr1|nowispr2|domaindnslocal|radsec|macauth|macreauth|macauthdeny|macallowlocal|strictmacauth|strictdhcp|ieee8021q|only8021q|radiusoriginalurl|swapoctets|statusfilesave|wpaguests|openidauth|papalwaysok|mschapv2|chillixml|acctupdate|dnsparanoia|seskeepalive|usetap|noarpentries|framedservice|scalewin|redir|injectwispr|redirurl|routeonetone|nousergardendata|uamgardendata|uamotherdata|withunixipc|uamallowpost|redirssl|uamuissl|layer3|patricia|redirdnsreq|dhcpnotidle|ipv6|ipv6only)
+           [ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> $chilli_conf
+           ;;
+       *)
+           echo "$1=\"$2\"" >> $chilli_conf
+           ;;
+    esac
+}
+
+start_chilli() {
+    local cfg="$1"
+    local start_chilli=$(eval "echo \$start_chilli_$cfg")
+    [ "$start_chilli" = "0" ] && return
+    local base=/var/run/chilli_${cfg}
+    chilli -c ${base}.conf \
+       --pidfile ${base}.pid \
+       --cmdsocket ${base}.sock \
+       --unixipc ${base}.ipc &
+}
+
+start() {
+    config_load chilli
+    config_foreach start_chilli chilli
+}
+
+stop() {
+    ls /var/run/chilli*.pid 2>/dev/null && {
+       kill $(cat /var/run/chilli*.pid)
+       sleep 1
+       killall -9 chilli
+       rm -f /var/run/chilli*
+    }
+}
diff --git a/net/coova-chilli/patches/100-fix-sysinfo-redeclaration.patch b/net/coova-chilli/patches/100-fix-sysinfo-redeclaration.patch
new file mode 100644
index 0000000..446eb63
--- /dev/null
+++ b/net/coova-chilli/patches/100-fix-sysinfo-redeclaration.patch
@@ -0,0 +1,24 @@
+--- a/src/system.h
++++ b/src/system.h
+@@ -76,10 +76,6 @@
+ #include <sys/stat.h>
+ #endif
+
+-#ifdef HAVE_SYS_SYSINFO_H
+-#include <sys/sysinfo.h>
+-#endif
+-
+ #ifdef HAVE_TIME_H
+ #include <time.h>
+ #endif
+@@ -132,6 +128,10 @@
+ #include <linux/un.h>
+ #endif
+
++#ifdef HAVE_SYS_SYSINFO_H
++#include <sys/sysinfo.h>
++#endif
++
+ #elif defined (__FreeBSD__)  || defined (__APPLE__) || defined (__OpenBSD__) || defined (__NetBSD__)
+ #include <net/if.h>
+ #include <net/bpf.h>
diff --git a/net/coova-chilli/patches/200-fix_compile_kmod.patch b/net/coova-chilli/patches/200-fix_compile_kmod.patch
new file mode 100644
index 0000000..799d26e
--- /dev/null
+++ b/net/coova-chilli/patches/200-fix_compile_kmod.patch
@@ -0,0 +1,24 @@
+--- a/src/linux/Makefile
++++ b/src/linux/Makefile
+@@ -9,7 +9,6 @@ modules:
+       make -C ${KERNEL_DIR} M=$$PWD $@;
+
+ modules_install:
+-      make -C ${KERNEL_DIR} M=$$PWD $@;
+
+ modules_clean:
+       make -C ${KERNEL_DIR} M=$$PWD $@;
+@@ -24,9 +23,9 @@ lib%.o: lib%.c
+       $(CC) $(CFLAGS) -fPIC -O2 -Wall -I${KERNEL_DIR}/include -D_INIT=lib$*_init -c -o $@ $<;
+
+ install: modules_install libxt_coova.so
+-      mkdir -p $(DESTDIR)/lib/xtables/
+-      cp libxt_coova.so $(DESTDIR)/lib/xtables/
++      mkdir -p $(DESTDIR)/usr/lib/iptables/
++      cp libxt_coova.so $(DESTDIR)/usr/lib/iptables/
+
+ distdir:
+
+-distclean: clean
+\ No newline at end of file
++distclean: clean
--
1.8.2.1


;

public by teslamint  2213  0  4  0

install tcpdump on /tmp

install tcpdump on /tmp: install_tcpdump.sh
#!/bin/sh

# fix opkg package url
sed -i 's@12.09.1@12.09@g' /etc/opkg.conf

# install libpcap and tcpdump
/bin/opkg update
/bin/opkg install tcpdump --add-dest temp:/tmp -d temp

# link libpcap and tcpdump
ln -sf /tmp/usr/lib/libpcap* /usr/lib
ln -sf /tmp/usr/sbin/* /usr/sbin


;

public by jaehoon  3033  7  4  0

TP-LINK Firmware flashing script by attila.lendvai from http://wiki.openwrt.org/toh/tp-link/tl-wr1043nd#oem.mass.flashing (rev. 1336694829) CC-BY-SA 3.0

TP-LINK Firmware flashing script by attila.lendvai from http://wiki.openwrt.org/toh/tp-link/tl-wr1043nd#oem.mass.flashing (rev. 1336694829) CC-BY-SA 3.0: tplink.sh
#!/bin/bash
 
# Pass the firmware image file to be flashed as the first and only
# command line argument.
#
# The second curl call will time out, but it is expected. Once the
# script exits, you can unplug the ethernet cable and proceed to the
# next router, but do KEEP each router ON POWER until the new image is
# fully written! When flashing is done the router reboots
# automatically (as shown by all the leds flashing once).
 
curl \
  --user admin:admin \
  --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' \
  --referer 'http://192.168.1.1/userRpm/SoftwareUpgradeRpm.htm' \
  --form "Filename=@$1" -F 'Upgrade=Upgrade' \
  http://192.168.1.1/incoming/Firmware.htm > /dev/null
 
sleep 1
 
curl \
  --max-time 2 \
  --user admin:admin \
  --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' \
  --referer 'http://192.168.1.1/incoming/Firmware.htm' \
  http://192.168.1.1/userRpm/FirmwareUpdateTemp.htm >  /dev/null

;