From: Paul B. S. <pa...@us...> - 2001-09-03 18:41:11
|
Update of /cvsroot/linux-atm/linux-atm/src/switch/debug In directory usw-pr-cvs1:/tmp/cvs-serv10656/switch/debug Added Files: Tag: V2_4_0 demo debug.c README Makefile.am Log Message: --- NEW FILE: demo --- #!/usr/bin/perl @cmd = ("xterm -fn 5x7 -geometry +25+400", "xterm -fn 5x7 -geometry +25+200", "xterm -fn 5x7 -geometry +450+200", "xterm -fn 5x7 -geometry +450+400", "xterm -fn 5x7 -geometry 132x24+110+0", "xterm -fn 5x7 -geometry +475+600", "xterm -fn 5x7 -geometry +0+600"); open(IN,"README") || die "open README: $!"; while (<IN>) { if (/^---\s*(\S+)\s*/) { if ($mode eq "F") { close OUT || die "close: $!"; } open(OUT,">$1") || die "create $1: $!"; $mode = "F"; next; } if (/^Preparation/) { $mode = "P"; next; } if (/^Start/) { $mode = "S"; next; } if ($mode eq "P") { chop; $_ .= " &" if /-l/; push(@do,$') if /^\s*#\s*/; next; } if ($mode eq "S") { chop; next unless /^\s*%\s*/; $c = $'; $c =~ s/-b/-d -l stderr/; $c =~ s/isp/isp -v/; $o = $c; $c = "sh -c \"$c; sleep 300\"" if $c =~ /isp/; push(@do,shift(@cmd)." -T '$o' -e $c &"); next; } if ($mode eq "F") { print OUT $_ || die "write: $!"; } } if ($mode eq "F") { close OUT || die "close: $!"; } for (@do) { print "$_\n"; system($_); sleep(1); } --- NEW FILE: debug.c --- /* debug.c - Simple debugging "switch" */ /* Written 1998-2000 by Werner Almesberger, EPFL DI-ICA */ #if HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <atm.h> #include <atmd.h> #include "uni.h" #include "../fab.h" #define COMPONENT "FAB(debug)" #define PRV(call) ((FAB *) (call)->fab) typedef struct _fab { CALL *next; /* relay.c may not keep track of calls, but WE are */ } FAB; static CALL *calls; void fab_option(const char *name,const char *value) { diag(COMPONENT,DIAG_FATAL,"unrecognized fabric option \"%s\"",name); } void fab_start(void (*port_notify)(int number,int up)) { sig_start_all(port_notify); } void fab_init(CALL *call) { PRV(call) = alloc_t(FAB); PRV(call)->next = calls; calls = call; } void fab_destroy(CALL *call) { CALL **walk; for (walk = &calls; *walk; walk = &PRV(*walk)->next) if (*walk == call) break; if (!*walk) diag(COMPONENT,DIAG_FATAL,"fab_destroy: call %p not found",call); *walk = PRV(call)->next; free(PRV(call)); PRV(call) = NULL; } /* * This function is rather simple-minded, because it only considers a single * port. Should go directly to the fabric control. @@@ */ static int vci_exists(int vci,int threshold) { CALL *call; int found; found = 0; for (call = calls; call; call = PRV(call)->next) if (call->in.pvc.sap_addr.vci == vci || call->out.pvc.sap_addr.vci == vci) if (++found > threshold) return 1; return 0; } static int check_ci(struct sockaddr_atmpvc *pvc) { int vci; if (pvc->sap_addr.vpi == ATM_VPI_ANY) pvc->sap_addr.vpi = 0; /* that was easy :-) */ for (vci = ATM_NOT_RSV_VCI; pvc->sap_addr.vci == ATM_VCI_ANY; vci++) if (!vci_exists(vci,0)) pvc->sap_addr.vci = vci; return !vci_exists(vci,1); } void fab_op(CALL *call,int op,const struct atm_qos *qos, void (*callback)(CALL *call,int cause,void *more,void *user),void *user) { diag(COMPONENT,DIAG_INFO,"fab_op%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", !op ? " FREE" : "",op & RM_RSV(_RM_ANY) ? " RM_RSV:" : "", op & RM_IN_TX ? " IN_TX" : "",op & RM_IN_RX ? " IN_RX" : "", op & RM_OUT_TX ? " OUT_TX" : "",op & RM_OUT_RX ? " OUT_RX" : "", op & RM_PATH_TX ? " PATH_TX" : "",op & RM_PATH_RX ? " PATH_RX" : "", op & RM_CLAIM(_RM_ANY) ? " RM_CLAIM:" : "", op & _RM_SHIFT(RM_IN_TX) ? " IN_TX" : "", op & _RM_SHIFT(RM_IN_RX) ? " IN_RX" : "", op & _RM_SHIFT(RM_OUT_TX) ? " OUT_TX" : "", op & _RM_SHIFT(RM_OUT_RX) ? " OUT_RX" : "", op & _RM_SHIFT(RM_PATH_TX) ? " PATH_TX" : "", op & _RM_SHIFT(RM_PATH_RX) ? " PATH_RX" : ""); if (op & (RM_RSV(RM_IN) | RM_CLAIM(RM_IN))) if (!check_ci(&call->in.pvc)) { callback(call,ATM_CV_CI_UNAVAIL,NULL,user); return; } if (op & (RM_RSV(RM_OUT) | RM_CLAIM(RM_OUT))) if (!check_ci(&call->out.pvc)) { callback(call,ATM_CV_CI_UNAVAIL,NULL,user); return; } callback(call,0,NULL,user); } --- NEW FILE: README --- This is a little sample configuration with two terminals connected to a switch. All of the network elements are on the same host and atmtcp takes care of the the real kernel with multiple terminals on the same machine. At least not yet.) Note that no data transfer or such is possible yet. This is only signaling. This is the example setup: +-------+ +------+ +-------+ | isp | |switch| | isp | |atmsigd|-----| |-----|atmsigd| +-------+ +------+ +-------+ Preparation (only once): # atmtcp virtual 1 listen-bg 8412 # atmtcp virtual 2 connect localhost 8412 bg # atmtcp virtual 3 listen-bg 8434 # atmtcp virtual 4 connect localhost 8434 bg # atmaddr -a 1 +123 Start the "network" (no privileges required): % atmsigd -b 1.0.105 /tmp/1 % atmsigd -b -m switch 2.0.105 /tmp/2 % atmsigd -b -m switch 3.0.105 /tmp/3 % atmsigd -b 4.0.105 /tmp/4 % ./sw_debug -d % isp /tmp/4 <4.isp % isp /tmp/1 <1.isp In more detail: +------------------------------------------+ | ./sw_debug | +------------------------------------------+ | | /tmp/2 /tmp/3 | | +----------------------------------+ +----------------------------------+ | atmsigd -m switch 2.0.105 /tmp/2 | | atmsigd -m switch 3.0.105 /tmp/3 | +----------------------------------+ +----------------------------------+ | | itf 2 | | | +--------------------------------------------+ | | atmtcp virtual 2 connect localhost 8412 bg | | +--------------------------------------------+ | | atmtcp virtual 1 listen-bg 8412 | | +--------------------------------------------+ itf 3 | | itf 1 +--------------------------------------------+ | | atmtcp virtual 3 listen-bg 8434 | | +--------------------------------------------+ | | atmtcp virtual 4 connect localhost 8434 bg | | +--------------------------------------------+ | | | itf 4 | | +------------------------+ +------------------------+ | atmsigd 1.0.105 /tmp/1 | | atmsigd 4.0.105 /tmp/4 | +------------------------+ +------------------------+ | | /tmp/1 /tmp/4 | | +-------------------+ +-------------------+ | isp /tmp/1 <1.isp | | isp /tmp/4 <4.isp | +-------------------+ +-------------------+ You can use the script "demo" to run this setup. You need to build the switch library and the debug switch first: cd ..; make cd debug; make --- switch.conf -------------------------------------------------------------- socket /tmp/2 { itf 2 2.0.5 route +1 } socket /tmp/3 { itf 3 2.0.5 default } --- 1.isp -------------------------------------------------------------------- send connect vcc=1 svc=+234 local=+123 qos=ubr,aal5 receive okay vcc=1 send close vcc=1 receive close vcc=1 --- 4.isp -------------------------------------------------------------------- send listen vcc=1 svc=+234 qos=ubr,aal5 receive okay vcc=1 receive indicate listen_vcc=1 send accept vcc=2 listen_vcc=1 receive okay vcc=2 receive close vcc=2 send close vcc=2 --- NEW FILE: Makefile.am --- noinst_PROGRAMS = sw_debug INCLUDES = -I$(top_builddir)/src/qgen sw_debug_SOURCES = debug.c sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \ $(top_builddir)/src/lib/libatmd.la \ $(top_builddir)/src/lib/libatm.la sw_debug_LDADD = $(sw_debug_XTRAS) -lfl sw_debug_DEPENDENCIES = $(sw_debug_XTRAS) EXTRA_DIST = demo README |