# HG changeset patch # User Sebastien Decugis # Date 1282025090 -32400 # Node ID 753c9ed8f19aa8655f855d5b47034e353f1a39a9 # Parent 6edd14e5f1324b43a0c5433ac083c5ec10a36f99 Initial working freeDiameter package diff -r 6edd14e5f132 -r 753c9ed8f19a contrib/OpenWRT/HOWTO --- a/contrib/OpenWRT/HOWTO Fri Aug 13 15:52:28 2010 +0900 +++ b/contrib/OpenWRT/HOWTO Tue Aug 17 15:04:50 2010 +0900 @@ -5,6 +5,7 @@ that it will work for you. Be prepared to eventually brick your routeur... Table of contents: +0) Quick HOWTO: optimistic step-by-step instructions. 1) Prerequisites: get the OpenWRT development environment ready. 2) Supplied packages: use the existing packages when possible (gnutls, ...) 3) Other dependencies: provide for additional missing dependencies (sctp ...) @@ -15,6 +16,58 @@ its basic configuration. Please refer to OpenWRT website for this type of HOWTOs. +============================================== +0) Quick HOWTO +============================================== +The following instructions should allow you to put freeDiameter on your OpenWRT-compatible router. +In case something goes wrong, you should follow the detailed instructions in the remaining of +this file. + +Be warned: playing with the software in your router may brick it, i.e. make it unusable forever. +Do it at your own risk. + +1) Get the OpenWRT environment: +$ git clone git://nbd.name/openwrt.git +$ cd openwrt + +2) Get the feeds +$ cp feeds.conf.default feeds.conf +$ echo "src-hg freediameter http://www.freediameter.net/hg/fD-OWRT-packages" >> feeds.conf +$ scripts/feeds update +$ scripts/feeds install freeDiameter + +3) Configure your image +$ make menuconfig +(set Target System and Target Profile as needed for your equipment) + +- Network ---> + freeDiameter (M) + +4) Build the image and packages, this takes a while +$ make world + +5) Export the bin/* directory through a webserver. + We assume it is available at http://192.168.1.25/owrt + +6) Flash the router with your new image -- THIS DESTROYS ALL CONFIG ON THE ROUTER! +$ ssh root@192.168.1.1 +# cd /tmp +# wget http://192.168.1.25/owrt/openwrt-brcm47xx-squashfs.trx + ;; change the file name with yours +# mtd -r write openwrt-brcm47xx-squashfs.trx linux + ;; wait for reboot +$ telnet 192.168.1.1 +# passwd +# sync + +7) Update the opkg router's config to get your new packages +ssh root@192.168.1.1 +# echo "src/gz chavroux http://192.168.1.25/owrt/packages" >> /etc/opkg.conf +# opkg update + +8) Install freeDiameter, you're done. Optionnaly, install also certtool and libgnutls-extra on the router before, to + generate the TLS certificate. +# opkg install freeDiameter ============================================== 1) Prerequisites: @@ -183,9 +236,9 @@ ============================================== Now, your environment should be ready to compile the freeDiameter ipkg package. -$ ./scripts/feeds install freediameter +$ scripts/feeds install freeDiameter -Note that in order to build this package, you need to have cmake on your compilation machine. +Note that in order to build this package, you need to have cmake & flex on your compilation machine. $ make menuconfig - Network ---> diff -r 6edd14e5f132 -r 753c9ed8f19a contrib/OpenWRT/packages/freeDiameter/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/OpenWRT/packages/freeDiameter/Makefile Tue Aug 17 15:04:50 2010 +0900 @@ -0,0 +1,137 @@ +# +# Software License Agreement (BSD License) +# +# Copyright (c) 2010, WIDE Project and NICT +# All rights reserved. +# +# See LICENSE file from freeDiameter source package for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=freeDiameter +PKG_REV:=497 +PKG_VERSION:=r$(PKG_REV) +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=hg +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.freediameter.net/hg/freeDiameter +# PKG_MD5SUM:= + +PKG_FIXUP:=libtool +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/freeDiameter + SECTION:=freeDiameter + CATEGORY:=Network + TITLE:=freeDiameter + URL:=http://www.freediameter.net + DEPENDS:=+sctp +libgnutls +libpthread +kmod-ipv6 +endef + +define Package/freeDiameter/description + freeDiameter + RADIUS/Diameter gateway extension package. +endef + +define Package/freeDiameter/conffiles +/etc/freeDiameter/freeDiameter.conf +/etc/freeDiameter/rgw.conf +endef + +define Build/Configure + IN_OPENWRT=1 \ + AR="$(TARGET_CROSS)ar" \ + AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \ + LD="$(TARGET_CROSS)ld" \ + NM="$(TARGET_CROSS)nm" \ + CC="$(TARGET_CC)" \ + GCC="$(TARGET_CC)" \ + CXX="$(TARGET_CROSS)g++" \ + RANLIB="$(TARGET_CROSS)ranlib" \ + STRIP="$(TARGET_CROSS)strip" \ + OBJCOPY="$(TARGET_CROSS)objcopy" \ + OBJDUMP="$(TARGET_CROSS)objdump" \ + TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \ + TARGET_CFLAGS="$(TARGET_CFLAGS)" \ + TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \ + cmake \ + -DCMAKE_PREFIX_PATH:PATH=$(STAGING_DIR)/usr \ + -DCMAKE_INSTALL_PREFIX:PATH=/usr \ + -DBUILD_TESTING:BOOL=OFF \ + -DCMAKE_BUILD_TYPE:STRING=DebianPackage \ + -DDEFAULT_CONF_PATH:PATH=/etc/freeDiameter \ + -DBUILD_APP_RADGW:BOOL=ON \ + -DBUILD_DBG_MONITOR:BOOL=ON \ + VERBOSE=1 \ + $(PKG_BUILD_DIR)/CMakeLists.txt +endef + +TARGET_LDFLAGS := -L$(STAGING_DIR)/usr/lib $(TARGET_LDFLAGS) +define Package/freeDiameter/install + # binaries + $(INSTALL_DIR) $(1)/usr/bin + $(CP) \ + $(PKG_INSTALL_DIR)/usr/bin/freeDiameterd* \ + $(1)/usr/bin/ + # libraries & extensions + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/* \ + $(1)/usr/lib/ + + # configuration files + $(INSTALL_DIR) $(1)/etc/freeDiameter + $(INSTALL_CONF) \ + $(PKG_BUILD_DIR)/doc/freediameter.conf.sample \ + $(1)/etc/freeDiameter/freeDiameter.conf + $(SED) 's,TLS_Cred,#TLS_Cred,g' $(1)/etc/freeDiameter/freeDiameter.conf + echo "" >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "### OPENWRT specific" >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "TLS_Cred = \"/etc/freeDiameter/freeDiameter.pem\", \"/etc/freeDiameter/freeDiameter.key\";" \ + >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "TLS_DH_Bits = 768;" >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "LoadExtension = \"dict_nasreq.fdx\";" >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "LoadExtension = \"dict_eap.fdx\";" >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "LoadExtension = \"app_radgw.fdx\":\"rgw.conf\";" \ + >> $(1)/etc/freeDiameter/freeDiameter.conf + echo "Identity = \"localhost.localdomain\";" >> $(1)/etc/freeDiameter/freeDiameter.conf + + + $(INSTALL_CONF) \ + $(PKG_BUILD_DIR)/doc/app_radgw.conf.sample \ + $(1)/etc/freeDiameter/rgw.conf + $(SED) 's,RGWX,#RGWX,g' $(1)/etc/freeDiameter/rgw.conf + echo "" >> $(1)/etc/freeDiameter/rgw.conf + echo "### OPENWRT specific" >> $(1)/etc/freeDiameter/rgw.conf + echo " RGWX = \"auth.rgwx\" : auth;" >> $(1)/etc/freeDiameter/rgw.conf + echo " RGWX = \"acct.rgwx\" : acct;" >> $(1)/etc/freeDiameter/rgw.conf + echo "" >> $(1)/etc/freeDiameter/rgw.conf + echo " cli = 127.0.0.1 / \"secret key\" ;" >> $(1)/etc/freeDiameter/rgw.conf + echo " auth_server_ip4 = 127.0.0.1;" >> $(1)/etc/freeDiameter/rgw.conf + echo " auth_server_ip6 = ::1 ;" >> $(1)/etc/freeDiameter/rgw.conf + echo " acct_server_ip4 = 127.0.0.1;" >> $(1)/etc/freeDiameter/rgw.conf + echo " acct_server_ip6 = ::1 ;" >> $(1)/etc/freeDiameter/rgw.conf +endef + +define Package/freeDiameter/postinst +#!/bin/sh +if [ ! -f "/usr/bin/certtool" ]; then + echo "certtool is not installed, skipping creation of default certificate." + exit 0 +fi +if [ ! -f "/etc/freeDiameter/freeDiameter.pem" ]; then + if [ ! -f "/etc/freeDiameter/freeDiameter.key" ]; then + echo "Creating a new private key for freeDiameter TLS layer, please wait" + certtool -p --outfile /etc/freeDiameter/freeDiameter.key + fi + echo "Creating a new certificate for freeDiameter TLS layer, please enter the appropriate values for your access point" + certtool -s --load-privkey /etc/freeDiameter/freeDiameter.key --outfile /etc/freeDiameter/freeDiameter.pem +fi +endef + +$(eval $(call BuildPackage,freeDiameter)) diff -r 6edd14e5f132 -r 753c9ed8f19a contrib/OpenWRT/packages/freeDiameter/patches/01-freeDiameter-OpenWRT.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/OpenWRT/packages/freeDiameter/patches/01-freeDiameter-OpenWRT.patch Tue Aug 17 15:04:50 2010 +0900 @@ -0,0 +1,19 @@ +diff -Nur freeDiameter/CMakeLists.txt freeDiameter-OpenWRT/CMakeLists.txt +--- freeDiameter/CMakeLists.txt 2010-08-13 16:19:35.000000000 +0900 ++++ freeDiameter-OpenWRT/CMakeLists.txt 2010-08-13 16:21:32.000000000 +0900 +@@ -51,6 +51,14 @@ + SET(DEBUG 1) + ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug|Profiling|DebugValgrind") + ++# OpenWRT ++SET(IN_OPENWRT $ENV{IN_OPENWRT}) ++IF (IN_OPENWRT) ++ ADD_DEFINITIONS("$ENV{TARGET_LDFLAGS}" "$ENV{TARGET_CPPFLAGS}" "$ENV{TARGET_CFLAGS}") ++ INCLUDE_DIRECTORIES("$ENV{TARGET_LDFLAGS}" "$ENV{TARGET_CPPFLAGS}" "$ENV{TARGET_CFLAGS}") ++ENDIF(IN_OPENWRT) ++ ++ + # some subfolders use yacc and lex parsers + SET(BISON_GENERATE_DEFINES TRUE) + SET(BISON_PREFIX_OUTPUTS TRUE) +Binary files freeDiameter/.hg/dirstate and freeDiameter-OpenWRT/.hg/dirstate differ diff -r 6edd14e5f132 -r 753c9ed8f19a contrib/OpenWRT/packages/sctp/Makefile --- a/contrib/OpenWRT/packages/sctp/Makefile Fri Aug 13 15:52:28 2010 +0900 +++ b/contrib/OpenWRT/packages/sctp/Makefile Tue Aug 17 15:04:50 2010 +0900 @@ -46,6 +46,16 @@ $(CP) \ $(PKG_INSTALL_DIR)/usr/lib/libsctp.so* \ $(1)/usr/lib/ + # And in staging for dependent packages + $(INSTALL_DIR) $(STAGING_DIR)/usr/include/netinet + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/netinet/* \ + $(STAGING_DIR)/usr/include/netinet/ + $(INSTALL_DIR) $(STAGING_DIR)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libsctp.so* \ + $(STAGING_DIR)/usr/lib/ + endef $(eval $(call BuildPackage,sctp)) @@ -69,7 +79,7 @@ AUTOLOAD:=\ $(call AutoLoad,30,crc32c libcrc32c,1) \ $(call AutoLoad,35,sctp) - DEPENDS:=@LINUX_2_6 +kmod-crypto-core +kmod-crypto-misc + DEPENDS:=@LINUX_2_6 +kmod-crypto-core +kmod-crypto-misc +kmod-crypto-md5 +kmod-crypto-hmac endef define KernelPackage/sctp/description