tcpser/ 0040755 0000764 0001040 00000000000 10747540171 013244 5 ustar brain Administrators tcpser/.cdtproject 0100644 0000764 0001040 00000002773 10562020167 015405 0 ustar brain Administrators
-
-
-
make
-f Makefile.win32
all
false
false
-
tcpser/.cproject 0100644 0000764 0001040 00000003657 10742356416 015070 0 ustar brain Administrators
make
-f Makefile.win32
all
false
false
tcpser/.project 0100644 0000764 0001040 00000006743 10562022335 014712 0 ustar brain Administrators
tcpser
org.eclipse.cdt.make.core.makeBuilder
org.eclipse.cdt.core.errorOutputParser
org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;
org.eclipse.cdt.make.core.fullBuildTarget
clean all
org.eclipse.cdt.make.core.incrementalBuildTarget
all
org.eclipse.cdt.make.core.buildLocation
org.eclipse.cdt.make.core.enableAutoBuild
false
org.eclipse.cdt.make.core.enableFullBuild
true
org.eclipse.cdt.make.core.enabledIncrementalBuild
true
org.eclipse.cdt.make.core.enableCleanBuild
true
org.eclipse.cdt.make.core.cleanBuildTarget
clean
org.eclipse.cdt.make.core.useDefaultBuildCmd
false
org.eclipse.cdt.make.core.buildArguments
-f Makefile.win32
org.eclipse.cdt.make.core.buildCommand
make
org.eclipse.cdt.make.core.autoBuildTarget
all
org.eclipse.cdt.make.core.stopOnError
false
org.eclipse.cdt.make.core.ScannerConfigBuilder
org.eclipse.cdt.make.core.ScannerConfigDiscoveryEnabled
true
org.eclipse.cdt.make.core.makeBuilderParserId
org.eclipse.cdt.make.core.GCCScannerInfoConsoleParser
org.eclipse.cdt.make.core.esiProviderCommandEnabled
true
org.eclipse.cdt.make.core.siProblemGenerationEnabled
true
org.eclipse.cdt.make.core.useDefaultESIProviderCmd
true
org.eclipse.cdt.make.core.makeBuilderParserEnabled
true
org.eclipse.cdt.make.core.esiProviderParserId
org.eclipse.cdt.make.core.GCCSpecsConsoleParser
org.eclipse.cdt.core.cnature
org.eclipse.cdt.make.core.makeNature
org.eclipse.cdt.make.core.ScannerConfigNature
tcpser/.settings/ 0040755 0000764 0001040 00000000000 10574105513 015155 5 ustar brain Administrators tcpser/.settings/.svn/ 0040755 0000764 0001040 00000000000 10574105513 016041 5 ustar brain Administrators tcpser/.settings/.svn/all-wcprops 0100444 0000764 0001040 00000000324 10562022502 020212 0 ustar brain Administrators K 25
svn:wc:ra_dav:version-url
V 38
/svn/tcpser/!svn/ver/4/trunk/.settings
END
org.eclipse.cdt.core.prefs
K 25
svn:wc:ra_dav:version-url
V 65
/svn/tcpser/!svn/ver/4/trunk/.settings/org.eclipse.cdt.core.prefs
END
tcpser/.settings/.svn/entries 0100444 0000764 0001040 00000000552 10562022502 017423 0 ustar brain Administrators 8
dir
5
http://www.jimbrain.com/svn/tcpser/trunk/.settings
http://www.jimbrain.com/svn/tcpser
2007-02-06T06:43:32.577387Z
4
brain
svn:special svn:externals svn:needs-lock
8602611e-c928-0410-ae49-afcc62ab246b
org.eclipse.cdt.core.prefs
file
2007-02-06T06:50:41.680046Z
3f613fdb51fe217b12933b9b3b900bc7
2007-02-06T06:43:32.577387Z
4
brain
tcpser/.settings/.svn/format 0100444 0000764 0001040 00000000002 10562022502 017230 0 ustar brain Administrators 8
tcpser/.settings/.svn/prop-base/ 0040755 0000764 0001040 00000000000 10574105513 017731 5 ustar brain Administrators tcpser/.settings/.svn/props/ 0040755 0000764 0001040 00000000000 10574105513 017204 5 ustar brain Administrators tcpser/.settings/.svn/text-base/ 0040755 0000764 0001040 00000000000 10574105513 017735 5 ustar brain Administrators tcpser/.settings/.svn/text-base/org.eclipse.cdt.core.prefs.svn-base 0100444 0000764 0001040 00000000152 10562022502 026407 0 ustar brain Administrators #Sun Feb 04 01:47:17 CST 2007
eclipse.preferences.version=1
indexerId=org.eclipse.cdt.core.fastIndexer
tcpser/.settings/.svn/tmp/ 0040755 0000764 0001040 00000000000 10574105513 016641 5 ustar brain Administrators tcpser/.settings/.svn/tmp/prop-base/ 0040755 0000764 0001040 00000000000 10574105513 020531 5 ustar brain Administrators tcpser/.settings/.svn/tmp/props/ 0040755 0000764 0001040 00000000000 10574105513 020004 5 ustar brain Administrators tcpser/.settings/.svn/tmp/text-base/ 0040755 0000764 0001040 00000000000 10574105513 020535 5 ustar brain Administrators tcpser/.settings/org.eclipse.cdt.core.prefs 0100644 0000764 0001040 00000000236 10742356416 022135 0 ustar brain Administrators #Sun Jan 13 03:42:38 CST 2008
eclipse.preferences.version=1
indexer/indexerId=org.eclipse.cdt.core.fastIndexer
indexerId=org.eclipse.cdt.core.fastIndexer
tcpser/.svn/ 0040755 0000764 0001040 00000000000 10747537570 014141 5 ustar brain Administrators tcpser/.svn/all-wcprops 0100444 0000764 0001040 00000001307 10562025525 016306 0 ustar brain Administrators K 25
svn:wc:ra_dav:version-url
V 28
/svn/tcpser/!svn/ver/4/trunk
END
.cdtproject
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/4/trunk/.cdtproject
END
.project
K 25
svn:wc:ra_dav:version-url
V 37
/svn/tcpser/!svn/ver/6/trunk/.project
END
Makefile.solaris
K 25
svn:wc:ra_dav:version-url
V 46
/svn/tcpser/!svn/ver/24/trunk/Makefile.solaris
END
CHANGES
K 25
svn:wc:ra_dav:version-url
V 37
/svn/tcpser/!svn/ver/24/trunk/CHANGES
END
Makefile
K 25
svn:wc:ra_dav:version-url
V 38
/svn/tcpser/!svn/ver/24/trunk/Makefile
END
README
K 25
svn:wc:ra_dav:version-url
V 36
/svn/tcpser/!svn/ver/24/trunk/README
END
Makefile.win32
K 25
svn:wc:ra_dav:version-url
V 44
/svn/tcpser/!svn/ver/24/trunk/Makefile.win32
END
tcpser/.svn/entries 0100444 0000764 0001040 00000002104 10747537570 015525 0 ustar brain Administrators 8
dir
5
http://www.jimbrain.com/svn/tcpser/trunk
http://www.jimbrain.com/svn/tcpser
2007-02-06T06:43:32.577387Z
4
brain
svn:special svn:externals svn:needs-lock
8602611e-c928-0410-ae49-afcc62ab246b
.cdtproject
file
2007-02-06T06:50:41.770176Z
091a4507f45b56fb0126d5d2c49ec9ac
2007-02-06T06:43:32.577387Z
4
brain
.project
file
6
2007-02-06T06:49:01.495988Z
dc563887f0068cbc319519aa5b312691
2007-02-06T07:04:10.627566Z
6
brain
src
dir
Makefile.solaris
file
24
2006-06-15T08:40:42.000000Z
a3c8e2e5702eb2062874a4adb6d21c96
2007-02-06T07:26:33.108543Z
24
brain
CHANGES
file
25
2008-01-29T05:53:50.866548Z
49dc9550b8aa72765108b6f1a61408e8
2007-02-06T07:26:33.108543Z
24
brain
Makefile
file
24
2006-06-15T08:41:04.000000Z
640e4f08da77487652f701e0ba4384ad
2007-02-06T07:26:33.108543Z
24
brain
README
file
25
2008-01-29T05:53:59.508976Z
384433c2157e77175f88ac27576adab8
2007-02-06T07:26:33.108543Z
24
brain
.settings
dir
Makefile.win32
file
24
2006-06-14T05:06:06.000000Z
6c03531002942eeb55bd3d9b5cf67312
2007-02-06T07:26:33.108543Z
24
brain
tcpser/.svn/format 0100444 0000764 0001040 00000000002 10562022500 015310 0 ustar brain Administrators 8
tcpser/.svn/prop-base/ 0040755 0000764 0001040 00000000000 10574105513 016013 5 ustar brain Administrators tcpser/.svn/props/ 0040755 0000764 0001040 00000000000 10574105513 015266 5 ustar brain Administrators tcpser/.svn/text-base/ 0040755 0000764 0001040 00000000000 10574105513 016017 5 ustar brain Administrators tcpser/.svn/text-base/.cdtproject.svn-base 0100444 0000764 0001040 00000002773 10562022500 021671 0 ustar brain Administrators
-
-
-
make
-f Makefile.win32
all
false
false
-
tcpser/.svn/text-base/.project.svn-base 0100444 0000764 0001040 00000006743 10562022335 021205 0 ustar brain Administrators
tcpser
org.eclipse.cdt.make.core.makeBuilder
org.eclipse.cdt.core.errorOutputParser
org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;
org.eclipse.cdt.make.core.fullBuildTarget
clean all
org.eclipse.cdt.make.core.incrementalBuildTarget
all
org.eclipse.cdt.make.core.buildLocation
org.eclipse.cdt.make.core.enableAutoBuild
false
org.eclipse.cdt.make.core.enableFullBuild
true
org.eclipse.cdt.make.core.enabledIncrementalBuild
true
org.eclipse.cdt.make.core.enableCleanBuild
true
org.eclipse.cdt.make.core.cleanBuildTarget
clean
org.eclipse.cdt.make.core.useDefaultBuildCmd
false
org.eclipse.cdt.make.core.buildArguments
-f Makefile.win32
org.eclipse.cdt.make.core.buildCommand
make
org.eclipse.cdt.make.core.autoBuildTarget
all
org.eclipse.cdt.make.core.stopOnError
false
org.eclipse.cdt.make.core.ScannerConfigBuilder
org.eclipse.cdt.make.core.ScannerConfigDiscoveryEnabled
true
org.eclipse.cdt.make.core.makeBuilderParserId
org.eclipse.cdt.make.core.GCCScannerInfoConsoleParser
org.eclipse.cdt.make.core.esiProviderCommandEnabled
true
org.eclipse.cdt.make.core.siProblemGenerationEnabled
true
org.eclipse.cdt.make.core.useDefaultESIProviderCmd
true
org.eclipse.cdt.make.core.makeBuilderParserEnabled
true
org.eclipse.cdt.make.core.esiProviderParserId
org.eclipse.cdt.make.core.GCCSpecsConsoleParser
org.eclipse.cdt.core.cnature
org.eclipse.cdt.make.core.makeNature
org.eclipse.cdt.make.core.ScannerConfigNature
tcpser/.svn/text-base/CHANGES.svn-base 0100444 0000764 0001040 00000002736 10445277232 020537 0 ustar brain Administrators 1.0
Initial release
1.0rc2
Cleaned up code
10.rc3
changed char fields to unsigned char
Changed many functions to return status
Added macros for __FUNCTION__ keyword, for compiler sanity
Added include headers needed for other UNIX platforms
1.0rc4
Changed cfg->connection to cfg->conn_type
Added support for send file text to connections on actions
If data received while off-hook and no conn, go on-hook.
Clean up parseRegister action in getcmd.c
Add support for ':' and '-' extended commands
Cleaned up functions to only exit at one point
1.0rc5
Moved includes to be in correct order
Fixed Q0 and Q1 (they were reversed)
1.0rc6
Add support for direct connection
1.0rc7
Fixed mislocated tcsetattr in serial.com:ser_init_conn
1.0rc8
Fixed bug in ip_thread (calling a null number would turn on ip_thread, but no connection, generating a dump
Fixed bugs in dce_set_flow_control
Fixed behavior of parms parsing for &Z (complex) and S (simple)
Defaulted code to not assume /dev/ttyS0 as serport
1.0rc9
Fixed bug that would stop first session if second call came in
Fixed outbound call not bringing DCD high.
1.0rc10
Added some more debugging information
Changed logging to go to stdout from stderr
Fixed Phone book matching function to use logger
1.0rc11
Added ip232 support with custom protocol for use with matching modified version of WinVICE 1.19
Added full support for Telnet Binary Transmission (RFC 856)
tcpser/.svn/text-base/Makefile.solaris.svn-base 0100444 0000764 0001040 00000001576 10444216412 022650 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall
LDFLAGS = -lpthread -lsocket -lnsl -lresolv
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/.svn/text-base/Makefile.svn-base 0100444 0000764 0001040 00000001604 10444216440 021166 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall
LDFLAGS = -lpthread
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/.svn/text-base/Makefile.win32.svn-base 0100444 0000764 0001040 00000001607 10443714476 022145 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall -DWIN32
LDFLAGS =
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser.exe *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/.svn/text-base/README.svn-base 0100444 0000764 0001040 00000015656 10445277620 020432 0 ustar brain Administrators
README
Application:
TCPSER turns a PC serial port into an emulated Hayes compatible modem that
uses TCP/IP for incoming and outgoing connections. It can be used to allow
older applications and systems designed for modem use to operate on the
Internet. TCPSER supports all standard Hayes commands, and understands
extended and vendor proprietary commands (though it does not implement
many of them). TCPSER can be used for both inbound and outbound connections.
License:
TCPSER is distributed under the GPL 2.0 or later
Executable/Building:
UNIX/Linux/BSD:
Simply untar the archive into a directory, and use the appropriate make command
generate the exectutable. If unsure, try the default make command first.
Default/Linux: make
Solaris: make -f Makefile.solaris
*BSD: gmake
Windows 95/OSR2/98/SE/ME/NT/2000/XP/2003:
The application archive contains a pregenerated Windows 32 bit executable
(tcpser.exe). No compilation should be required, though the GNU toolchain and
the CYGWIN POSIX libraries can be used to regenerate the executable if desired:
Win32: make -f Makefile.win32
Note that at least the cygwin1.dll library is required to operate tcpser under
Windows. I recommend downloading a recent version from www.cygwin.com
This version of tcpser supports setting up an ip232 port instead of using a
real serial port. This is for use with the version of WinVICE 1.19 that has
the ACIA fix and ip232 support, allowing WinVICE to use tcpser as if it was
connected via a serial cable.
Operation:
tcpser -d -s -l -t ...
-or-
tcpser -v -s -l -t ...
samples:
tcpser -d /dev/ttyS0 -s 38400 -l 7 -tsSiI -i "s0=1" -p 6400
Will start tcpser on ttyS0 at 38400 bps, level 7 logging, tracing of
inbound serial, outbound serial, inbound IP, outbound IP, init
modem to answer after 1 ring, and listen for incoming connections on port
6400
tcpser -v 25232 -s 38400 -l 4 -p 23
Will set up an ip232 port at 25232, report 38400 bps connections,
level 4 logging, and listen for incoming connections on port 23.
tcpser -h will provide additional information
tcpser can be configured to send the contents of a file upon:
connect ; -c -C
answer ; -a -A
no-answer ; -I
busy ; -B
inactivity-timeout ; -T
For connect and answer, there are separate options for sending a file to the
local serial connection (-c, -a) and the remote IP connection (-C, -A).
If tcpser connects to a telnet service, tcpser will negotiate the connection
using the telnet protocol. If telnet is detected, then tcpser will support
RFC 856 (Telnet Binary Transmission), so that 8-bit file transfers will
work correctly.
tcpser can be configured to support multiple serial/ip232 ports on one TCP/IP
port. Simply repeat the -s and -d/-v parameters on the command line for each
serial/ip232 port to be configured. Options s,S,a,A,c,C,I, and T will
"propagate" to subsequent connections, unless they are redefined. Defaults
for s and S are 38400. This configuration enables the operation of a
multi-line BBS on one TCP/IP port.
Frequently used addresses can be configured in the "phonebook", like so:
tcpser .... -nhome=jbrain.com:6400
This is also useful for systems that do not accept non-numeric phone numbers:
tcpser .... -n5551212=bestbbs.net
One can even "hide" a regular IP address or DNS entry by aliasing it to
something else:
tcpser .... -njbrain.com=bestbbs.com
At this point, phonebook support is very alpha, so use with care.
Emulation:
All of the standard Hayes commands should behave as expected. Some of
of the proprietary commands are not implemented, but should not cause
errors.
Examples:
ats0=1 ; set number of rings to answer
ata ; answer the line
ath0 ; hang up
ats12? ; query S register 12
ate0 ; turn off echo
at&k3 ; set flow control to RTS/CTS
atdtjbrain.com:6400 ; "dial" jbrain.com, port 6400 (defaults to port 23)
atdl ; "dial" last number
a/ ; repeat last command
Commands can be chained, as on a regular modem:
ats0=1z&c1&k3%f0s3=13dtjbrain.com
tcpser supports the Hayes break sequence semantics, so +++ should operate
correctly, even if the sequence of characters is used in normal data
transmissions.i
Cable:
tcpser can be used with a regular null modem cable, but it utilizes the DTR
line on the PC serial port to reflect the state of the DCD line as seen by the
target system. On a normal null-modem cable, DTR is mapped to DCD/DSR, which
implies DSR will also reflect the state of DCD on the target machine. However,
some systems (notably those utilizing the 6551 ACIA communication IC) will not
transmit unless DSR is held high. In this case, a quick qorkaround is to force
DCD to be held high by adding -i"&c0" to the tcpser parameter list. However,
this also prevents normal operation of the DCD line, which is needed by some
BBS systems. A more permanent solution is to construct a modified null-modem
cable or modify an existing cable to the following specifications:
PC Target
CTS-----RTS
RTS-----CTS
SND-----RCV
RCV-----SND
DTR-----DCD
DCD-+-+-DTR
| |
DSR-+ +-DSR
GND-----GND
This differs from a regular null-modem cable in that the target machine has DSR
looped to DTR, not to DCD. Note that this cable is directional.
Normally, the target machine will configure DSR to float to a high state if
unconnected. As well, PCs do not require a valid DSR line for operation. Thus,
a simpler cable can be constructed that is bi-directional:
CTS-----RTS
RTS-----CTS
SND-----RCV
RCV-----SND
DTR-----DCD
DCD-----DTR
GND-----GND
Unless there are issues, we recommend this simplified version, as it can be
installed in either direction.
As an even simpler solution, many have simply taken a normal rs232 DE-9F to
DE-9M cable and removed pin 6 from the male end (DSR). This is fine, but the
cable must be installed between the null modem adapter and the target machine:
PC ----- null-modem adapter ----- cable with pin 6 removed ------ target machine
Any other configuration will not work correctly.
Platform notes:
Win32 users should use /dev/ttyS0-3 for COM1-4. At present, using "com1:"
does not operate correctly.
This has been tested on the following platforms:
Linux 2.4.20-8
Windows XP
Windows XP SP1
Slackware 10.0
Help:
tcpser has a small but active user community. Help can be found by asking a
question in comp.sys.cbm, on the NEWNet #c64friends IRC channel, or by emailing
the author.
-----------------------------------
Jim Brain
brain@jbrain.com
www.jbrain.com
The ip232 support was added by Anthony Tolle. For questions regarding that,
e-mail atolle@gcns.com
tcpser/.svn/tmp/ 0040755 0000764 0001040 00000000000 10747537570 014741 5 ustar brain Administrators tcpser/.svn/tmp/prop-base/ 0040755 0000764 0001040 00000000000 10574105512 016612 5 ustar brain Administrators tcpser/.svn/tmp/props/ 0040755 0000764 0001040 00000000000 10574105512 016065 5 ustar brain Administrators tcpser/.svn/tmp/text-base/ 0040755 0000764 0001040 00000000000 10574105512 016616 5 ustar brain Administrators tcpser/bridge 0100644 0000764 0001040 00000000131 10314630070 014377 0 ustar brain Administrators tcpser-1.0rc10/tcpser -d /dev/ttyS1 -s 1200 -i"e0" -tsS -n"5551212=ltshosting.net:5190"
tcpser/CHANGES 0100644 0000764 0001040 00000003106 10747533047 014240 0 ustar brain Administrators 1.0
Initial release
1.0rc2
Cleaned up code
10.rc3
changed char fields to unsigned char
Changed many functions to return status
Added macros for __FUNCTION__ keyword, for compiler sanity
Added include headers needed for other UNIX platforms
1.0rc4
Changed cfg->connection to cfg->conn_type
Added support for send file text to connections on actions
If data received while off-hook and no conn, go on-hook.
Clean up parseRegister action in getcmd.c
Add support for ':' and '-' extended commands
Cleaned up functions to only exit at one point
1.0rc5
Moved includes to be in correct order
Fixed Q0 and Q1 (they were reversed)
1.0rc6
Add support for direct connection
1.0rc7
Fixed mislocated tcsetattr in serial.com:ser_init_conn
1.0rc8
Fixed bug in ip_thread (calling a null number would turn on ip_thread, but no connection, generating a dump
Fixed bugs in dce_set_flow_control
Fixed behavior of parms parsing for &Z (complex) and S (simple)
Defaulted code to not assume /dev/ttyS0 as serport
1.0rc9
Fixed bug that would stop first session if second call came in
Fixed outbound call not bringing DCD high.
1.0rc10
Added some more debugging information
Changed logging to go to stdout from stderr
Fixed Phone book matching function to use logger
1.0rc11
Added ip232 support with custom protocol for use with matching modified version of WinVICE 1.19
Added full support for Telnet Binary Transmission (RFC 856)
1.0rc12
Added code to hook SIG_IO to SIG_IGN. Newer versions of Linux are terminating when IO arrives.
tcpser/Makefile 0100644 0000764 0001040 00000001604 10444216440 014673 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall
LDFLAGS = -lpthread
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/Makefile.solaris 0100644 0000764 0001040 00000001576 10444216412 016355 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall
LDFLAGS = -lpthread -lsocket -lnsl -lresolv
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/Makefile.win32 0100644 0000764 0001040 00000001607 10443714476 015652 0 ustar brain Administrators SRC=src
SRCS = $(SRC)/bridge.c $(SRC)/debug.c $(SRC)/getcmd.c $(SRC)/ip.c $(SRC)/init.c $(SRC)/modem_core.c $(SRC)/nvt.c $(SRC)/serial.c $(SRC)/ip232.c $(SRC)/util.c $(SRC)/phone_book.c $(SRC)/shared.c $(SRC)/tcpser.c $(SRC)/line.c $(SRC)/dce.c
OBJS = $(SRC)/bridge.o $(SRC)/debug.o $(SRC)/getcmd.o $(SRC)/ip.o $(SRC)/init.o $(SRC)/modem_core.o $(SRC)/nvt.o $(SRC)/serial.o $(SRC)/ip232.o $(SRC)/util.o $(SRC)/phone_book.o $(SRC)/shared.o $(SRC)/tcpser.o $(SRC)/dce.o $(SRC)/line.o
CC = gcc
DEF =
CFLAGS = -O $(DEF) -Wall -DWIN32
LDFLAGS =
DEPEND = makedepend $(DEF) $(CFLAGS)
all: tcpser
#.o.c:
# $(CC) $(CFLAGS) -c $*.c
$(SRCS):
$(CC) $(CFLAGS) -c $*.c
tcpser: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
depend: $(SRCS)
$(DEPEND) $(SRCS)
clean:
-rm tcpser.exe *.bak $(SRC)/*~ $(SRC)/*.o $(SRC)/*.bak core
# DO NOT DELETE THIS LINE -- make depend depends on it.
tcpser/README 0100644 0000764 0001040 00000016640 10747532642 014134 0 ustar brain Administrators
README
Application:
TCPSER turns a PC serial port into an emulated Hayes compatible modem that
uses TCP/IP for incoming and outgoing connections. It can be used to allow
older applications and systems designed for modem use to operate on the
Internet. TCPSER supports all standard Hayes commands, and understands
extended and vendor proprietary commands (though it does not implement
many of them). TCPSER can be used for both inbound and outbound connections.
License:
TCPSER is distributed under the GPL 2.0 or later
Executable/Building:
UNIX/Linux/BSD:
Simply untar the archive into a directory, and use the appropriate make command
generate the exectutable. If unsure, try the default make command first.
Default/Linux: make
Solaris: make -f Makefile.solaris
*BSD: gmake
Windows 95/OSR2/98/SE/ME/NT/2000/XP/2003:
The application archive contains a pregenerated Windows 32 bit executable
(tcpser.exe). No compilation should be required, though the GNU toolchain and
the CYGWIN POSIX libraries can be used to regenerate the executable if desired:
Win32: make -f Makefile.win32
Note that at least the cygwin1.dll library is required to operate tcpser under
Windows. I recommend downloading a recent version from www.cygwin.com
This version of tcpser supports setting up an ip232 port instead of using a
real serial port. This is for use with the version of WinVICE 1.19 that has
the ACIA fix and ip232 support, allowing WinVICE to use tcpser as if it was
connected via a serial cable.
Operation:
tcpser -d -s -l -t ...
-or-
tcpser -v -s -l -t ...
samples:
tcpser -d /dev/ttyS0 -s 38400 -l 7 -tsSiI -i "s0=1" -p 6400
Will start tcpser on ttyS0 at 38400 bps, level 7 logging, tracing of
inbound serial, outbound serial, inbound IP, outbound IP, init
modem to answer after 1 ring, and listen for incoming connections on port
6400
tcpser -v 25232 -s 38400 -l 4 -p 23
Will set up an ip232 port at 25232, report 38400 bps connections,
level 4 logging, and listen for incoming connections on port 23.
tcpser -h will provide additional information
tcpser can be configured to send the contents of a file upon:
connect ; -c -C
answer ; -a -A
no-answer ; -I
busy ; -B
inactivity-timeout ; -T
For connect and answer, there are separate options for sending a file to the
local serial connection (-c, -a) and the remote IP connection (-C, -A).
If tcpser connects to a telnet service, tcpser will negotiate the connection
using the telnet protocol. If telnet is detected, then tcpser will support
RFC 856 (Telnet Binary Transmission), so that 8-bit file transfers will
work correctly.
tcpser can be configured to support multiple serial/ip232 ports on one TCP/IP
port. Simply repeat the -s and -d/-v parameters on the command line for each
serial/ip232 port to be configured. Options s,S,a,A,c,C,I, and T will
"propagate" to subsequent connections, unless they are redefined. Defaults
for s and S are 38400. This configuration enables the operation of a
multi-line BBS on one TCP/IP port.
Frequently used addresses can be configured in the "phonebook", like so:
tcpser .... -nhome=jbrain.com:6400
This is also useful for systems that do not accept non-numeric phone numbers:
tcpser .... -n5551212=bestbbs.net
One can even "hide" a regular IP address or DNS entry by aliasing it to
something else:
tcpser .... -njbrain.com=bestbbs.com
At this point, phonebook support is very alpha, so use with care.
Emulation:
All of the standard Hayes commands should behave as expected. Some of
of the proprietary commands are not implemented, but should not cause
errors.
Examples:
ats0=1 ; set number of rings to answer
ata ; answer the line
ath0 ; hang up
ats12? ; query S register 12
ate0 ; turn off echo
at&k3 ; set flow control to RTS/CTS
atdtjbrain.com:6400 ; "dial" jbrain.com, port 6400 (defaults to port 23)
atdl ; "dial" last number
a/ ; repeat last command
Commands can be chained, as on a regular modem:
ats0=1z&c1&k3%f0s3=13dtjbrain.com
tcpser supports the Hayes break sequence semantics, so +++ should operate
correctly, even if the sequence of characters is used in normal data
transmissions.i
Cable:
tcpser can be used with a regular null modem cable, but it utilizes the DTR
line on the PC serial port to reflect the state of the DCD line as seen by the
target system. On a normal null-modem cable, DTR is mapped to DCD/DSR, which
implies DSR will also reflect the state of DCD on the target machine. However,
some systems (notably those utilizing the 6551 ACIA communication IC) will not
transmit unless DSR is held high. In this case, a quick qorkaround is to force
DCD to be held high by adding -i"&c0" to the tcpser parameter list. However,
this also prevents normal operation of the DCD line, which is needed by some
BBS systems. A more permanent solution is to construct a modified null-modem
cable or modify an existing cable to the following specifications:
PC Target
CTS-----RTS
RTS-----CTS
SND-----RCV
RCV-----SND
DTR-----DCD
DCD-+-+-DTR
| |
DSR-+ +-DSR
GND-----GND
This differs from a regular null-modem cable in that the target machine has DSR
looped to DTR, not to DCD. Note that this cable is directional.
Normally, the target machine will configure DSR to float to a high state if
unconnected. As well, PCs do not require a valid DSR line for operation. Thus,
a simpler cable can be constructed that is bi-directional:
CTS-----RTS
RTS-----CTS
SND-----RCV
RCV-----SND
DTR-----DCD
DCD-----DTR
GND-----GND
Unless there are issues, we recommend this simplified version, as it can be
installed in either direction.
As an even simpler solution, many have simply taken a normal rs232 DE-9F to
DE-9M cable and removed pin 6 from the male end (DSR). This is fine, but the
cable must be installed between the null modem adapter and the target machine:
PC ----- null-modem adapter ----- cable with pin 6 removed ------ target machine
Any other configuration will not work correctly.
Platform notes:
Win32 users should use /dev/ttyS0-3 for COM1-4. At present, using "com1:"
does not operate correctly.
Raymond Day sends the following Ubuntu 7.10 autorun scripts:
In:
/etc/init.d/
Make a file named something like tcpser with this code in it:
#!/bin/sh
# Start tcpser at 1200 boud on both RS232 ports for Q-Link Reloaded.
case "$1" in
'start')
tcpser -d /dev/ttyS0 -s 1200 -i"e0&k0&c0" -n"5551212"=66.135.39.36:5190&
tcpser -d /dev/ttyS1 -p 6401 -s 1200 -i"e0&k0&c0" -n"5551212"=66.135.39.36:5190&
;;
'stop')
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
This has been tested on the following platforms:
Linux 2.4.20-8
Windows XP
Windows XP SP1
Slackware 10.0
Help:
tcpser has a small but active user community. Help can be found by asking a
question in comp.sys.cbm, on the NEWNet #c64friends IRC channel, or by emailing
the author.
-----------------------------------
Jim Brain
brain@jbrain.com
www.jbrain.com
The ip232 support was added by Anthony Tolle. For questions regarding that,
e-mail atolle@gcns.com
tcpser/src/ 0040755 0000764 0001040 00000000000 10747540205 014031 5 ustar brain Administrators tcpser/src/.svn/ 0040755 0000764 0001040 00000000000 10747537547 014734 5 ustar brain Administrators tcpser/src/.svn/all-wcprops 0100444 0000764 0001040 00000005640 10562025525 017101 0 ustar brain Administrators K 25
svn:wc:ra_dav:version-url
V 32
/svn/tcpser/!svn/ver/4/trunk/src
END
tcpser.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/20/trunk/src/tcpser.c
END
bridge.h
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/bridge.h
END
init.c
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/24/trunk/src/init.c
END
getcmd.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/22/trunk/src/getcmd.c
END
tcpser.h
K 25
svn:wc:ra_dav:version-url
V 41
/svn/tcpser/!svn/ver/6/trunk/src/tcpser.h
END
ip.c
K 25
svn:wc:ra_dav:version-url
V 38
/svn/tcpser/!svn/ver/12/trunk/src/ip.c
END
init.h
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/10/trunk/src/init.h
END
getcmd.h
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/getcmd.h
END
modem_core.c
K 25
svn:wc:ra_dav:version-url
V 46
/svn/tcpser/!svn/ver/20/trunk/src/modem_core.c
END
util.c
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/10/trunk/src/util.c
END
ip.h
K 25
svn:wc:ra_dav:version-url
V 38
/svn/tcpser/!svn/ver/10/trunk/src/ip.h
END
modem_core.h
K 25
svn:wc:ra_dav:version-url
V 46
/svn/tcpser/!svn/ver/24/trunk/src/modem_core.h
END
serial.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/22/trunk/src/serial.c
END
util.h
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/10/trunk/src/util.h
END
phone_book.c
K 25
svn:wc:ra_dav:version-url
V 46
/svn/tcpser/!svn/ver/22/trunk/src/phone_book.c
END
tcpmdm.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/tcpmdm.c
END
serial.h
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/serial.h
END
debug.c
K 25
svn:wc:ra_dav:version-url
V 41
/svn/tcpser/!svn/ver/22/trunk/src/debug.c
END
phone_book.h
K 25
svn:wc:ra_dav:version-url
V 46
/svn/tcpser/!svn/ver/10/trunk/src/phone_book.h
END
tcpmdm.h
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/tcpmdm.h
END
dce.c
K 25
svn:wc:ra_dav:version-url
V 39
/svn/tcpser/!svn/ver/24/trunk/src/dce.c
END
debug.h
K 25
svn:wc:ra_dav:version-url
V 41
/svn/tcpser/!svn/ver/10/trunk/src/debug.h
END
ip232.c
K 25
svn:wc:ra_dav:version-url
V 41
/svn/tcpser/!svn/ver/24/trunk/src/ip232.c
END
dce.h
K 25
svn:wc:ra_dav:version-url
V 39
/svn/tcpser/!svn/ver/10/trunk/src/dce.h
END
ip232.h
K 25
svn:wc:ra_dav:version-url
V 41
/svn/tcpser/!svn/ver/24/trunk/src/ip232.h
END
shared.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/14/trunk/src/shared.c
END
nvt.c
K 25
svn:wc:ra_dav:version-url
V 39
/svn/tcpser/!svn/ver/24/trunk/src/nvt.c
END
shared.h
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/10/trunk/src/shared.h
END
nvt.h
K 25
svn:wc:ra_dav:version-url
V 39
/svn/tcpser/!svn/ver/24/trunk/src/nvt.h
END
line.c
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/24/trunk/src/line.c
END
line.h
K 25
svn:wc:ra_dav:version-url
V 40
/svn/tcpser/!svn/ver/10/trunk/src/line.h
END
bridge.c
K 25
svn:wc:ra_dav:version-url
V 42
/svn/tcpser/!svn/ver/24/trunk/src/bridge.c
END
tcpser/src/.svn/entries 0100444 0000764 0001040 00000010173 10747537546 016324 0 ustar brain Administrators 8
dir
5
http://www.jimbrain.com/svn/tcpser/trunk/src
http://www.jimbrain.com/svn/tcpser
2007-02-06T06:43:32.577387Z
4
brain
svn:special svn:externals svn:needs-lock
8602611e-c928-0410-ae49-afcc62ab246b
tcpser.c
file
25
2008-01-29T05:53:42.394366Z
b1b1bf67a0899eec8caebcf42ac195c1
2007-02-06T07:18:50.343343Z
20
brain
bridge.h
file
10
2004-06-25T05:34:58.000000Z
709b6569a8f4ebe84e47679ea7217249
2007-02-06T07:09:21.911371Z
10
brain
getcmd.c
file
22
2005-08-14T07:18:04.000000Z
a9688f12dd0165fc83016c423aeedfdc
2007-02-06T07:20:51.581213Z
22
brain
init.c
file
24
2006-06-18T15:01:24.000000Z
c77848808846789b08cc43f336fe1973
2007-02-06T07:26:33.108543Z
24
brain
tcpser.h
file
6
2004-05-03T19:55:54.000000Z
d41d8cd98f00b204e9800998ecf8427e
2007-02-06T07:04:10.627566Z
6
brain
getcmd.h
file
10
2004-06-25T05:34:58.000000Z
62db7febb7a9fc7bb7736421d8370a32
2007-02-06T07:09:21.911371Z
10
brain
init.h
file
10
2004-06-25T05:34:58.000000Z
915673b09bff87fcd6fbc6d12f6ba64c
2007-02-06T07:09:21.911371Z
10
brain
ip.c
file
12
2004-07-27T02:39:59.000000Z
eba32cd8708f6baf7f8ea844b8f2adef
2007-02-06T07:11:31.776866Z
12
brain
modem_core.c
file
20
2005-03-06T22:10:16.000000Z
0aff0f81727b4b178260c1ca9a741e15
2007-02-06T07:18:50.343343Z
20
brain
util.c
file
10
2004-06-25T05:34:58.000000Z
234a4462405cfc000a9c77713c7cdd78
2007-02-06T07:09:21.911371Z
10
brain
ip.h
file
10
2004-06-25T05:34:58.000000Z
26cc6e8c5810d22897baf0d0540e2df6
2007-02-06T07:09:21.911371Z
10
brain
modem_core.h
file
24
2006-06-13T23:53:34.000000Z
249c89e974797fc1814469d566821b31
2007-02-06T07:26:33.108543Z
24
brain
serial.c
file
22
2005-09-20T05:14:26.000000Z
9f6a1acbf3996e3e1695c433b6f99784
2007-02-06T07:20:51.581213Z
22
brain
util.h
file
10
2004-06-25T05:34:58.000000Z
eaae47082bac117a94a19d67909b9474
2007-02-06T07:09:21.911371Z
10
brain
phone_book.c
file
22
2005-09-20T05:29:58.000000Z
45efc345d55a6336dfae25e5a040667e
2007-02-06T07:20:51.581213Z
22
brain
tcpmdm.c
file
10
2004-06-25T05:34:58.000000Z
29d58f5f46b83889932b82c37cf3c3c7
2007-02-06T07:09:21.911371Z
10
brain
serial.h
file
10
2004-06-25T05:34:58.000000Z
3316a6fe2b24b446596074f0f447ce2a
2007-02-06T07:09:21.911371Z
10
brain
debug.c
file
22
2005-08-17T07:19:24.000000Z
01bd6a218ab392ad65ee67f711d62c18
2007-02-06T07:20:51.581213Z
22
brain
phone_book.h
file
10
2004-06-25T05:34:58.000000Z
117e5ec742424894912c60cb747edd88
2007-02-06T07:09:21.911371Z
10
brain
tcpmdm.h
file
10
2004-06-25T05:34:58.000000Z
68b329da9893e34099c7d8ad5cb9c940
2007-02-06T07:09:21.911371Z
10
brain
dce.c
file
24
2006-06-14T05:09:42.000000Z
ccaf9121be0220469f57fcf1fa729e7b
2007-02-06T07:26:33.108543Z
24
brain
debug.h
file
10
2004-06-25T05:34:58.000000Z
516a843f31a3ea8e3fc6fde852d30151
2007-02-06T07:09:21.911371Z
10
brain
ip232.c
file
24
2006-06-15T08:27:38.000000Z
70fb3d4f9d09cd18fd3df6bbd3696676
2007-02-06T07:26:33.108543Z
24
brain
modem_data.h
file
6
deleted
dce.h
file
10
2004-06-25T05:34:58.000000Z
cc01f11badd5c031ba9056ddde621b82
2007-02-06T07:09:21.911371Z
10
brain
ip232.h
file
24
2006-06-14T05:10:30.000000Z
40bfa6c501500c3098098b3088f3fefe
2007-02-06T07:26:33.108543Z
24
brain
shared.c
file
14
2004-08-01T07:38:46.000000Z
358b801da059b4225907c3d748952044
2007-02-06T07:13:17.349634Z
14
brain
nvt.c
file
24
2006-04-03T07:06:00.000000Z
fb21d2dbf16d463ee1b9ae857feeb25b
2007-02-06T07:26:33.108543Z
24
brain
connect
file
12
deleted
shared.h
file
10
2004-06-25T05:34:58.000000Z
03ed49293987680880e2069598748679
2007-02-06T07:09:21.911371Z
10
brain
nvt.h
file
24
2006-04-01T23:31:56.000000Z
49905189a6be9329c9f3acae9fe72577
2007-02-06T07:26:33.108543Z
24
brain
main.c
file
6
deleted
line.c
file
24
2006-04-18T21:27:04.000000Z
879eb12cbb71ead8967d7590b56eaa82
2007-02-06T07:26:33.108543Z
24
brain
main.h
file
6
deleted
bridge.c
file
24
2006-06-18T15:00:20.000000Z
72614ab784e6e9f688e9d3b1afdfca1e
2007-02-06T07:26:33.108543Z
24
brain
line.h
file
10
2004-06-25T05:34:58.000000Z
50d226b6d7d3c3cb3fd576be85d3f1f0
2007-02-06T07:09:21.911371Z
10
brain
tcpser/src/.svn/format 0100444 0000764 0001040 00000000002 10562022500 016077 0 ustar brain Administrators 8
tcpser/src/.svn/prop-base/ 0040755 0000764 0001040 00000000000 10574105512 016601 5 ustar brain Administrators tcpser/src/.svn/props/ 0040755 0000764 0001040 00000000000 10574105512 016054 5 ustar brain Administrators tcpser/src/.svn/text-base/ 0040755 0000764 0001040 00000000000 10574105512 016605 5 ustar brain Administrators tcpser/src/.svn/text-base/bridge.c.svn-base 0100444 0000764 0001040 00000030663 10445265204 021727 0 ustar brain Administrators #include
#include // for recv...
#include // for read...
#include // for exit...
#include
#include
#include
#include "util.h"
#include "debug.h"
#include "nvt.h"
#include "modem_core.h"
#include "ip.h"
//#include "serial.h"
#include "getcmd.h"
#include "bridge.h"
const unsigned char MDM_NO_ANSWER[] = "NO ANSWER\n";
//const unsigned char CONNECT_NOTICE[] = "\r\nCONNECTING...\r\n";
//const unsigned char TELNET_NOTICE[] = "TELNET MODE ENABLED\r\n";
int accept_connection(modem_config* cfg) {
LOG_ENTER();
cfg->line_data.fd=ip_accept(cfg->line_data.sfd);
if(cfg->line_data.fd > -1) {
cfg->line_data.valid_conn=TRUE;
if(cfg->data.direct_conn == TRUE) {
cfg->conn_type=MDM_CONN_INCOMING;
mdm_off_hook(cfg);
cfg->cmd_mode=TRUE;
} else {
//line_write(cfg,(unsigned char*)CONNECT_NOTICE,strlen(CONNECT_NOTICE));
cfg->rings=0;
mdm_send_ring(cfg);
}
// tell parent I got it.
LOG(LOG_DEBUG,"Informing parent task that I am busy");
writePipe(cfg->data.mp[0][1],MSG_ACCEPTED);
}
LOG_EXIT();
return 0;
}
int parse_ip_data(modem_config *cfg, unsigned char* data, int len) {
// I'm going to cheat and assume it comes in chunks.
int i=0;
unsigned char ch;
unsigned char text[1025];
int text_len=0;
if(cfg->line_data.first_char==TRUE) {
cfg->line_data.first_char=FALSE;
if((data[0] == 0xff) || (data[0] == 0x1a)) {
//line_write(cfg,(unsigned char*)TELNET_NOTICE,strlen(TELNET_NOTICE));
LOG(LOG_INFO,"Detected telnet");
cfg->line_data.is_telnet=TRUE;
}
}
if(cfg->line_data.is_telnet == TRUE) {
while(iline_data.fd, &cfg->line_data.nvt_data,ch,data[i+2]);
i+=3;
break;
case NVT_SB: // sub negotiation
// again, overflow...
i+=parse_nvt_subcommand(cfg->line_data.fd, &cfg->line_data.nvt_data,data + i,len - i);
break;
case NVT_IAC:
if (cfg->line_data.nvt_data.binary_recv)
text[text_len++] = NVT_IAC;
// fall through to skip this sequence
default:
// ignore...
i+=2;
}
} else {
text[text_len++]=data[i++];
}
if(text_len == 1024) {
text[text_len] = 0;
// write to serial...
mdm_write(cfg,text,text_len);
text_len=0;
}
}
if(text_len) {
text[text_len] = 0;
// write to serial...
mdm_write(cfg,text,text_len);
}
} else {
mdm_write(cfg,data,len);
}
return 0;
}
void *ip_thread(void *arg) {
modem_config* cfg=(modem_config *)arg;
int action_pending=FALSE;
fd_set readfs;
int max_fd;
int res=0;
unsigned char buf[256];
int rc;
LOG_ENTER();
while(TRUE) {
FD_ZERO(&readfs);
FD_SET(cfg->data.cp[1][0], &readfs);
max_fd=cfg->data.cp[1][0];
if(action_pending == FALSE
&& cfg->conn_type != MDM_CONN_NONE
&& cfg->cmd_mode == FALSE
&& cfg->line_data.fd > -1
&& cfg->line_data.valid_conn ==TRUE
) {
FD_SET(cfg->line_data.fd, &readfs);
max_fd=MAX(max_fd,cfg->line_data.fd);
}
max_fd++;
rc=select(max_fd, &readfs, NULL, NULL, NULL);
if(rc == -1) {
ELOG(LOG_WARN,"Select returned error");
// handle error
} else {
// we got data
if (cfg->line_data.valid_conn==TRUE && FD_ISSET(cfg->line_data.fd,&readfs)) { // socket
LOG(LOG_DEBUG,"Data available on socket");
res = recv(cfg->line_data.fd,buf,sizeof(buf),0);
if(0 >= res) {
LOG(LOG_INFO,"No socket data read, assume closed peer");
writePipe(cfg->data.cp[0][1],MSG_DISCONNECT);
action_pending=TRUE;
} else {
LOG(LOG_DEBUG,"Read %d bytes from socket",res);
buf[res]=0;
log_trace(TRACE_IP_IN,buf,res);
parse_ip_data(cfg,buf,res);
}
}
if (FD_ISSET(cfg->data.cp[1][0],&readfs)) { // pipe
res = read(cfg->data.cp[1][0],buf,sizeof(buf) - 1);
LOG(LOG_DEBUG,"IP thread notified");
action_pending=FALSE;
}
}
}
LOG_EXIT();
}
void *ctrl_thread(void *arg) {
modem_config* cfg=(modem_config *)arg;
int status;
int new_status;
LOG_ENTER();
status=dce_get_control_lines(cfg);
while(status > -1) {
new_status = dce_check_control_lines(cfg);
if(new_status > -1 && status != new_status) {
// something changed
if((status & MDM_CL_DTR_HIGH) != (new_status & MDM_CL_DTR_HIGH)) {
if((new_status & MDM_CL_DTR_HIGH) == 0) {
LOG(LOG_INFO,"DTR has gone low");
writePipe(cfg->data.wp[0][1],MSG_DTR_DOWN);
} else {
LOG(LOG_INFO,"DTR has gone high");
writePipe(cfg->data.wp[0][1],MSG_DTR_UP);
}
}
}
status = new_status;
}
LOG_EXIT();
// need to quit application, as status cannot be obtained.
exit(-1);
}
int spawn_ctrl_thread(modem_config *cfg) {
int rc;
pthread_t thread_id;
rc=pthread_create(&thread_id,NULL,ctrl_thread,(void *)cfg);
LOG(LOG_ALL,"CTRL thread ID=%d",(int)thread_id);
if(rc < 0) {
ELOG(LOG_FATAL,"CTRL thread could not be started");
exit(-1);
}
return 0;
}
int spawn_ip_thread(modem_config *cfg) {
int rc;
pthread_t thread_id;
rc=pthread_create(&thread_id,NULL,ip_thread,(void *)cfg);
LOG(LOG_ALL,"IP thread ID=%d",(int)thread_id);
if(rc < 0) {
ELOG(LOG_FATAL,"IP thread could not be started");
exit(-1);
}
return 0;
}
void *run_bridge(void * arg) {
modem_config *cfg=(modem_config *)arg;
struct timeval timer;
struct timeval* ptimer;
int max_fd=0;
fd_set readfs;
int res=0;
unsigned char buf[256];
int rc=0;
int last_conn_type;
int last_cmd_mode=cfg->cmd_mode;
LOG_ENTER();
if( -1 == pipe(cfg->data.wp[0])) {
ELOG(LOG_FATAL,"Control line watch task incoming IPC pipe could not be created");
exit(-1);
}
if( -1 == pipe(cfg->data.cp[0])) {
ELOG(LOG_FATAL,"IP thread incoming IPC pipe could not be created");
exit(-1);
}
if( -1 == pipe(cfg->data.cp[1])) {
ELOG(LOG_FATAL,"IP thread outgoing IPC pipe could not be created");
exit(-1);
}
spawn_ctrl_thread(cfg);
spawn_ip_thread(cfg);
mdm_set_control_lines(cfg);
strncpy(cfg->cur_line,cfg->config0,sizeof(cfg->cur_line));
last_conn_type=cfg->conn_type;
last_cmd_mode=cfg->cmd_mode;
cfg->allow_transmit=FALSE;
// call some functions behind the scenes
mdm_disconnect(cfg);
mdm_parse_cmd(cfg);
// if direct connection, and num length > 0, dial number.
if (cfg->data.direct_conn == TRUE) {
if(strlen(cfg->data.direct_conn_num) > 0 &&
cfg->data.direct_conn_num[0] != ':') {
// we have a direct number to connect to.
strncpy(cfg->dialno,cfg->data.direct_conn_num,sizeof(cfg->dialno));
if(0 != line_connect(cfg)) {
LOG(LOG_FATAL,"Cannot connect to Direct line address!");
// probably should exit...
exit(-1);
} else {
cfg->conn_type=MDM_CONN_OUTGOING;
}
}
}
cfg->allow_transmit=TRUE;
for(;;) {
if(last_conn_type!= cfg->conn_type) {
LOG(LOG_ALL,"Connection status change, handling");
//writePipe(cfg->data.mp[0][1],MSG_NOTIFY);
writePipe(cfg->data.cp[1][1],MSG_NOTIFY);
if(cfg->conn_type == MDM_CONN_OUTGOING) {
if(strlen(cfg->data.local_connect) > 0) {
writeFile(cfg->data.local_connect,cfg->line_data.fd);
}
if(strlen(cfg->data.remote_connect) > 0) {
writeFile(cfg->data.remote_connect,cfg->line_data.fd);
}
} else if(cfg->conn_type == MDM_CONN_INCOMING) {
if(strlen(cfg->data.local_answer) > 0) {
writeFile(cfg->data.local_answer,cfg->line_data.fd);
}
if(strlen(cfg->data.remote_answer) > 0) {
writeFile(cfg->data.remote_answer,cfg->line_data.fd);
}
}
last_conn_type=cfg->conn_type;
}
if(last_cmd_mode != cfg->cmd_mode) {
writePipe(cfg->data.cp[1][1],MSG_NOTIFY);
last_cmd_mode=cfg->cmd_mode;
}
LOG(LOG_ALL,"Waiting for modem/control line/timer/socket activity");
LOG(LOG_ALL,"Command Mode=%d, Connection status=%d",cfg->cmd_mode,cfg->conn_type);
max_fd=MAX(cfg->data.mp[1][0],cfg->dce_data.fd);
max_fd=MAX(max_fd,cfg->data.wp[0][0]);
max_fd=MAX(max_fd,cfg->data.cp[0][0]);
FD_ZERO(&readfs);
FD_SET(cfg->data.mp[1][0], &readfs);
FD_SET(cfg->dce_data.fd, &readfs);
FD_SET(cfg->data.wp[0][0], &readfs);
FD_SET(cfg->data.cp[0][0], &readfs);
ptimer=NULL;
if(cfg->cmd_mode == FALSE) {
if(cfg->pre_break_delay == FALSE || cfg->break_len == 3) {
LOG(LOG_ALL,"Setting timer for break delay");
timer.tv_sec=0;
timer.tv_usec=cfg->s[12] * 20000;
ptimer=&timer;
} else if(cfg->pre_break_delay == TRUE && cfg->break_len > 0) {
LOG(LOG_ALL,"Setting timer for inter-break character delay");
timer.tv_sec=1; // 1 second
timer.tv_usec=0;
ptimer=&timer;
} else if (cfg->s[30] != 0) {
LOG(LOG_ALL,"Setting timer for inactivity delay");
timer.tv_sec=cfg->s[30] * 10;
timer.tv_usec=0;
ptimer=&timer;
}
} else if(cfg->cmd_mode == TRUE && cfg->conn_type== MDM_CONN_NONE && cfg->line_data.valid_conn ==TRUE) {
LOG(LOG_ALL,"Setting timer for rings");
timer.tv_sec=4;
timer.tv_usec=0;
ptimer=&timer;
}
max_fd++;
rc=select(max_fd, &readfs, NULL, NULL, ptimer);
if(rc == -1) {
ELOG(LOG_WARN,"Select returned error");
// handle error
} else if(rc == 0) {
// timer popped.
if(cfg->cmd_mode == TRUE && cfg->conn_type == MDM_CONN_NONE && cfg->line_data.valid_conn == TRUE) {
if(cfg->s[0] == 0 && cfg->rings==10) {
// not going to answer, send some data back to IP and disconnect.
if(strlen(cfg->data.no_answer) == 0) {
line_write(cfg,(unsigned char*)MDM_NO_ANSWER,strlen(MDM_NO_ANSWER));
} else {
writeFile(cfg->data.no_answer,cfg->line_data.fd);
}
mdm_disconnect(cfg);
} else
mdm_send_ring(cfg);
} else
mdm_handle_timeout(cfg);
}
if (FD_ISSET(cfg->dce_data.fd,&readfs)) { // serial port
LOG(LOG_DEBUG,"Data available on serial port");
res = dce_read(cfg,buf,sizeof(buf));
LOG(LOG_DEBUG,"Read %d bytes from serial port",res);
if(res > 0) {
if(cfg->conn_type == MDM_CONN_NONE && cfg->off_hook == TRUE) {
// this handles the case where atdt goes off hook, but no
// connection
mdm_disconnect(cfg);
mdm_send_response(MDM_RESP_OK,cfg);
} else {
mdm_parse_data(cfg,buf,res);
}
}
}
if (FD_ISSET(cfg->data.wp[0][0],&readfs)) { // control pipe
res = read(cfg->data.wp[0][0],buf,sizeof(buf) -1);
buf[res]=0;
LOG(LOG_DEBUG,"Received %c from Control line watch task",buf[0]);
switch (buf[0]) {
case MSG_DTR_DOWN:
// DTR drop, close any active connection and put
// in cmd_mode
mdm_disconnect(cfg);
break;
case MSG_DTR_UP:
break;
}
}
if (FD_ISSET(cfg->data.cp[0][0],&readfs)) { // ip thread pipe
res = read(cfg->data.cp[0][0],buf,sizeof(buf));
LOG(LOG_DEBUG,"Received %c from ip thread",buf[0]);
switch (buf[0]) {
case MSG_DISCONNECT:
if(cfg->data.direct_conn == TRUE) {
// what should we do here...
LOG(LOG_ERROR,"Direct Connection Link broken, disconnecting and awaiting new direct connection");
cfg->data.direct_conn=FALSE;
mdm_disconnect(cfg);
cfg->data.direct_conn=TRUE;
} else {
mdm_disconnect(cfg);
}
break;
}
}
if (FD_ISSET(cfg->data.mp[1][0],&readfs)) { // parent pipe
LOG(LOG_DEBUG,"Data available on incoming IPC pipe");
res = read(cfg->data.mp[1][0],buf,sizeof(buf));
switch (buf[0]) {
case MSG_ACCEPT: // accept connection.
accept_connection(cfg);
break;
}
}
}
LOG_EXIT();
}
tcpser/src/.svn/text-base/bridge.h.svn-base 0100444 0000764 0001040 00000001022 10066734602 021721 0 ustar brain Administrators #define MSG_NOT_ACTIVE 'a'
#define MSG_ACTIVE 'A'
#define MSG_NOT_LISTENING 'l'
#define MSG_LISTENING 'L'
#define MSG_ACCEPT '+'
#define MSG_ACCEPTED '+'
#define MSG_DTR_DOWN 'd'
#define MSG_DTR_UP 'D'
#define MSG_RTS_DOWN 'r'
#define MSG_RTS_UP 'R'
#define MSG_CD_DOWN 'c'
#define MSG_CD_UP 'c'
#define MSG_RNG_DOWN 'n'
#define MSG_RNG_UP 'N'
#define MSG_DISCONNECT 'D'
#define MSG_NOTIFY 'N'
int accept_connection(modem_config*);
int parse_ip_data(modem_config *cfg, unsigned char* data, int len);
void *run_bridge(void *arg);
tcpser/src/.svn/text-base/dce.c.svn-base 0100444 0000764 0001040 00000005415 10443715026 021223 0 ustar brain Administrators #include
#include
#include
#include "debug.h"
#include "serial.h"
#include "modem_core.h"
#include "ip232.h" // needs modem_core.h
#include "dce.h"
int dce_init_config(modem_config *cfg) {
return 0;
}
int dce_init_conn(modem_config* cfg) {
int rc;
LOG_ENTER();
if (cfg->dce_data.is_ip232) {
rc=ip232_init_conn(cfg);
} else {
rc=ser_init_conn(cfg->dce_data.tty,cfg->dte_speed);
cfg->dce_data.fd=rc;
}
LOG_EXIT();
return rc;
}
int dce_set_flow_control(modem_config *cfg,int opts) {
int status=0;
int rc=0;
LOG_ENTER();
if(opts == 0) {
LOG(LOG_ALL,"Setting NONE flow control");
} else {
if((opts & MDM_FC_RTS) != 0) {
LOG(LOG_ALL,"Setting RTSCTS flow control");
status |= CRTSCTS;
}
if((opts && MDM_FC_XON) != 0) {
status |= (IXON | IXOFF);
LOG(LOG_ALL,"Setting XON/XOFF flow control");
}
}
if (cfg->dce_data.is_ip232) {
rc=ip232_set_flow_control(cfg,status);
} else {
rc=ser_set_flow_control(cfg->dce_data.fd,status);
}
LOG_EXIT()
return rc;
}
int dce_set_control_lines(modem_config *cfg,int state) {
int status=0;
int rc;
LOG_ENTER();
if((state & MDM_CL_CTS_HIGH) != 0) {
LOG(LOG_ALL,"Setting CTS pin high");
status |= TIOCM_RTS;
} else {
LOG(LOG_ALL,"Setting CTS pin low");
//status &= ~TIOCM_RTS;
}
if((state & MDM_CL_DCD_HIGH) != 0) {
LOG(LOG_ALL,"Setting DCD pin high");
status |= TIOCM_DTR;
} else {
LOG(LOG_ALL,"Setting DCD pin low");
//status &= ~TIOCM_DTR;
}
if (cfg->dce_data.is_ip232) {
rc = ip232_set_control_lines(cfg,status);
} else {
rc = ser_set_control_lines(cfg->dce_data.fd,status);
}
LOG_EXIT();
return rc;
}
int dce_get_control_lines(modem_config *cfg) {
int status;
int rc_status;
if (cfg->dce_data.is_ip232) {
status = ip232_get_control_lines(cfg);
} else {
status = ser_get_control_lines(cfg->dce_data.fd);
}
if(status > -1) {
rc_status=((status & TIOCM_DSR) != 0?MDM_CL_DTR_HIGH:0);
} else {
rc_status=status;
}
return rc_status;
}
int dce_check_control_lines(modem_config *cfg) {
int status=0;
int new_status=0;
LOG_ENTER();
status = dce_get_control_lines(cfg);
new_status = status;
while(new_status > -1 && status == new_status) {
usleep(100000);
new_status = dce_get_control_lines(cfg);
}
LOG_EXIT();
return new_status;
}
int dce_write(modem_config *cfg,unsigned char data[], int len) {
if (cfg->dce_data.is_ip232) {
return ip232_write(cfg,data,len);
}
return ser_write(cfg->dce_data.fd,data,len);
}
int dce_read(modem_config *cfg, unsigned char data[], int len) {
if (cfg->dce_data.is_ip232) {
return ip232_read(cfg,data,len);
}
return ser_read(cfg->dce_data.fd,data,len);
}
tcpser/src/.svn/text-base/dce.h.svn-base 0100444 0000764 0001040 00000001031 10066734602 021220 0 ustar brain Administrators #ifndef DCE_H
#define DCE_H 1
int dce_init(void);
int dce_init_config(modem_config *cfg);
int dce_init_conn(modem_config* cfg);
int dce_set_flow_control(modem_config *cfg,int opts);
int dce_set_control_lines(modem_config *cfg,int state);
int dce_get_control_lines(modem_config *cfg);
int dce_check_control_lines(modem_config *cfg);
int dce_read(modem_config *cfg,unsigned char* data,int len);
int dce_write(modem_config *cfg,unsigned char* data,int len);
//int dce_check_for_break(modem_config *cfg, char ch, int chars_left);
#endif
tcpser/src/.svn/text-base/debug.c.svn-base 0100444 0000764 0001040 00000005415 10300562374 021554 0 ustar brain Administrators #include // for exit...
#include
#include
#include
#define DEBUG_VARS 1 // need this so we don't get extern defs
#include "debug.h"
int log_level=0;
FILE* log_file;
int trace_flags=0;
unsigned char* trace_type[9]; // cheesy, but I can't think of another o(1) way
unsigned char* log_desc[LOG_TRACE+1];
pthread_mutex_t log_mutex;
int log_init() {
log_file=stdout;
log_level=0;
trace_flags=0;
trace_type[TRACE_MODEM_IN]="RS<-";
trace_type[TRACE_MODEM_OUT]="RS->";
trace_type[TRACE_IP_IN]="IP<-";
trace_type[TRACE_IP_OUT]="IP->";
log_desc[LOG_FATAL]="FATAL";
log_desc[LOG_ERROR]="ERROR";
log_desc[LOG_WARN]="WARN";
log_desc[LOG_INFO]="INFO";
log_desc[LOG_DEBUG]="DEBUG";
log_desc[LOG_ENTER_EXIT]="ENTER_EXIT";
log_desc[LOG_ALL]="DEBUG_X";
log_desc[LOG_TRACE]="";
if( -1 == pthread_mutex_init(&log_mutex,NULL)) {
perror("Could not create Log Mutex");
exit(-1);
}
return 0;
}
void log_set_file(FILE* a) {
log_file=a;
}
void log_set_level(int a) {
log_level=a;
}
void log_set_trace_flags(int a) {
trace_flags=a;
}
int log_get_trace_flags() {
return trace_flags;
}
void log_trace(int type, unsigned char* line, int len) {
int i=0;
int ch;
unsigned char data[64]="\0";
unsigned char *dptr=NULL;
unsigned char text[17];
if(len==0)
return;
if((type & trace_flags) != 0) {
text[16]=0;
for(i=0;i 31 && ch < 127) {
text[i % 16] = ch;
} else {
text[i % 16] = '.';
}
if((i %16) == 15) {
log_start(LOG_TRACE);
fprintf(log_file,"%s|%s|%s|",trace_type[type],data,text);
log_end();
} else {
sprintf(dptr + 7 + ((i % 16) * 3)," ");
}
}
i=i%16;
if(i > 0) {
for(;i<16;i++) {
sprintf(dptr + 5 + ((i % 16) * 3)," ");
if((i % 16) != 15) {
sprintf(dptr + 7 + ((i % 16) * 3)," ");
}
text[i % 16] = ' ';
}
log_start(LOG_TRACE);
fprintf(log_file,"%s|%s|%s|",trace_type[type],data,text);
}
log_end();
}
}
void log_start(int level) {
unsigned char t[23];
time_t now;
if(-1 == pthread_mutex_lock(&log_mutex)) {
perror("Could not lock the log mutex");
} else {
// we have the lock.
now=time(NULL);
strftime(t,22,"%Y-%m-%d %H:%M:%S",localtime(&now));
fprintf(log_file,"%s:%5.5d:%s:",t,(int)pthread_self(),log_desc[level]);
//free(t);
}
}
void log_end() {
fprintf(log_file,"\n");
fflush(log_file);
if(-1 == pthread_mutex_unlock(&log_mutex)) {
perror("Could not lock the log mutex");
}
}
tcpser/src/.svn/text-base/debug.h.svn-base 0100444 0000764 0001040 00000003307 10066734602 021563 0 ustar brain Administrators #ifndef DEBUG_H
#define DEBUG_H 1
#define LOG_TRACE 10
#define LOG_ALL 7
#define LOG_ENTER_EXIT 6
#define LOG_DEBUG 5
#define LOG_INFO 4
#define LOG_WARN 3
#define LOG_ERROR 2
#define LOG_FATAL 1
#define LOG_NONE 0
#define TRACE_MODEM_IN 1
#define TRACE_MODEM_OUT 2
#define TRACE_IP_IN 4
#define TRACE_IP_OUT 8
#include // needed for strerror
#include // needed for strerror
#include // needed for errno
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ ""
# endif
#endif
#define LOG(a,args...) do { \
if(a <= log_level) { \
log_start(a); \
fprintf(log_file,args); \
log_end(); \
} \
} while(0)
#define ELOG(a,args...) do { \
if(a <= log_level) { \
log_start(a); \
fprintf(log_file,args); \
fprintf(log_file," (%s)\n",strerror(errno)); \
log_end(); \
} \
} while(0)
#define LOG_ENTER() LOG(LOG_ENTER_EXIT,"Entering %s function",__func__);
#define LOG_EXIT() LOG(LOG_ENTER_EXIT,"Exitting %s function",__func__);
int log_init(void);
void log_set_file(FILE* a);
void log_set_level(int a);
int log_get_trace_flags();
void log_set_trace_flags(int a);
void log_trace(int type, unsigned char* line, int len);
void log_start(int level);
void log_end();
#endif
#ifndef DEBUG_VARS
#define DEBUG_VARS 1
#include
extern int log_level;
extern FILE* log_file;
#endif
tcpser/src/.svn/text-base/getcmd.c.svn-base 0100444 0000764 0001040 00000015046 10277570054 021741 0 ustar brain Administrators #include
#include
#include
#include "getcmd.h"
int getData(unsigned char line[],
int* index,
int len,
int* data_start,
int* data_end,
int complex_parse
) {
int alpha=FALSE;
int done=FALSE;
*data_start=*index;
while(*index < len && done != TRUE) {
// I'm going to assume either
// a number
// a string with a space
switch(line[*index]) {
case ' ':
if(!complex_parse && *index != *data_start) {
// leave space, next call will skip it.
done=TRUE;
} else if(*index != *data_start) {
// we are complex, add the space and continue.
(*index)++;
} else {
// we have not started, eat space and continue.
(*index)++;
*data_start=*index;
}
break;
case 0:
done=TRUE;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': // isnum
(*index)++;
break;
default:
if(!complex_parse && *index != *data_start && 0==alpha ) {
// we were a number, but we've hit an alpha 'S0=137S...'
done=TRUE;
} else {
(*index)++;
alpha=TRUE;
}
break;
}
}
*data_end=(*index);
return 0;
}
int getNumber(unsigned char line[], int* index, int len ) {
int num=0;
int found=FALSE;
while(*index *num)
*num=0;
return toupper(cmd) | flags;
}
int parseRegister(unsigned char line[],
int flags,
int* index,
int* num,
int len,
int* data_start,
int* data_end,
int complex_parse
) {
// need to handle S?, which queries that S register.
int cmd=0;
cmd = getCommand(line,flags,index,num,len);
if(0 > num)
return AT_CMD_ERR;
skip(line,index,len,' ');
if(len == *index)
return AT_CMD_ERR;
switch (line[(*index)++]) {
case '=':
// set a register
skip(line, index, len, ' ');
if(0 > getData(line, index, len, data_start, data_end, complex_parse))
return AT_CMD_ERR;
break;
case '?':
// query a register
flags |= AT_CMD_FLAG_QUERY;
if(*num < 0)
*num=0;
break;
default:
return AT_CMD_ERR;
}
return toupper(cmd) | flags;
}
int getcmd(unsigned char line[],
int* index,
int* num,
int* data_start,
int* data_end
) {
int len=0;
int cmd=AT_CMD_END;
*num=0;
*data_start=0;
*data_end=0;
if(line == NULL)
return AT_CMD_NONE;
len=strlen(line);
while(*index < len) {
cmd=toupper(line[*index]);
switch (cmd) {
case ' ':
break;
case 0:
return AT_CMD_END;
case '%':
(*index)++;
while(*index