netspool fixes

master
Sergey Dorofeev 13 years ago
parent b5f3f48f0d
commit b1adc98f2d

@ -1,3 +1,7 @@
=== 2012-02 ===
Netspool support
=== 2011-12-25 ===
Cmdline processing code is partially rewritten.

@ -101,7 +101,7 @@ BFORCE_OBJS = bforce/bforce.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o bforce/u_file.o \
bforce/u_pkt.o bforce/u_recode.o \
bforce/u_plock.o
bforce/u_plock.o bforce/netspool.o
.c.o:
@echo Compiling $*.c

@ -8,11 +8,10 @@
#include <sys/types.h>
#include <netdb.h>
#include "includes.h"
#include "netspool.h"
const char *RHOST = "172.31.251.3";
const char *RPORT = "24555";
#ifdef NETSPOOL
int readstr(int s, char *buf, int len) {
char c=0;
@ -99,7 +98,7 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
if( r ) {
state->state = NS_ERROR;
state->error = gai_error(r);
state->error = gai_strerror(r);
return;
}
@ -118,7 +117,7 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
if(r==-1) {
state->state = NS_ERROR;
state->error = "could not connect\n"
state->error = "could not connect";
return;
}
@ -139,7 +138,10 @@ void netspool_start(s_netspool_state *state, const char *host, const char *port,
void netspool_query(s_netspool_state *state, const char *what)
{
int r = sendstr(state->socket, "GET ALL");
char strbuf[STRBUF];
int r;
snprintf(strbuf, STRBUF, "GET %s", what); /* ALL or comma separated NETMAIL, ECHOMAIL... */
r = sendstr(state->socket, strbuf);
if( r ) {
state->state = NS_ERROR;
state->error = "IO error";
@ -153,7 +155,7 @@ void netspool_receive(s_netspool_state *state)
char strbuf[STRBUF];
int r;
r = readstr(s, strbuf, STRBUF);
r = readstr(state->socket, strbuf, STRBUF);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
puts(strbuf);
if(strcmp(strbuf, "QUEUE EMPTY")==0) {
@ -162,15 +164,15 @@ void netspool_receive(s_netspool_state *state)
}
if(strncmp(strbuf, "FILENAME ", 9)==0) {
strcpy(filename, strbuf+9);
puts(filename);
strcpy(state->filename, strbuf+9);
puts(state->filename);
} else {
state->state = NS_ERROR;
state->error = "expected filename or queue empty"
state->error = "expected filename or queue empty";
return;
}
r = readstr(s, strbuf, STRBUF);
r = readstr(state->socket, strbuf, STRBUF);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
if(strncmp(strbuf, "BINARY ", 7)==0) {
/*if(filename[0]==0) {
@ -182,7 +184,7 @@ void netspool_receive(s_netspool_state *state)
state->state = NS_RECVFILE;
} else {
state->state = NS_ERROR;
state->error = "expected binary"
state->error = "expected binary";
return;
}
@ -265,3 +267,4 @@ void savefile(const char *fn, unsigned long long l, int s)
close(f);
}
*/
#endif

@ -102,7 +102,9 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
/* network queue */
#ifdef NETSPOOL
log("start netspool");
if(state.netspool.state == NS_NOTINIT) {
log("netspool connection");
char password[9];
char address[300];
char *host = conf_string(cf_netspool_host);
@ -122,19 +124,24 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
}
}
if(state.netspool_state == NS_READY) {
if(state.netspool.state == NS_READY) {
log("netspool request");
netspool_query(&state.netspool, "ALL");
}
if(state.netspool_state == NS_RECEIVING) {
if(state.netspool.state == NS_RECEIVING) {
log("netspool begin receive");
netspool_receive(&state.netspool);
}
if(state.netspool_state == NS_RECVFILE) {
if(state.netspool.state == NS_RECVFILE) {
log("netspool start file");
*dest = NULL;
return 0;
}
log("netspool gives no more files");
#endif
return 1;
@ -292,7 +299,7 @@ get_next_file:
pi->send->action = ptrl->action;
pi->send->flodsc = ptrl->flodsc;
#idef NETSPOOL
#ifdef NETSPOOL
}
#endif
@ -435,8 +442,8 @@ int p_tx_fclose(s_protinfo *pi)
logerr("send: cannot truncate file \"%s\"", pi->send->fname);
break;
#ifdef NETSPOOL
case ACTION_ACKNOWLEDE:
netspool_acknowlede(&state.netspool);
case ACTION_ACKNOWLEDGE:
netspool_acknowledge(&state.netspool);
break;
#endif
}
@ -465,8 +472,8 @@ int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
long ftell_pos;
#ifdef NETSPOOL
if(pi->send->fname==NULL && strcmp(pi->send->localname, "NETSPOOL")==0 ) {
if( state->state != NS_RECVFILE ) {
if(pi->send->fname==NULL && strcmp(pi->send->local_name, "NETSPOOL")==0 ) {
if( state.netspool.state != NS_RECVFILE ) {
log("send: wrong netspool state");
pi->send->status = FSTAT_SKIPPED;
return -2;
@ -475,7 +482,7 @@ int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
pi->send->eofseen = state.netspool.length == 0;
if( n==-1 ) {
log("send: netspool error");
log(netspool->state->error);
log(state.netspool.error);
pi->send->status = FSTAT_SKIPPED;
return -2;
}
@ -1278,6 +1285,9 @@ void p_session_cleanup(s_protinfo *pi, bool success)
}
#ifdef NETSPOOL
if(state.netspool.state==NS_ERROR) {
log("netspool error %s", state.netspool.error);
}
netspool_end(&state.netspool);
#endif
}

9278
source/configure vendored

File diff suppressed because it is too large Load Diff

@ -82,6 +82,11 @@ AC_ARG_ENABLE(syslog, [ --enable-syslog use syslog for logging [experimen
AC_DEFINE([USE_SYSLOG], [1], [Use syslog for logging])
fi], [AC_DEFINE([USE_SYSLOG], [1], [Use syslog for logging])])
AC_ARG_ENABLE(netspool, [ --enable-netspool network attached inbound/outbound],
[if test $enableval = yes; then
AC_DEFINE([NETSPOOL], [1], [Use netspool])
fi], [AC_DEFINE([NETSPOOL], [1], [Use netspool])])
AC_ARG_ENABLE(buggy_emsi, [ --disable-buggy-emsi disable buggy emsi support (default)],
[if test $enableval = yes; then
AC_DEFINE([BUGGY_EMSI], [1], [Disable buggy emsi])

@ -1,22 +0,0 @@
/* Do you want debug code to be compiled? */
#undef DEBUG
/* Do you want use DCD line control? */
#undef MODEM_WATCH_CARRIER
/* Do you want hangup to watch for modem DCD line? */
#undef MODEM_HANGUP_WATCH_CARRIER
/* Version string */
#undef RELEASE_VERSION
/* Disable passwords logging? */
#undef BFORCE_LOG_PASSWD
/* Path to the UUCP lock files directory */
#undef BFORCE_LOCK_DIR
/* Do you want use .csy locks? */
#undef BFORCE_USE_CSY

@ -62,6 +62,9 @@
/* Do you want to use syslog? */
#undef USE_SYSLOG
/* Netspool */
#undef NETSPOOL
/* Do you want use .csy locks? */
#undef BFORCE_USE_CSY

@ -1,4 +1,18 @@
/*
* binkleyforce -- unix FTN mailer project
*
* Copyright (c) 1998-2000 Alexander Belkin, 2:5020/1398.11
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* $Id$
*/
#ifndef _NETSPOOL_H_
#define _NETSPOOL_H_
#define NS_NOTINIT (0)
#define NS_UNCONF (1)
@ -6,15 +20,28 @@
#define NS_READY (3)
#define NS_RECEIVING (4)
#define NS_RECVFILE (5)
#define NS_CLOSED (6)
#define STRBUF (1024)
typedef struct {
int state;
char *error;
const char *error;
int socket;
int filename[STRBUF];
char filename[STRBUF];
unsigned long long length;
} s_netspool_state;
/* create socket and start session */
void netspool_start(s_netspool_state *state, const char *host, const char *port, const char *address, const char *password);
/* request for outbound */
void netspool_query(s_netspool_state *state, const char *what);
/* receive next file */
void netspool_receive(s_netspool_state *state);
/* read data */
int netspool_read(s_netspool_state *state, void *buf, int buflen);
/* acknowledge successful file transmission */
void netspool_acknowledge(s_netspool_state *state);
/* end session */
void netspool_end(s_netspool_state *state);
#endif

@ -27,6 +27,7 @@
#define ACTION_UNLINK 0x001 /* Unlink file if send successful */
#define ACTION_TRUNCATE 0x002 /* Truncate file if send successful */
#define ACTION_FORCEUNLINK 0x004 /* Unlink file in any case after ses.*/
#define ACTION_ACKNOWLEDGE 0x008 /* Report success to netspool server */
#define TYPE_UNKNOWN 0x000
#define TYPE_NETMAIL 0x001

@ -11,4 +11,4 @@ CC=$PREFIX-gcc
export PATH CC CPP
#./configure --prefix=/opt/bforce --host=mips-openwrt-linux --disable-syslog
#./configure --prefix=/opt/bforce --host=mips-openwrt-linux --disable-syslog --enable-netspool

Loading…
Cancel
Save