Changeset 31729


Ignore:
Timestamp:
2012-05-14T22:58:41+02:00 (6 years ago)
Author:
nbd
Message:

openconnect: add netifd support

Location:
packages/net/openconnect
Files:
4 added
2 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • packages/net/openconnect/Makefile

    r31562 r31729  
    2121  SECTION:=net 
    2222  CATEGORY:=Network 
    23   DEPENDS:=+libxml2 +libopenssl +kmod-tun +vpnc-scripts 
     23  DEPENDS:=+libxml2 +libopenssl +kmod-tun +resolveip +!PACKAGE_netifd:vpnc-scripts 
    2424  TITLE:=VPN client for Cisco's AnyConnect SSL VPN 
    2525  URL:=http://www.infradead.org/openconnect/ 
     
    3636 
    3737CONFIGURE_ARGS+=--disable-shared 
     38ifdef CONFIG_PACKAGE_netifd 
     39  CONFIGURE_ARGS += --with-vpnc-script=/lib/netifd/vpnc-script 
    3840 
    39 define Package/openconnect/install 
     41  define Package/openconnect/install 
     42        $(INSTALL_DIR) $(1)/lib/netifd/proto 
     43        $(INSTALL_BIN) ./files/openconnect.sh $(1)/lib/netifd/proto/ 
     44        $(INSTALL_BIN) ./files/vpnc-script $(1)/lib/netifd/ 
     45        $(INSTALL_DIR) $(1)/usr/sbin 
     46        $(INSTALL_BIN) $(PKG_BUILD_DIR)/openconnect $(1)/usr/sbin/ 
     47  endef 
     48else 
     49  CONFIGURE_ARGS += --with-vpnc-script=/etc/vpnc/vpnc-script 
     50 
     51  define Package/openconnect/install 
    4052        $(INSTALL_DIR) $(1)/lib/network 
    41         $(INSTALL_BIN) ./files/openconnect.sh $(1)/lib/network/ 
     53        $(INSTALL_BIN) ./files.old/openconnect.sh $(1)/lib/network/ 
    4254        $(INSTALL_DIR) $(1)/usr/sbin 
    43         $(INSTALL_BIN) ./files/run-openconnect $(1)/usr/sbin/ 
     55        $(INSTALL_BIN) ./files.old/run-openconnect $(1)/usr/sbin/ 
    4456        $(INSTALL_BIN) $(PKG_BUILD_DIR)/openconnect $(1)/usr/sbin/ 
    45 endef 
     57  endef 
     58endif 
    4659 
    4760$(eval $(call BuildPackage,openconnect)) 
  • packages/net/openconnect/files/openconnect.sh

    r31559 r31729  
    1 find_gw() { 
    2         route -n | awk '$1 == "0.0.0.0" { print $2; exit }' 
     1#!/bin/sh 
     2. /etc/functions.sh 
     3. ../netifd-proto.sh 
     4init_proto "$@" 
     5 
     6proto_openconnect_init_config() { 
     7        proto_config_add_string "server" 
     8        proto_config_add_int "port" 
     9        proto_config_add_string "username" 
     10        proto_config_add_string "cookie" 
     11        proto_config_add_string "password" 
     12        no_device=1 
     13        available=1 
    314} 
    415 
    5 scan_openconnect() { 
    6         config_set "$1" device "vpn-$1" 
     16proto_openconnect_setup() { 
     17        local config="$1" 
     18 
     19        json_get_vars server port username cookie password 
     20 
     21        grep -q tun /proc/modules || insmod tun 
     22 
     23        serv_addr= 
     24        for ip in $(resolveip -t 5 "$server"); do 
     25                proto_add_host_dependency "$config" "$server" 
     26                serv_addr=1 
     27        done 
     28        [ -n "$serv_addr" ] || { 
     29                echo "Could not resolve server address" 
     30                sleep 5 
     31                proto_setup_failed "$config" 
     32                exit 1 
     33        } 
     34 
     35        [ -n "$port" ] && port=":$port" 
     36 
     37        cmdline="$server$port -i vpn-$config --no-cert-check --non-inter --syslog --script /lib/netifd/vpnc-script" 
     38 
     39        [ -n "$cookie" ] && append cmdline "-C $cookie" 
     40        [ -n "$username" ] && append cmdline "-u $username" 
     41        [ -n "$password" ] && { 
     42                umask 077 
     43                pwfile="/var/run/openconnect-$config.passwd" 
     44                echo "$password" > "$pwfile" 
     45                append cmdline "--passwd-file=$pwfile" 
     46        } 
     47 
     48        proto_export INTERFACE="$config" 
     49        proto_run_command "$config" /usr/sbin/openconnect $cmdline 
    750} 
    851 
    9 stop_interface_openconnect() { 
    10         local config="$1" 
    11         local lock="/var/lock/openconnect-$config" 
    12  
    13         uci_set_state network "$config" up 0 
    14  
    15         lock "$lock" 
    16  
    17         SERVICE_PID_FILE="/var/run/openconnect-${config}.pid" \ 
    18           SERVICE_SIG=HUP service_stop /bin/sh 
    19  
    20         remove_dns "$config" 
    21  
    22         lock -u "$lock" 
     52proto_openconnect_teardown() { 
     53        proto_kill_command "$config" 
    2354} 
    2455 
    25 setup_interface_openconnect() { 
    26         local config="$2" 
    27  
    28         /sbin/insmod tun 2>&- >&- 
    29  
    30         # creating the tunnel below will trigger a net subsystem event 
    31         # prevent it from touching or iface by disabling .auto here 
    32         uci_set_state network "$config" ifname "vpn-$config" 
    33         uci_set_state network "$config" auto 0 
    34         uci_set_state network "$config" up 1 
    35  
    36         SERVICE_PID_FILE="/var/run/openconnect-${config}.pid" \ 
    37           SERVICE_WRITE_PID=1  SERVICE_DAEMONIZE=1 \ 
    38         service_start /usr/sbin/run-openconnect $config 
    39 } 
     56add_protocol openconnect 
Note: See TracChangeset for help on using the changeset viewer.