From: <kr...@us...> - 2007-03-02 22:29:39
|
Revision: 693 http://svn.sourceforge.net/astlinux/?rev=693&view=rev Author: krisk84 Date: 2007-03-02 14:29:39 -0800 (Fri, 02 Mar 2007) Log Message: ----------- add cdp-send support for CDP Modified Paths: -------------- trunk/package/Config.in Added Paths: ----------- trunk/package/cdp-send/ trunk/package/cdp-send/Config.in trunk/package/cdp-send/cdp-send-vvlan.patch trunk/package/cdp-send/cdp-send.mk Modified: trunk/package/Config.in =================================================================== --- trunk/package/Config.in 2007-03-02 20:01:49 UTC (rev 692) +++ trunk/package/Config.in 2007-03-02 22:29:39 UTC (rev 693) @@ -50,6 +50,7 @@ source "package/bluez/Config.in" source "package/boa/Config.in" source "package/bridge/Config.in" +source "package/cdp-send/Config.in" source "package/chansccp/Config.in" source "package/customize/Config.in" source "package/dhcp/Config.in" Added: trunk/package/cdp-send/Config.in =================================================================== --- trunk/package/cdp-send/Config.in (rev 0) +++ trunk/package/cdp-send/Config.in 2007-03-02 22:29:39 UTC (rev 693) @@ -0,0 +1,8 @@ +config BR2_PACKAGE_CDP-SEND + bool "cdp-send" + default n + help + cdp-send from the cdp-tools package + With AstLinux patches for voice VLAN support + + http://gpl.internetconnection.net/ Added: trunk/package/cdp-send/cdp-send-vvlan.patch =================================================================== --- trunk/package/cdp-send/cdp-send-vvlan.patch (rev 0) +++ trunk/package/cdp-send/cdp-send-vvlan.patch 2007-03-02 22:29:39 UTC (rev 693) @@ -0,0 +1,115 @@ +diff -ur cdp-tools.orig/cdp-send.c cdp-tools/cdp-send.c +--- cdp-tools.orig/cdp-send.c 2006-10-26 14:04:33.000000000 -0400 ++++ cdp-tools/cdp-send.c 2007-02-28 17:13:35.000000000 -0500 +@@ -2,6 +2,8 @@ + * cdp-send is part of cdp-tools. + * cdp-tools is (c) 2003-2006 Internet Connection, Inc. + * ++ * Voice VLAN support by Kristian Kielhofner <kr...@kr...> ++ * + * cdp-send is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) +@@ -37,6 +39,8 @@ + + static unsigned int use_vlanid = 0; + ++static unsigned int use_voiceid = 0; ++ + static unsigned char *use_ip_prefix = 0; + static unsigned int use_ip_prefix_len = 0; + +@@ -178,7 +182,7 @@ + + buffer+=sizeof(struct cdp_header); + +- buffer[0]=0x1; /* cdp version */ ++ buffer[0]=0x2; /* cdp version */ + buffer[1]=0xb4; /* cdp holdtime, 180 sec by default */ + buffer[2]=buffer[3]=0; /* checksum - will calculate later */ + +@@ -299,7 +303,7 @@ + if (duplex == 0) return 0; + if (len < 5) return 0; + sx_write_short(buffer,htons(0x000b)); /* type=port duplex */ +- sx_write_short(buffer+2,htons(1)); ++ sx_write_short(buffer+2,htons(5)); /* totallength*/ + buffer[4] = (duplex == 1 ? 1 : 0); + return 5; + } +@@ -309,11 +313,23 @@ + { + if (len < 6) return 0; + sx_write_short(buffer,htons(0x000a)); /* type=vlan id */ +- sx_write_short(buffer+2,htons(2)); ++ sx_write_short(buffer+2,htons(6)); /* totallength*/ + sx_write_short(buffer+4,htons(use_vlanid)); + return 6; + } + ++int ++cdp_add_voiceid(unsigned char* buffer, int len) ++{ ++ if (len < 7) return 0; ++ sx_write_short(buffer,htons(0x000e)); /* type=voice vlan id */ ++ sx_write_short(buffer+2,htons(7)); /* totallength*/ ++ sx_write_short(buffer+4,htons(0x1)); /*PAD*/ ++ sx_write_short(buffer+5,htons(use_voiceid)); ++ return 7; ++} ++ ++ + + unsigned short + cdp_checksum(unsigned char *ptr, int length) { +@@ -346,6 +362,7 @@ + " -d enable debugging output\n" + " -D dom specify VTP management domain (octal escapes ok)\n" + " -L vlan specify native VLAN (vlanid)\n" ++" -V vlan specify voice VLAN (voiceid)\n" + " -m mach specify machine/platform to advertise (e.g. \"%s\")\n" + " -n name specify a hostname\n" + " -p name override port name (default: interface)\n" +@@ -435,11 +452,12 @@ + struct cdp_interface *ifaces=NULL; + int specify_duplex = 0; + int specified_vlan = 0; ++ int specified_vvlan = 0; + int didcap = 0; + char *q; + + uname(&myuname); +- while((c=getopt(argc,argv,"a:c:dD:L:m:n:op:P:s:S:t:"))!=EOF) { ++ while((c=getopt(argc,argv,"a:c:dD:L:V:m:n:op:P:s:S:t:"))!=EOF) { + switch(c) { + case 'a': + if (inet_aton(optarg, &iaddr)) { +@@ -518,6 +536,15 @@ + specified_vlan=1; + use_vlanid = i; + break; ++ case 'V': ++ i = strtod(optarg, &q); ++ if ((q && *q) || i < 0 || i > 65535) { ++ fprintf(stderr, "Voice VLAN ID is an unsigned 16-bit integer\n"); ++ exit(1); ++ } ++ specified_vvlan=1; ++ use_voiceid = i; ++ break; + case 'm': + use_machine = strdup(optarg); + if (!use_machine) { +@@ -673,7 +700,11 @@ + if (specified_vlan) { + offset+=cdp_add_vlanid(buffer+offset, sizeof(buffer)-offset); + } +- ++ ++ if (specified_vvlan) { ++ offset+=cdp_add_voiceid(buffer+offset, sizeof(buffer)-offset); ++ } ++ + ((struct cdp_header*)buffer)->length=htons(offset-14); + + *(u_short*)(buffer+sizeof(struct cdp_header)+2)=cdp_checksum( Added: trunk/package/cdp-send/cdp-send.mk =================================================================== --- trunk/package/cdp-send/cdp-send.mk (rev 0) +++ trunk/package/cdp-send/cdp-send.mk 2007-03-02 22:29:39 UTC (rev 693) @@ -0,0 +1,49 @@ +############################################################# +# +# cdp-send support +# +############################################################# +CDP-SEND_SOURCE=cdp-tools.tar.gz +CDP-SEND_CAT:=zcat +CDP-SEND_SITE:=http://gpl.internetconnection.net/files +CDP-SEND_DIR=$(BUILD_DIR)/cdp-tools + +$(DL_DIR)/$(CDP-SEND_SOURCE): + $(WGET) -P $(DL_DIR) $(CDP-SEND_SITE)/$(CDP-SEND_SOURCE) + +$(CDP-SEND_DIR)/.patched: $(DL_DIR)/$(CDP-SEND_SOURCE) + $(CDP-SEND_CAT) $(DL_DIR)/$(CDP-SEND_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) - + toolchain/patch-kernel.sh $(CDP-SEND_DIR) package/cdp-send/ cdp-send\*.patch + touch $@ + +$(CDP-SEND_DIR)/cdp-send: $(CDP-SEND_DIR)/.patched + # We don't use the cdp-tools Makefile because it isn't worth it... + $(TARGET_CC) $(TARGET_CFLAGS) -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H \ + -I$(STAGING_DIR)/include -c -o $(CDP-SEND_DIR)/cdp-send.o $(CDP-SEND_DIR)/cdp-send.c + $(TARGET_CC) $(TARGET_CFLAGS) -o $(CDP-SEND_DIR)/cdp-send $(CDP-SEND_DIR)/cdp-send.o \ + $(STAGING_DIR)/lib/libnet.a + touch -c $(CDP-SEND_DIR)/cdp-send + +$(TARGET_DIR)/usr/sbin/cdp-send: $(CDP-SEND_DIR)/cdp-send + $(INSTALL) -D -m 0755 $(CDP-SEND_DIR)/cdp-send $(TARGET_DIR)/usr/sbin/cdp-send + -$(STRIP) $(TARGET_DIR)/usr/sbin/cdp-send + touch -c $(TARGET_DIR)/usr/sbin/cdp-send + +cdp-send: uclibc libnet $(TARGET_DIR)/usr/sbin/cdp-send + +cdp-send-source: $(DL_DIR)/$(CDP-SEND_SOURCE) + +cdp-send-clean: + rm -f $(TARGET_DIR)/usr/sbin/cdp-send + -$(MAKE) -C $(CDP-SEND_DIR) clean + +cdp-send-dirclean: + rm -rf $(CDP-SEND_DIR) +############################################################# +# +# Toplevel Makefile options +# +############################################################# +ifeq ($(strip $(BR2_PACKAGE_CDP-SEND)),y) +TARGETS+=cdp-send +endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |