Place files back on the vendor branch.
Prodded by: ru
This commit is contained in:
parent
e42ab7cde1
commit
24dc798a69
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/ngatm/dist/; revision=135923
@ -44,7 +44,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <isc/eventlib.h>
|
|
||||||
|
|
||||||
#include <netnatm/unimsg.h>
|
#include <netnatm/unimsg.h>
|
||||||
#include <netnatm/saal/sscop.h>
|
#include <netnatm/saal/sscop.h>
|
||||||
@ -64,7 +63,9 @@ int user_fd;
|
|||||||
int loose;
|
int loose;
|
||||||
int user_out_fd;
|
int user_out_fd;
|
||||||
u_int verbose;
|
u_int verbose;
|
||||||
|
#ifndef USE_LIBBEGEMOT
|
||||||
evContext evctx;
|
evContext evctx;
|
||||||
|
#endif
|
||||||
evFileID sscop_h;
|
evFileID sscop_h;
|
||||||
evFileID user_h;
|
evFileID user_h;
|
||||||
|
|
||||||
@ -153,7 +154,11 @@ proto_msgin(int fd __unused)
|
|||||||
|
|
||||||
if (got == 0) {
|
if (got == 0) {
|
||||||
eof:
|
eof:
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_unregister(sscop_h);
|
||||||
|
#else
|
||||||
evDeselectFD(evctx, sscop_h);
|
evDeselectFD(evctx, sscop_h);
|
||||||
|
#endif
|
||||||
(void)close(sscop_fd);
|
(void)close(sscop_fd);
|
||||||
sscop_fd = -1;
|
sscop_fd = -1;
|
||||||
if (m != NULL)
|
if (m != NULL)
|
||||||
@ -212,7 +217,11 @@ user_msgin(int fd __unused)
|
|||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
eof:
|
eof:
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_unregister(user_h);
|
||||||
|
#else
|
||||||
evDeselectFD(evctx, user_h);
|
evDeselectFD(evctx, user_h);
|
||||||
|
#endif
|
||||||
if (m != NULL)
|
if (m != NULL)
|
||||||
uni_msg_destroy(m);
|
uni_msg_destroy(m);
|
||||||
VERBOSE(("EOF on user connection"));
|
VERBOSE(("EOF on user connection"));
|
||||||
@ -384,9 +393,14 @@ parse_param(struct sscop_param *param, u_int *pmask, int opt, char *arg)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
static void
|
||||||
|
tfunc(int tid __unused, void *uap)
|
||||||
|
#else
|
||||||
static void
|
static void
|
||||||
tfunc(evContext ctx __unused, void *uap, struct timespec due __unused,
|
tfunc(evContext ctx __unused, void *uap, struct timespec due __unused,
|
||||||
struct timespec inter __unused)
|
struct timespec inter __unused)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct timer *t = uap;
|
struct timer *t = uap;
|
||||||
|
|
||||||
@ -402,18 +416,25 @@ sscop_start_timer(struct sscop *sscop, void *arg __unused, u_int msec,
|
|||||||
void (*func)(void *))
|
void (*func)(void *))
|
||||||
{
|
{
|
||||||
struct timer *t;
|
struct timer *t;
|
||||||
|
#ifndef USE_LIBBEGEMOT
|
||||||
struct timespec due;
|
struct timespec due;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((t = malloc(sizeof(*t))) == NULL)
|
if ((t = malloc(sizeof(*t))) == NULL)
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
t->sscop = sscop;
|
t->sscop = sscop;
|
||||||
t->func = func;
|
t->func = func;
|
||||||
|
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
if ((t->id = poll_start_timer(msec, 0, tfunc, t)) == -1)
|
||||||
|
err(1, "cannot start timer");
|
||||||
|
#else
|
||||||
due = evAddTime(evNowTime(),
|
due = evAddTime(evNowTime(),
|
||||||
evConsTime((time_t)msec/1000, (long)(msec%1000)*1000));
|
evConsTime((time_t)msec/1000, (long)(msec%1000)*1000));
|
||||||
|
|
||||||
if (evSetTimer(evctx, tfunc, t, due, evConsTime(0, 0), &t->id))
|
if (evSetTimer(evctx, tfunc, t, due, evConsTime(0, 0), &t->id))
|
||||||
err(1, "cannot start timer");
|
err(1, "cannot start timer");
|
||||||
|
#endif
|
||||||
|
|
||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
@ -426,6 +447,10 @@ sscop_stop_timer(struct sscop *sscop __unused, void *arg __unused, void *tp)
|
|||||||
{
|
{
|
||||||
struct timer *t = tp;
|
struct timer *t = tp;
|
||||||
|
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_stop_timer(t->id);
|
||||||
|
#else
|
||||||
evClearTimer(evctx, t->id);
|
evClearTimer(evctx, t->id);
|
||||||
|
#endif
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,14 @@
|
|||||||
#ifndef _SAAL_COMMON_H_
|
#ifndef _SAAL_COMMON_H_
|
||||||
#define _SAAL_COMMON_H_
|
#define _SAAL_COMMON_H_
|
||||||
|
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
#include <rpoll.h>
|
||||||
|
#define evFileID int
|
||||||
|
#define evTimerID int
|
||||||
|
#else
|
||||||
|
#include <isc/eventlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes to a pipe must be in messages (if we don't use framing).
|
* Writes to a pipe must be in messages (if we don't use framing).
|
||||||
* It is not clear, what is the maximum message size for this. It seems
|
* It is not clear, what is the maximum message size for this. It seems
|
||||||
@ -49,7 +57,9 @@ extern int user_fd; /* file descriptor for USER */
|
|||||||
extern int loose; /* loose messages */
|
extern int loose; /* loose messages */
|
||||||
extern int user_out_fd; /* file descriptor for output to user */
|
extern int user_out_fd; /* file descriptor for output to user */
|
||||||
extern u_int verbose; /* talk to me */
|
extern u_int verbose; /* talk to me */
|
||||||
|
#ifndef USE_LIBBEGEMOT
|
||||||
extern evContext evctx;
|
extern evContext evctx;
|
||||||
|
#endif
|
||||||
extern evFileID sscop_h;
|
extern evFileID sscop_h;
|
||||||
extern evFileID user_h;
|
extern evFileID user_h;
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <isc/eventlib.h>
|
|
||||||
|
|
||||||
#include <netnatm/unimsg.h>
|
#include <netnatm/unimsg.h>
|
||||||
#include <netnatm/saal/sscop.h>
|
#include <netnatm/saal/sscop.h>
|
||||||
@ -95,8 +94,13 @@ static const struct sscop_funcs sscop_funcs = {
|
|||||||
* SSCOP file descriptor is ready. Allocate and read one message
|
* SSCOP file descriptor is ready. Allocate and read one message
|
||||||
* and dispatch a signal.
|
* and dispatch a signal.
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
static void
|
||||||
|
proto_infunc(int fd, int mask __unused, void *uap)
|
||||||
|
#else
|
||||||
static void
|
static void
|
||||||
proto_infunc(evContext ctx __unused, void *uap, int fd, int mask __unused)
|
proto_infunc(evContext ctx __unused, void *uap, int fd, int mask __unused)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct uni_msg *m;
|
struct uni_msg *m;
|
||||||
|
|
||||||
@ -107,8 +111,13 @@ proto_infunc(evContext ctx __unused, void *uap, int fd, int mask __unused)
|
|||||||
/*
|
/*
|
||||||
* User input. Allocate and read message and dispatch signal.
|
* User input. Allocate and read message and dispatch signal.
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
static void
|
||||||
|
user_infunc(int fd, int mask __unused, void *uap)
|
||||||
|
#else
|
||||||
static void
|
static void
|
||||||
user_infunc(evContext ctx __unused, void *uap, int fd, int mask __unused)
|
user_infunc(evContext ctx __unused, void *uap, int fd, int mask __unused)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct uni_msg *m;
|
struct uni_msg *m;
|
||||||
|
|
||||||
@ -134,7 +143,9 @@ main(int argc, char *argv[])
|
|||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
int wait = 0;
|
int wait = 0;
|
||||||
u_int mask;
|
u_int mask;
|
||||||
|
#ifndef USE_LIBBEGEMOT
|
||||||
evEvent ev;
|
evEvent ev;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default is to have the USER on stdin and SSCOP on stdout
|
* Default is to have the USER on stdin and SSCOP on stdout
|
||||||
@ -209,8 +220,10 @@ main(int argc, char *argv[])
|
|||||||
if(user_out_fd < 0)
|
if(user_out_fd < 0)
|
||||||
user_out_fd = user_fd;
|
user_out_fd = user_fd;
|
||||||
|
|
||||||
|
#ifndef USE_LIBBEGEMOT
|
||||||
if (evCreate(&evctx))
|
if (evCreate(&evctx))
|
||||||
err(1, "evCreate");
|
err(1, "evCreate");
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Catch USR1
|
* Catch USR1
|
||||||
@ -233,8 +246,14 @@ main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Register sscop fd
|
* Register sscop fd
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
if ((sscop_h = poll_register(sscop_fd, proto_infunc,
|
||||||
|
sscop, POLL_IN)) == -1)
|
||||||
|
err(1, "can't select on sscop fd");
|
||||||
|
#else
|
||||||
if (evSelectFD(evctx, sscop_fd, EV_READ, proto_infunc, sscop, &sscop_h))
|
if (evSelectFD(evctx, sscop_fd, EV_READ, proto_infunc, sscop, &sscop_h))
|
||||||
err(1, "can't select on sscop fd");
|
err(1, "can't select on sscop fd");
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we are active - send establish request
|
* if we are active - send establish request
|
||||||
@ -246,11 +265,15 @@ main(int argc, char *argv[])
|
|||||||
* Run protocol until it get's ready
|
* Run protocol until it get's ready
|
||||||
*/
|
*/
|
||||||
while (sscop_fd >= 0 && !ready) {
|
while (sscop_fd >= 0 && !ready) {
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_dispatch(1);
|
||||||
|
#else
|
||||||
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
||||||
if (evDispatch(evctx, ev))
|
if (evDispatch(evctx, ev))
|
||||||
err(1, "dispatch event");
|
err(1, "dispatch event");
|
||||||
} else if (errno != EINTR)
|
} else if (errno != EINTR)
|
||||||
err(1, "get event");
|
err(1, "get event");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -265,15 +288,23 @@ main(int argc, char *argv[])
|
|||||||
VERBOSE(("READY - starting data transfer"));
|
VERBOSE(("READY - starting data transfer"));
|
||||||
|
|
||||||
if (!unidir &&
|
if (!unidir &&
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
((user_h = poll_register(user_fd, user_infunc, sscop, POLL_IN)) == -1))
|
||||||
|
#else
|
||||||
evSelectFD(evctx, user_fd, EV_READ, user_infunc, sscop, &user_h))
|
evSelectFD(evctx, user_fd, EV_READ, user_infunc, sscop, &user_h))
|
||||||
|
#endif
|
||||||
err(1, "can't select on sscop fd");
|
err(1, "can't select on sscop fd");
|
||||||
|
|
||||||
while (!sigusr1 && sscop_fd >= 0) {
|
while (!sigusr1 && sscop_fd >= 0) {
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_dispatch(1);
|
||||||
|
#else
|
||||||
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
||||||
if (evDispatch(evctx, ev))
|
if (evDispatch(evctx, ev))
|
||||||
err(1, "dispatch event");
|
err(1, "dispatch event");
|
||||||
} else if (errno != EINTR)
|
} else if (errno != EINTR)
|
||||||
err(1, "get event");
|
err(1, "get event");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sigusr1 && sscop_fd >= 0) {
|
if (sigusr1 && sscop_fd >= 0) {
|
||||||
@ -282,11 +313,15 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
sscop_aasig(sscop, SSCOP_RELEASE_request, NULL, 0);
|
sscop_aasig(sscop, SSCOP_RELEASE_request, NULL, 0);
|
||||||
while (!finished && sscop_fd >= 0) {
|
while (!finished && sscop_fd >= 0) {
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_dispatch(1);
|
||||||
|
#else
|
||||||
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
if (evGetNext(evctx, &ev, EV_WAIT) == 0) {
|
||||||
if (evDispatch(evctx, ev))
|
if (evDispatch(evctx, ev))
|
||||||
err(1, "dispatch event");
|
err(1, "dispatch event");
|
||||||
} else if (errno != EINTR)
|
} else if (errno != EINTR)
|
||||||
err(1, "get event");
|
err(1, "get event");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +368,11 @@ sscop_send_upper(struct sscop *sscop, void *arg __unused, enum sscop_aasig sig,
|
|||||||
case SSCOP_RELEASE_indication:
|
case SSCOP_RELEASE_indication:
|
||||||
if (end_at_eof) {
|
if (end_at_eof) {
|
||||||
VERBOSE((" ... exiting"));
|
VERBOSE((" ... exiting"));
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_unregister(sscop_h);
|
||||||
|
#else
|
||||||
evDeselectFD(evctx, sscop_h);
|
evDeselectFD(evctx, sscop_h);
|
||||||
|
#endif
|
||||||
(void)close(sscop_fd);
|
(void)close(sscop_fd);
|
||||||
sscop_fd = -1;
|
sscop_fd = -1;
|
||||||
}
|
}
|
||||||
@ -345,7 +384,11 @@ sscop_send_upper(struct sscop *sscop, void *arg __unused, enum sscop_aasig sig,
|
|||||||
case SSCOP_RELEASE_confirm:
|
case SSCOP_RELEASE_confirm:
|
||||||
if (end_at_eof) {
|
if (end_at_eof) {
|
||||||
VERBOSE((" ... exiting"));
|
VERBOSE((" ... exiting"));
|
||||||
|
#ifdef USE_LIBBEGEMOT
|
||||||
|
poll_unregister(sscop_h);
|
||||||
|
#else
|
||||||
evDeselectFD(evctx, sscop_h);
|
evDeselectFD(evctx, sscop_h);
|
||||||
|
#endif
|
||||||
(void)close(sscop_fd);
|
(void)close(sscop_fd);
|
||||||
sscop_fd = -1;
|
sscop_fd = -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user