|
|
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 c
Length: 9827 (0x2663)
Types: TextFile
Names: »camtec.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/compat/camtec.c«
/* camtec.c - X.25, CONS abstractions for CAMTEC CCL */
#ifndef lint
static char *rcsid = "$Header: /f/osi/compat/RCS/camtec.c,v 6.0 89/03/18 23:24:58 mrose Rel $";
#endif
/*
* $Header: /f/osi/compat/RCS/camtec.c,v 6.0 89/03/18 23:24:58 mrose Rel $
*
* Contributed by Keith Ruttle, CAMTEC Electronics Ltd
*
*
* $Log: camtec.c,v $
* Revision 6.0 89/03/18 23:24:58 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 <errno.h>
#include <stdio.h>
#include "general.h"
#include "manifest.h"
#ifdef CAMTEC_CCL
#ifdef X25
#include "tailor.h"
#include "tpkt.h"
/* \f
4.[23] UNIX: CCL X25 */
#include "x25.h"
static char calling_dte[NSAP_DTELEN + 1];
/* \f
*/
int start_x25_client (local)
struct NSAPaddr *local;
{
int sd, pgrp;
CONN_DB l_iov;
if (local != NULLNA)
local -> na_type = NA_X25;
if ((sd = socket (AF_CCL, SOCK_STREAM, CCLPROTO_X25)) == NOTOK) {
SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
return NOTOK; /* Error can be found in errno */
}
pgrp = getpid();
if (ioctl(sd, SIOCSPGRP, &pgrp)) {
SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
return NOTOK; /* Error can be found in errno */
}
l_iov.ccl_iovec[0].iov_base = calling_dte;
gen2if(local, &l_iov, ADDR_LOCAL);
return sd;
}
/* \f
*/
int start_x25_server (local, backlog, opt1, opt2)
struct NSAPaddr *local;
int backlog,
opt1,
opt2;
{
int sd, pgrp;
CONN_DB b_iov;
char param1[128];
b_iov.ccl_iovec[0].iov_base = param1;
if ((sd = socket (AF_CCL, SOCK_STREAM, CCLPROTO_X25)) == NOTOK) {
SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
return NOTOK; /* Can't get an X.25 socket */
}
pgrp = getpid();
if (ioctl(sd, SIOCSPGRP, &pgrp)) {
SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
return NOTOK; /* Error can be found in errno */
}
if (local != NULLNA)
local -> na_type = NA_X25;
if (local != NULLNA && local -> na_dtelen == 0) {
(void) strcpy (local -> na_dte, x25_local_dte);
local -> na_dtelen = strlen(x25_local_dte);
}
(void) gen2if (local, &b_iov, ADDR_LISTEN);
if (bind (sd, &b_iov, sizeof(b_iov)) != NOTOK) {
if (ioctl(sd, CCL_AUTO_ACCEPT, 1) < 0) {
SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
("CCL_AUTO_ACCEPT"));
close (sd);
return NOTOK;
}
(void) listen (sd, backlog);
return sd;
}
(void) close (sd);
return NOTOK;
}
/* \f
*/
int join_x25_client (fd, remote)
int fd;
struct NSAPaddr *remote;
{
CONN_DB sck;
struct iovec *iov;
int i, len = 0;
int nfd;
char param1[128];
char param2[128];
char param3[128];
char param4[256];
iov = &(sck.ccl_iovec[0]);
if((nfd = accept (fd, (char *) 0, &len)) == NOTOK)
return NOTOK;
iov[0].iov_base = param1;
iov[1].iov_base = param2;
iov[2].iov_base = param3;
iov[3].iov_base = param4;
iov[0].iov_len = iov[1].iov_len = iov[2].iov_len = 128;
iov[3].iov_len = 256;
iov[4].iov_len = iov[5].iov_len = iov[6].iov_len = 0;
if (ioctl(nfd, CCL_FETCH_CONNECT, &iov[0]) < 0)
return NOTOK;
(void) if2gen (remote, &sck, ADDR_REMOTE);
ioctl (nfd, CCL_SEND_TYPE, 0);
return nfd;
}
int join_x25_server (fd, remote)
int fd;
struct NSAPaddr *remote;
{
CONN_DB zsck;
CONN_DB *sck = &zsck;
int r;
struct iovec *iov = &( zsck.ccl_iovec[0] );
char param1[128];
char param3[128];
char param4[256];
if (remote == NULLNA || remote -> na_type != NA_X25)
{
SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
("Invalid type na%d", remote->na_type));
return NOTOK;
}
iov[0].iov_base = param1;
iov[1].iov_base = calling_dte;
iov[1].iov_len = strlen(calling_dte);
iov[2].iov_base = param3;
iov[3].iov_base = param4;
iov[4].iov_len = iov[5].iov_len = iov[6].iov_len = 0;
(void) gen2if (remote, sck, ADDR_REMOTE);
if ((r = connect (fd, sck, sizeof (CONN_DB))) >= 0)
ioctl (fd, CCL_SEND_TYPE, 0);
bzero(calling_dte, sizeof calling_dte );
return (r);
}
int read_x25_socket (fd, buffer, len)
int fd, len;
char *buffer;
{
static u_char mode;
int cc, count = 0, total = len;
char *p = buffer;
do {
cc = recv (fd, p, total, 0);
switch (cc) {
case NOTOK:
if (errno == ECONNRESET) {
struct iovec iov[7];
char parm[34];
int i;
iov[0].iov_base = parm;
iov[0].iov_len = 1;
iov[1].iov_base = parm + 1;
iov[1].iov_len = 32;
for (i = 2; i < 7; i++) {
iov[i].iov_base = (char *)0;
iov[i].iov_len = 0;
}
ioctl(fd, CCL_FETCH_RESET, iov);
elucidate_x25_err( 1 << RECV_DIAG, iov[0].iov_base);
}
case 0:
return cc;
default:
ioctl (fd, CCL_RECV_TYPE, &mode);
count += cc;
p += cc;
total -= cc;
break;
}
} while (total > 0 && (mode & MORE_DATA));
DLOG (compat_log, LLOG_DEBUG,
("X25 read, total %d", count ));
return count;
}
int write_x25_socket (fd, buffer, len)
int fd, len;
char *buffer;
{
int count;
int cc;
count = send(fd, buffer, len, 0);
DLOG (compat_log, LLOG_DEBUG,
("X25 write, total %d/%d", count, len));
return count;
}
#endif
#ifdef CONS
#include "cons.h"
/* L */
int start_cons_client (local)
struct NSAPaddr *local;
{
int sd, pgrp;
if (local != NULLNA)
local -> na_type = NA_NSAP;
if ((sd = socket (AF_CCL, SOCK_STREAM, cons_is_ybts ? CCLPROTO_YBTS : CCLPROTO_CONS)) == NOTOK) {
SLOG (compat_log, LLOG_EXCEPTIONS), "failed", ("socket"));
return NOTOK; /* Error can be found in errno */
}
pgrp = getpid();
if (ioctl(sd, SIOCSPGRP, &pgrp)) {
SLOG (compat_log, LLOG_EXCEPTIONS), "failed",("SIOCSPGRP"));
return NOTOK; /* Error can be found in errno */
}
return sd;
}
/* \f
*/
int start_cons_server (local, backlog, opt1, opt2)
struct NSAPaddr *local;
int backlog,
opt1,
opt2;
{
int sd, pgrp;
CONN_DB b_iov;
if ((sd = socket (AF_CCL, SOCK_STREAM, cons_is_ybts ? CCLPROTO_YBTS : CCLPROTO_CONS)) == NOTOK) {
SLOG (compat_log, LLOG_EXCEPTIONS), "failed", ("socket"));
return NOTOK; /* Ca't get an CONS socket */
}
pgrp = getpid();
if (ioctl(sd, SIOCSPGRP, &pgrp)) {
SLOG (compat_log, LLOG_EXCEPTIONS), "failed", ("SIOCSPGRP"));
return NOTOK; /* Error can be found in errno */
}
if (local != NULLNA)
local -> na_type = NA_NSAP;
if (local -> na_addrlen == 0) {
(void) strcpy (local -> na_address, cons_local_address);
local -> na_addrlen = strlen(cons_local_address);
}
(void) gen2if (local, &b_iov, ADDR_LISTEN);
if (bind (sd, &b_iov, sizeof(b_iov)) != NOTOK) {
if (ioctl(sd, CCL_AUTO_ACCEPT, 1) < 0) {
SLOG (compat_log, LLOG_EXCEPTIONS), "failed", ("CCL_AUTO_ACCEPT"));
close (sd);
return NOTOK;
}
(void) listen (sd, backlog);
return sd;
}
(void) close (sd);
return NOTOK;
}
/* \f
*/
int join_cons_client (fd, remote)
int fd;
struct NSAPaddr *remote;
{
struct iovec iov[6];
int i, len = 0;
int nfd;
char param1[128];
char param2[128];
char param3[128];
char param4[128];
if((nfd = accept (fd, (char *) 0, &len)) == NOTOK)
return NOTOK;
iov[0].iov_base = param1;
iov[1].iov_base = param2;
iov[2].iov_base = param3;
iov[3].iov_base = param4;
for (i = 0; i < 4; i++) iov[i].iov_len = 128;
iov[4].iov_len = iov[5].iov_len = 0;
if (ioctl(nfd, CCL_FETCH_CONNECT, &iov[0]) < 0)
return NOTOK;
(void) if2gen (remote, (CONN_DB *)&iov[0], ADDR_REMOTE);
ioctl (nfd, CCL_SEND_TYPE, 0);
return nfd;
}
int join_cons_server (fd, remote)
int fd;
struct NSAPaddr *remote;
{
CONN_DB zsck;
CONN_DB *sck = &zsck;
int r;
if (remote == NULLNA || remote -> na_type != NA_NSAP)
{
SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
("Invalid type na%d", remote->na_type));
return NOTOK;
}
(void) gen2if (remote, sck, ADDR_REMOTE);
if ((r = connect (fd, sck, sizeof (CONN_DB))) >= 0)
ioctl (fd, CCL_SEND_TYPE, 0);
return (r);
}
int read_cons_socket (fd, buffer, len)
int fd, len;
char *buffer;
{
static u_char mode;
int cc, count = 0, total = len;
char *p = buffer;
do {
cc = recv (fd, p, total, 0);
switch (cc) {
case NOTOK:
if (errno == ECONNRESET) {
struct iovec iov[6];
char parm[32];
int i;
iov[0].iov_base = parm;
iov[0].iov_len = 32;
for (i = 1; i < 6; i++) {
iov[i].iov_base = (char *)0;
iov[i].iov_len = 0;
}
ioctl(fd, CCL_FETCH_RESET, &iov[0]);
}
case 0:
return cc;
default:
ioctl (fd, CCL_RECV_TYPE, &mode);
count += cc;
p += cc;
total -= cc;
break;
}
} while (total > 0 && (mode & MORE_DATA));
return count;
}
int write_cons_socket (fd, buffer, len)
int fd, len;
char *buffer;
{
int count;
int cc;
count = send(fd, buffer, len, 0);
SLOG (compat_log, LLOG_DEBUG, NULLCP,
("CONS write, total %d/%d", count, len));
return count;
}
#endif
#endif