summaryrefslogtreecommitdiff
path: root/usr/src/lib/libnsl/dial/interface.c
diff options
context:
space:
mode:
authorrobinson <none@none>2005-07-01 13:10:39 -0700
committerrobinson <none@none>2005-07-01 13:10:39 -0700
commit61961e0f20c7637a3846bb39786bb9dffa91dfb9 (patch)
treea205cd61b8055bd820ff84bd5412bcea48fc08ee /usr/src/lib/libnsl/dial/interface.c
parent6550f384c4c0d912ed90ff04d9da05ce4b4501e6 (diff)
downloadillumos-gate-61961e0f20c7637a3846bb39786bb9dffa91dfb9.tar.gz
PSARC/2005/362 Removal of <rpc/trace.h>
4426428 libnsl needs some tidying up 6256192 Remaining ulonglong_t needs to be exorcised 6267468 rpcgen generates code gcc doesn't like 6271220 rpc/trace.h is obsolete and dead code 6271232 rpcgen fails to cast memset correctly --HG-- rename : usr/src/lib/libnsl/dial/dk.h => deleted_files/usr/src/lib/libnsl/dial/dk.h rename : usr/src/lib/libnsl/dial/dkbreak.c => deleted_files/usr/src/lib/libnsl/dial/dkbreak.c rename : usr/src/lib/libnsl/dial/dkdial.c => deleted_files/usr/src/lib/libnsl/dial/dkdial.c rename : usr/src/lib/libnsl/dial/dkerr.c => deleted_files/usr/src/lib/libnsl/dial/dkerr.c rename : usr/src/lib/libnsl/dial/dkminor.c => deleted_files/usr/src/lib/libnsl/dial/dkminor.c rename : usr/src/lib/libnsl/dial/dtnamer.c => deleted_files/usr/src/lib/libnsl/dial/dtnamer.c rename : usr/src/lib/libnsl/rpc/rpc_trace.c => deleted_files/usr/src/lib/libnsl/rpc/rpc_trace.c rename : usr/src/uts/common/rpc/trace.h => deleted_files/usr/src/uts/common/rpc/trace.h
Diffstat (limited to 'usr/src/lib/libnsl/dial/interface.c')
-rw-r--r--usr/src/lib/libnsl/dial/interface.c309
1 files changed, 77 insertions, 232 deletions
diff --git a/usr/src/lib/libnsl/dial/interface.c b/usr/src/lib/libnsl/dial/interface.c
index bd69864ba7..3c789c1b0a 100644
--- a/usr/src/lib/libnsl/dial/interface.c
+++ b/usr/src/lib/libnsl/dial/interface.c
@@ -19,90 +19,67 @@
*
* CDDL HEADER END
*/
+
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-/* interface( label )
- provide alternate definitions for the I/O functions through global
- interfaces.
-*/
+/*
+ * interface( label )
+ * provide alternate definitions for the I/O functions through global
+ * interfaces.
+ */
#include "uucp.h"
-#include <rpc/trace.h>
-
+#include <unistd.h>
#ifdef TLI
#include <tiuser.h>
-char *t_alloc();
-int t_bind(), t_close(), t_connect(), t_free(), t_look(), t_open(), t_rcvdis();
-int t_getinfo(), t_getstate(), t_look(), t_rcv(), t_snd(), t_sync(), t_unbind();
#endif /* TLI */
-#ifdef DATAKIT
-#include "dk.h"
-
-static int dksetup();
-static int dkteardown();
-#endif /* DATAKIT */
-
-EXTERN void sethup();
-EXTERN int restline();
-extern ssize_t read(), write();
-static int usetup(), uteardown();
+static void sethup(int);
+static int restline(void);
+static int usetup(int, int *, int *);
+static int uteardown(int, int, int);
-GLOBAL ssize_t (*Read)() = read,
+static ssize_t (*Read)() = read,
(*Write)() = write;
-GLOBAL int (*Ioctl)(int,int,...) = ioctl,
- (*Setup)() = usetup,
- (*Teardown)() = uteardown;
+static int (*Ioctl)(int, int, ...) = ioctl,
+ (*Setup)() = usetup;
#ifdef TLI
-EXTERN void tfaillog(int fd, const char *s);
-EXTERN void show_tlook();
-static ssize_t tread(), twrite(); /* TLI i/o */
-static int tioctl(int, int, ...),
- tsetup(), /* TLI setup without streams module */
- tssetup(), /* TLI setup with streams module */
- tteardown(); /* TLI teardown, works with either setup
- */
+static void tfaillog(int fd, const char *s);
+static void show_tlook(int);
+static ssize_t tread(int, char *, unsigned);
+static ssize_t twrite(int, char *, unsigned);
+static int tioctl(int, int, ...);
+static int tsetup(int, int *, int *); /* TLI setup without streams module */
+static int tssetup(int, int *, int *); /* TLI setup with streams module */
+static int tteardown(int, int, int); /* TLI teardown, works with either setup */
#endif /* TLI */
-/* The IN_label in Interface[] imply different caller routines:
- e.g. tlicall().
- If so, the names here and the names in callers.c must match.
-*/
-static
- struct Interface {
- const char *IN_label; /* interface name */
+/*
+ * The IN_label in Interface[] imply different caller routines:
+ * e.g. tlicall().
+ * If so, the names here and the names in callers.c must match.
+ */
+static struct Interface {
+ const char *IN_label; /* interface name */
ssize_t (*IN_read)(); /* read function */
ssize_t (*IN_write)(); /* write function */
- int (*IN_ioctl)(int,int,...);
- int (*IN_setup)(); /* setup function, called before first
- i/o operation */
- int (*IN_teardown)(); /* teardown function, called after last
- i/o operation */
+ int (*IN_ioctl)(int, int, ...);
+ int (*IN_setup)(); /* setup function, called before */
+ /* first i/o operation */
+ int (*IN_teardown)(); /* teardown function, called after */
+ /* last i/o operation */
} Interface[] = {
/* vanilla UNIX */
{ "UNIX", read, write, ioctl, usetup, uteardown },
-#ifdef SYTEK
- /* Sytek network */
- { "Sytek", read, write, ioctl, usetup, uteardown },
-#endif /* Sytek network */
-#ifdef DIAL801
- /* 801 auto dialers */
- { "801", read, write, ioctl, usetup, uteardown },
-#endif /* DIAL801 */
-#ifdef DIAL801
- /* 212 auto dialers */
- { "212", read, write, ioctl, usetup, uteardown },
-#endif /* DIAL801 */
#ifdef TLI
/* AT&T Transport Interface Library WITHOUT streams */
{ "TLI", tread, twrite, tioctl, tsetup, tteardown },
@@ -111,39 +88,25 @@ static
{ "TLIS", read, write, tioctl, tssetup, uteardown },
#endif /* TLIS */
#endif /* TLI */
-#ifdef DATAKIT
- { "DK", read, write, ioctl, dksetup, dkteardown },
-#endif /* DATAKIT */
-#ifdef UNET /* this should work for 4.2BSD and 3com */
- { "TCP", read, write, ioctl, usetup, uteardown },
-#endif
-#ifdef UNET
- { "Unetserver", read, write, ioctl, usetup, uteardown },
-#endif
{ 0, 0, 0, 0, 0, 0 }
};
-GLOBAL int
-interface(label)
-char *label;
+static int
+interface(const char *label)
{
- register int i;
+ int i;
- trace1(TR_interface, 0);
for (i = 0; Interface[i].IN_label; ++i) {
- if (!strcmp(Interface[i].IN_label, label)) {
+ if (strcmp(Interface[i].IN_label, label) == 0) {
Read = Interface[i].IN_read;
Write = Interface[i].IN_write;
Ioctl = Interface[i].IN_ioctl;
Setup = Interface[i].IN_setup;
- Teardown = Interface[i].IN_teardown;
DEBUG(5, "set interface %s\n", label);
- trace1(TR_interface, 1);
return (0);
}
}
- trace1(TR_interface, 1);
return (FAIL);
}
@@ -153,13 +116,11 @@ char *label;
static int
usetup(int role, int *fdreadp, int *fdwritep)
{
- trace1(TR_usetup, 0);
if (role == SLAVE) {
*fdreadp = 0;
*fdwritep = 1;
/* 2 has been re-opened to RMTDEBUG in main() */
}
- trace1(TR_usetup, 1);
return (SUCCESS);
}
@@ -169,125 +130,49 @@ usetup(int role, int *fdreadp, int *fdwritep)
static int
uteardown(int role, int fdread, int fdwrite)
{
- int ret;
char *ttyn;
- trace1(TR_uteardown, 0);
if (role == SLAVE) {
- ret = restline();
- DEBUG(4, "ret restline - %d\n", ret);
+ (void) restline();
sethup(0);
}
if (fdread != -1) {
ttyn = ttyname(fdread);
if (ttyn != NULL)
- chmod(ttyn, Dev_mode); /* can fail, but who cares? */
+ /* can fail, but who cares? */
+ (void) chmod(ttyn, Dev_mode);
(void) close(fdread);
(void) close(fdwrite);
}
- trace1(TR_uteardown, 1);
- return (SUCCESS);
-}
-
-#ifdef DATAKIT
-/*
- * dksetup - DATAKIT setup routine
- *
- * Put line in block mode.
- */
-
-static int
-dksetup (role, fdreadp, fdwritep)
-int role;
-int * fdreadp;
-int * fdwritep;
-{
- static short dkrmode[3] = { DKR_BLOCK | DKR_TIME, 0, 0 };
- int ret;
-
- trace2(TR_dksetup, 0, role);
- (void) usetup(role, fdreadp, fdwritep);
- if ((ret = (*Ioctl)(*fdreadp, DIOCRMODE, dkrmode)) < 0) {
- DEBUG(4, "dksetup: failed to set block mode. ret=%d,\n", ret);
- DEBUG(4, "read fd=%d, ", *fdreadp);
- DEBUG(4, "errno=%d\n", errno);
- trace1(TR_dksetup, 1);
- return (FAIL);
- }
- trace1(TR_dksetup, 1);
return (SUCCESS);
}
-/*
- * dkteardown - DATAKIT teardown routine
- */
-static int
-dkteardown(role, fdread, fdwrite)
-int role, fdread, fdwrite;
-{
- char *ttyn;
-
- trace4(TR_dkteardown, 0, role, fdread, fdwrite);
- if (role == MASTER) {
- ttyn = ttyname(fdread);
- if (ttyn != NULL)
- chmod(ttyn, Dev_mode); /* can fail, but who cares? */
- }
-
- /* must flush fd's for datakit */
- /* else close can hang */
- if (ioctl(fdread, DIOCFLUSH, NULL) != 0)
- DEBUG(4, "dkteardown: DIOCFLUSH of input fd %d failed", fdread);
- if (ioctl(fdwrite, DIOCFLUSH, NULL) != 0)
- DEBUG(4, "dkteardown: DIOCFLUSH of output fd %d failed", fdwrite);
-
- (void) close(fdread);
- (void) close(fdwrite);
- trace1(TR_dkteardown, 1);
- return (SUCCESS);
-}
-#endif /* DATAKIT */
-
-
#ifdef TLI
/*
* tread - tli read routine
*/
static ssize_t
-tread(fd, buf, nbytes)
-int fd;
-char *buf;
-unsigned nbytes;
+tread(int fd, char *buf, unsigned nbytes)
{
int rcvflags;
- int dummy;
- trace2(TR_tread, 0, fd);
- dummy = t_rcv(fd, buf, nbytes, &rcvflags);
- trace1(TR_tread, 1);
- return ((ssize_t)dummy);
-}
+ return ((ssize_t)t_rcv(fd, buf, nbytes, &rcvflags));
+}
/*
* twrite - tli write routine
*/
#define N_CHECK 100
static ssize_t
-twrite(fd, buf, nbytes)
-int fd;
-char *buf;
-unsigned nbytes;
+twrite(int fd, char *buf, unsigned nbytes)
{
- register int i, ret;
+ int i, ret;
static int n_writ, got_info;
static struct t_info info;
- int dummy;
- trace3(TR_twrite, 0, fd, nbytes);
if (got_info == 0) {
if (t_getinfo(fd, &info) != 0) {
tfaillog(fd, "twrite: t_getinfo\n");
- trace1(TR_twrite, 1);
return (FAIL);
}
got_info = 1;
@@ -296,36 +181,26 @@ unsigned nbytes;
/* on every N_CHECKth call, check that are still in DATAXFER state */
if (++n_writ == N_CHECK) {
n_writ = 0;
- if (t_getstate(fd) != T_DATAXFER) {
- trace1(TR_twrite, 1);
+ if (t_getstate(fd) != T_DATAXFER)
return (FAIL);
- }
- }
-
- if (info.tsdu <= 0 || nbytes <= info.tsdu) {
- dummy = t_snd(fd, buf, nbytes, NULL);
- trace1(TR_twrite, 1);
- return ((ssize_t)dummy);
}
+
+ if (info.tsdu <= 0 || nbytes <= info.tsdu)
+ return ((ssize_t)t_snd(fd, buf, nbytes, NULL));
/* if get here, then there is a limit on transmit size */
/* (info.tsdu > 0) and buf exceeds it */
i = ret = 0;
while (nbytes >= info.tsdu) {
- if ((ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu) {
- trace1(TR_twrite, 1);
+ if ((ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu)
return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
- }
i += info.tsdu;
nbytes -= info.tsdu;
}
if (nbytes != 0) {
- if ((ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes) {
- trace1(TR_twrite, 1);
+ if ((ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes)
return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
- }
i += nbytes;
}
- trace1(TR_twrite, 1);
return ((ssize_t)i);
}
@@ -334,15 +209,8 @@ unsigned nbytes;
*/
/* ARGSUSED */
static int
-#ifdef __STDC__
tioctl(int fd, int request, ...)
-#else
-tioctl(fd, request, arg)
-int fd, request;
-#endif
{
- trace1(TR_tioctl, 0);
- trace1(TR_tioctl, 1);
return (SUCCESS);
}
@@ -353,7 +221,6 @@ int fd, request;
static int
tsetup(int role, int *fdreadp, int *fdwritep)
{
- trace1(TR_tsetup, 0);
if (role == SLAVE) {
*fdreadp = 0;
*fdwritep = 1;
@@ -361,11 +228,9 @@ tsetup(int role, int *fdreadp, int *fdwritep)
errno = t_errno = 0;
if (t_sync(*fdreadp) == -1 || t_sync(*fdwritep) == -1) {
tfaillog(*fdreadp, "tsetup: t_sync\n");
- trace1(TR_tsetup, 1);
return (FAIL);
}
}
- trace1(TR_tsetup, 1);
return (SUCCESS);
}
@@ -376,10 +241,8 @@ tsetup(int role, int *fdreadp, int *fdwritep)
static int
tteardown(int role, int fdread, int fdwrite)
{
- trace1(TR_tteardown, 0);
(void) t_unbind(fdread);
(void) t_close(fdread);
- trace1(TR_tteardown, 1);
return (SUCCESS);
}
@@ -389,72 +252,61 @@ tteardown(int role, int fdread, int fdwrite)
* note blatant assumption that *fdreadp == *fdwritep
*/
static int
-tssetup(role, fdreadp, fdwritep)
-int role;
-int *fdreadp;
-int *fdwritep;
+tssetup(int role, int *fdreadp, int *fdwritep)
{
- trace2(TR_tssetup, 0, role);
if (role == SLAVE) {
*fdreadp = 0;
*fdwritep = 1;
/* 2 has been re-opened to RMTDEBUG in main() */
DEBUG(5, "tssetup: SLAVE mode: leaving ok\n%s", "");
- trace1(TR_tssetup, 1);
return (SUCCESS);
}
DEBUG(4, "tssetup: MASTER mode: leaving ok\n%s", "");
- trace1(TR_tssetup, 1);
return (SUCCESS);
}
/*
* Report why a TLI call failed.
*/
-GLOBAL void
-tfaillog(fd, s)
-int fd;
-const char *s;
+static void
+tfaillog(int fd, const char *s)
{
char fmt[ BUFSIZ ];
- trace2(TR_tfaillog, 0, fd);
if (0 < t_errno && t_errno < t_nerr) {
- sprintf(fmt, "%s: %%s\n", s);
+ (void) snprintf(fmt, sizeof (fmt), "%s: %%s\n", s);
DEBUG(5, fmt, t_errlist[t_errno]);
logent(s, t_errlist[t_errno]);
if (t_errno == TSYSERR) {
- strcpy(fmt, "tlicall: system error: %s\n");
+ (void) strcpy(fmt, "tlicall: system error: %s\n");
DEBUG(5, fmt, strerror(errno));
} else if (t_errno == TLOOK) {
show_tlook(fd);
}
} else {
- sprintf(fmt, "unknown tli error %d", t_errno);
+ (void) snprintf(fmt, sizeof (fmt),
+ "unknown tli error %d", t_errno);
logent(s, fmt);
- sprintf(fmt, "%s: unknown tli error %d", s, t_errno);
+ (void) snprintf(fmt, sizeof (fmt),
+ "%s: unknown tli error %d", s, t_errno);
DEBUG(5, fmt, 0);
- sprintf(fmt, "%s: %%s\n", s);
+ (void) snprintf(fmt, sizeof (fmt), "%s: %%s\n", s);
DEBUG(5, fmt, strerror(errno));
}
- trace1(TR_tfaillog, 1);
- return;
}
-GLOBAL void
-show_tlook(fd)
-int fd;
+static void
+show_tlook(int fd)
{
- register int reason;
- register const char *msg;
+ int reason;
+ const char *msg;
/*
* Find out the current state of the interface.
*/
- trace2(TR_show_tlook, 0, fd);
errno = t_errno = 0;
- switch(reason = t_getstate(fd)) {
+ switch (reason = t_getstate(fd)) {
case T_UNBND: msg = (const char *)"T_UNBIND"; break;
case T_IDLE: msg = (const char *)"T_IDLE"; break;
case T_OUTCON: msg = (const char *)"T_OUTCON"; break;
@@ -464,12 +316,10 @@ int fd;
case T_INREL: msg = (const char *)"T_INREL"; break;
default: msg = NULL; break;
}
- if (msg == NULL) {
- trace1(TR_show_tlook, 1);
+ if (msg == NULL)
return;
- }
DEBUG(5, "state is %s", msg);
- switch(reason = t_look(fd)) {
+ switch (reason = t_look(fd)) {
case -1: msg = (const char *)""; break;
case 0: msg = (const char *)"NO ERROR"; break;
case T_LISTEN: msg = (const char *)"T_LISTEN"; break;
@@ -484,24 +334,19 @@ int fd;
}
DEBUG(4, " reason is %s\n", msg);
- if (reason == T_DISCONNECT)
- {
+ if (reason == T_DISCONNECT) {
struct t_discon *dropped;
- if (((dropped =
- (struct t_discon *)t_alloc(fd, T_DIS, T_ALL)) == 0)
- || (t_rcvdis(fd, dropped) == -1)) {
+ if (((dropped =
+ /* LINTED pointer cast */
+ (struct t_discon *)t_alloc(fd, T_DIS, T_ALL)) == 0) ||
+ (t_rcvdis(fd, dropped) == -1)) {
if (dropped)
- t_free((char *)dropped, T_DIS);
- trace1(TR_show_tlook, 1);
+ (void) t_free((char *)dropped, T_DIS);
return;
}
DEBUG(5, "disconnect reason #%d\n", dropped->reason);
- t_free((char *)dropped, T_DIS);
+ (void) t_free((char *)dropped, T_DIS);
}
- trace1(TR_show_tlook, 1);
- return;
}
-
#endif /* TLIS */
-
#endif /* TLI */