|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 3856 (0xf10) Types: TextFile Names: »ts2bridge.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/tsap/ts2bridge.c«
/* ts2bridge.c - TPM: X.25 interface via bridge */ #ifndef lint static char *rcsid = "$Header: /f/osi/tsap/RCS/ts2bridge.c,v 6.0 89/03/18 23:45:17 mrose Rel $"; #endif /* * $Header: /f/osi/tsap/RCS/ts2bridge.c,v 6.0 89/03/18 23:45:17 mrose Rel $ * * Contributed by Julian Onions, Nottingham University in the UK * * * $Log: ts2bridge.c,v $ * Revision 6.0 89/03/18 23:45:17 mrose * Release 5.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ /* LINTLIBRARY */ #include <stdio.h> #include "tpkt.h" #ifdef BRIDGE_X25 #include <sys/uio.h> #include <sys/ioctl.h> #include "tailor.h" /* * This could be anything up to the size TCP encapsualtion howver, to * interwork with the X.25 it should be the same as X.25's MAXNSDU. * This define is clearly a hack - but including x25.h messes things up more! */ #define MAXNSDU (1024) extern int errno; /* \f N-CONNECT.REQUEST */ int bridgeopen (tb, local, remote, td, async) register struct tsapblk *tb; struct NSAPaddr *local, *remote; struct TSAPdisconnect *td; { register int fd; if (async) return tsaplose (td, DR_PARAMETER, NULLCP, "asynchronous not supported"); if ((fd = start_bridge_client (local)) == NOTOK) return tsaplose (td, DR_CONGEST, "socket", "unable to start"); tb -> tb_fd = fd; (void) BTService (tb); if (join_bridge_server (fd, remote) == NOTOK) { (void) tsaplose (td, DR_REFUSED, "connection", "unable to establish"); (void) close_bridge_socket (fd); return (tb -> tb_fd = NOTOK); } return DONE; } /* \f */ /* ARGSUSED */ static int bridgeretry (tb, td) struct tsapblk *tb; struct TSAPdisconnect *td; { return tsaplose (td, DR_OPERATION, NULLCP, "connection not in progress"); } /* \f init for read from network/write to network */ #define bridgeinit tcpinit #define bridgeread read #define bridgewrite tcpwrite int close_bridge_socket (); #define select_bridge_socket selsocket int tcpinit (); int tcpwrite (); int selsocket (); int read (); /* \f */ /* ARGSUSED */ char *bridgesave (fd, dte1, l1, dte2, l2, td) int fd; char *dte1; int l1; char *dte2; int l2; struct TSAPdisconnect *td; { static char buffer[BUFSIZ]; (void) sprintf (buffer, "%c%d %*s %*s", NT_BRG, fd, l1, dte1, l2, dte2); return buffer; } int bridgerestore (tb, buffer, td) register struct tsapblk *tb; char *buffer; struct TSAPdisconnect *td; { int fd; char dte1[NSAP_DTELEN + 1], dte2[NSAP_DTELEN + 1]; register struct NSAPaddr *na; register struct TSAPaddr *ta; if (sscanf (buffer, "%d %s %s", &fd, dte1, dte2) != 3 || fd < 0) return tsaplose (td, DR_PARAMETER, NULLCP, "bad initialization vector \"%s\"", buffer); ta = &tb -> tb_initiating; ta -> ta_naddr = 1; na = ta -> ta_addrs; na -> na_type = NA_BRG; bcopy(dte1, na -> na_dte, strlen(dte1)); na -> na_dtelen = strlen (na -> na_dte); tb -> tb_fd = fd; (void) BTService (tb); ta = &tb -> tb_responding; ta -> ta_naddr = 1; na = ta -> ta_addrs; na -> na_type = NA_BRG; bcopy(dte1, na -> na_dte, strlen(dte2)); na -> na_dtelen = strlen (na -> na_dte); return OK; } /* \f */ int BTService (tb) register struct tsapblk *tb; { tb -> tb_flags |= TB_BRG; tb -> tb_tsdusize = MAXNSDU - (tb -> tb_tpduslop = DT_MAGIC); tb -> tb_retryfnx = bridgeretry; tb -> tb_initfnx = bridgeinit; tb -> tb_readfnx = bridgeread; tb -> tb_writefnx = bridgewrite; tb -> tb_closefnx = close_bridge_socket; tb -> tb_selectfnx = select_bridge_socket; tp0init (tb); } #endif