Add smap package.
Signed-off-by: Jiri Slachta <slachta@cesnet.cz>
This commit is contained in:
parent
a6bf7db0cb
commit
630f712b96
4 changed files with 201 additions and 0 deletions
64
smap/Makefile
Normal file
64
smap/Makefile
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=smap
|
||||||
|
PKG_VERSION:=0.6.0
|
||||||
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-20081016.tar.gz
|
||||||
|
PKG_SOURCE_URL:=http://www.wormulon.net/smap/
|
||||||
|
PKG_MD5SUM:=814456ccc8fea5688382b7ec55fe44eb
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/smap-$(PKG_VERSION)/smap
|
||||||
|
PKG_FIXUP:=autoreconf
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
LIBTOOL="$(STAGING_DIR)/host/bin/libtool"
|
||||||
|
|
||||||
|
define Package/smap
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Telephony
|
||||||
|
TITLE:=A SIP network discovery tool
|
||||||
|
MAINTAINER:=Daniel Dickinson <openwrt@cshore.neomailbox.net>
|
||||||
|
URL:=http://www.wormulon.net/smap/
|
||||||
|
DEPENDS:=+libpthread
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/smap/description
|
||||||
|
Discovers and identifies SIP devices on the network including hardware
|
||||||
|
phones, softphones, PBX software, and PBX equipment.
|
||||||
|
endef
|
||||||
|
|
||||||
|
# define Package/smap/conffiles
|
||||||
|
# /etc/config/smap
|
||||||
|
# endef
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||||
|
CC="$(TARGET_CC)" \
|
||||||
|
LD="$(TARGET_LD)" \
|
||||||
|
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -DRAW_SOCKET -DHAVE_RANDOM -DSMAP_OS=linux" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS) -lm -lpthread" \
|
||||||
|
LIBTOOL="$(LIBTOOL)" \
|
||||||
|
smap
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/smap/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/smap $(1)/usr/bin
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/smap
|
||||||
|
$(CP) $(PKG_BUILD_DIR)/fingerprint.db $(1)/usr/share/smap
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,smap))
|
62
smap/patches/00-fix-broadcast.patch
Normal file
62
smap/patches/00-fix-broadcast.patch
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
diff -Naur smap.orig/icmpping.c smap/icmpping.c
|
||||||
|
--- smap.orig/icmpping.c 2007-10-07 06:15:11.000000000 -0400
|
||||||
|
+++ smap/icmpping.c 2009-06-13 11:57:28.000000000 -0400
|
||||||
|
@@ -182,6 +182,7 @@
|
||||||
|
struct sockaddr_in sin;
|
||||||
|
#define ICMP_PKT_LEN (sizeof(struct icmp) + ICMP_PAYLOAD_LEN)
|
||||||
|
char icmpbuf[ICMP_PKT_LEN];
|
||||||
|
+ socklen_t socklen;
|
||||||
|
|
||||||
|
/* prepare ICMP packet */
|
||||||
|
memset(&icmpbuf, 'A', ICMP_PKT_LEN);
|
||||||
|
@@ -207,6 +208,8 @@
|
||||||
|
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) != 0)
|
||||||
|
perror("setsockopt");
|
||||||
|
#endif
|
||||||
|
+ if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) != 0)
|
||||||
|
+ perror("setsockopt");
|
||||||
|
icmp->icmp_cksum = icmp_in_cksum((unsigned short *) &icmpbuf, ICMP_PKT_LEN);
|
||||||
|
|
||||||
|
/* send data */
|
||||||
|
diff -Naur smap.orig/smap.c smap/smap.c
|
||||||
|
--- smap.orig/smap.c 2007-11-03 14:14:52.000000000 -0400
|
||||||
|
+++ smap/smap.c 2009-06-13 10:49:15.000000000 -0400
|
||||||
|
@@ -244,11 +244,11 @@
|
||||||
|
break;
|
||||||
|
case 't': /* TCP transport */
|
||||||
|
/* UDP is default so TCP would override it */
|
||||||
|
- config.flags ^= FLAG_UDP_TRANSPORT;
|
||||||
|
+ config.flags &= ~FLAG_UDP_TRANSPORT;
|
||||||
|
config.flags |= FLAG_TCP_TRANSPORT;
|
||||||
|
break;
|
||||||
|
case 'u': /* UDP transport */
|
||||||
|
- config.flags ^= FLAG_TCP_TRANSPORT;
|
||||||
|
+ config.flags &= ~FLAG_TCP_TRANSPORT;
|
||||||
|
config.flags |= FLAG_UDP_TRANSPORT;
|
||||||
|
break;
|
||||||
|
case 'r': /* ratelimit messages/sec */
|
||||||
|
diff -Naur smap.orig/transport_udp.c smap/transport_udp.c
|
||||||
|
--- smap.orig/transport_udp.c 2008-08-20 09:02:57.000000000 -0400
|
||||||
|
+++ smap/transport_udp.c 2009-06-13 11:56:15.000000000 -0400
|
||||||
|
@@ -52,6 +52,7 @@
|
||||||
|
extern int udp_sendsock;
|
||||||
|
extern struct sockaddr_in udp_sendsock_sockaddr;
|
||||||
|
int sockaddrlen;
|
||||||
|
+ int one;
|
||||||
|
|
||||||
|
/* is 5060 (DEFAULT_SIP_PORT) available?
|
||||||
|
* if yes, we'll use it since some clients send responses to
|
||||||
|
@@ -116,6 +117,13 @@
|
||||||
|
error(ERR_DEBUG, "bind() successful");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ one = 1;
|
||||||
|
+ if (setsockopt(udp_sendsock, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) != 0) {
|
||||||
|
+ perror("setsockopt");
|
||||||
|
+ error(ERR_ERROR, "unable to set socket to broadcast");
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (getsockname(udp_sendsock, (struct sockaddr *) &udp_sendsock_sockaddr,
|
||||||
|
(socklen_t *) &sockaddrlen) != 0)
|
||||||
|
if (DEBUG) perror("getsocknameudp_sendsock");
|
12
smap/patches/01-add-tecom-supported-header.patch
Normal file
12
smap/patches/01-add-tecom-supported-header.patch
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
diff -Naur smap.broadcast/test_supported.c smap/test_supported.c
|
||||||
|
--- smap.broadcast/test_supported.c 2009-06-14 21:41:49.000000000 -0400
|
||||||
|
+++ smap/test_supported.c 2009-06-14 21:51:17.000000000 -0400
|
||||||
|
@@ -49,6 +49,8 @@
|
||||||
|
{"Supported: timer, 100rel, replaces, callerid", 13},
|
||||||
|
/* Cisco 79x0 */
|
||||||
|
{"Supported: replaces,join,norefersub", 14},
|
||||||
|
+ /* Tecom IP2007 */
|
||||||
|
+ {"Supported: 100rel,replaces", 15 },
|
||||||
|
{"", 0}
|
||||||
|
};
|
||||||
|
|
63
smap/patches/02-segfault-and-toofast-bugfixes.patch
Normal file
63
smap/patches/02-segfault-and-toofast-bugfixes.patch
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
diff -Naur smap.supported/config.h smap/config.h
|
||||||
|
--- smap.supported/config.h 2009-06-14 22:18:57.000000000 -0400
|
||||||
|
+++ smap/config.h 2009-06-24 16:36:50.000000000 -0400
|
||||||
|
@@ -113,6 +113,7 @@
|
||||||
|
|
||||||
|
#define DEFAULT_SIP_PORT 5060
|
||||||
|
#define DEFAULT_TIMEOUT 500 /* in ms */
|
||||||
|
+#define DEFAULT_RATELIMIT 25
|
||||||
|
|
||||||
|
/* randomizer related ********************************************************/
|
||||||
|
enum { RAND_CALLID = 1, RAND_TAG, RAND_CSEQ, RAND_BRANCH };
|
||||||
|
diff -Naur smap.supported/listener.c smap/listener.c
|
||||||
|
--- smap.supported/listener.c 2009-06-14 22:18:57.000000000 -0400
|
||||||
|
+++ smap/listener.c 2009-06-15 04:36:40.000000000 -0400
|
||||||
|
@@ -130,7 +130,7 @@
|
||||||
|
/* use Call-ID to match response to requests */
|
||||||
|
callid = response_getcallid(msg);
|
||||||
|
if (callid == 0) {
|
||||||
|
- error(ERR_NOTICE, "could not parse Call-ID");
|
||||||
|
+ error(ERR_DEBUG, "could not parse Call-ID");
|
||||||
|
goto nextmsg;
|
||||||
|
}
|
||||||
|
state = state_lookup_by_callid(callid);
|
||||||
|
diff -Naur smap.supported/results.c smap/results.c
|
||||||
|
--- smap.supported/results.c 2009-06-14 22:18:57.000000000 -0400
|
||||||
|
+++ smap/results.c 2009-06-24 16:38:00.000000000 -0400
|
||||||
|
@@ -39,6 +39,7 @@
|
||||||
|
(task->results & RES_ICMP_REACH) ? "reachable" : "unreachable",
|
||||||
|
(task->results & RES_SIP_ENABLED) ? "enabled" : "disabled");
|
||||||
|
if (task->results & RES_SIP_ENABLED)
|
||||||
|
+ error(ERR_DEBUG, "Looking up fingerprint");
|
||||||
|
fingerprint_lookup(*task->fp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
diff -Naur smap.supported/smap.c smap/smap.c
|
||||||
|
--- smap.supported/smap.c 2009-06-14 22:18:57.000000000 -0400
|
||||||
|
+++ smap/smap.c 2009-06-24 17:09:39.000000000 -0400
|
||||||
|
@@ -197,7 +197,7 @@
|
||||||
|
config.sip_port = DEFAULT_SIP_PORT;
|
||||||
|
config.sip_domain = NULL;
|
||||||
|
config.timeout = DEFAULT_TIMEOUT;
|
||||||
|
- config.ratelimit = 0;
|
||||||
|
+ config.ratelimit = DEFAULT_RATELIMIT;
|
||||||
|
|
||||||
|
printf("\nsmap %s <hs@123.org> "
|
||||||
|
"http://www.wormulon.net/\n\n", SMAP_VERSION);
|
||||||
|
@@ -338,12 +338,15 @@
|
||||||
|
break; /* make gcc happy */
|
||||||
|
}
|
||||||
|
error_while_scanning:
|
||||||
|
-
|
||||||
|
pthread_join(pth_worker, NULL);
|
||||||
|
pthread_kill(pth_worker, SIGINT);
|
||||||
|
pthread_kill(pth_listener, SIGINT);
|
||||||
|
stats_dump();
|
||||||
|
|
||||||
|
+ signal(SIGINT, SIG_DFL);
|
||||||
|
+ signal(SIGTERM, SIG_DFL);
|
||||||
|
+ signal(SIGKILL, SIG_DFL);
|
||||||
|
+
|
||||||
|
/* clean up */
|
||||||
|
pthread_mutex_destroy(&scrlock);
|
||||||
|
pthread_mutex_destroy(&tasklock);
|
Loading…
Reference in a new issue