Added simple Close handling to frontend server (no hooks for resource
reporting yet), and demonstration client.
+Added cs_addrstr() command to COMSTACK to retrieve peer hostname/address.
+
--- 1.0b3 1995/08/24
Fixed bug in the frontend-server. The numberOfRecordsReturned field was
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: client.c,v $
- * Revision 1.23 1995-10-18 16:12:30 quinn
+ * Revision 1.24 1995-10-30 12:41:13 quinn
+ * Added hostname lookup for server.
+ *
+ * Revision 1.23 1995/10/18 16:12:30 quinn
* Better diagnostics.
*
* Revision 1.22 1995/10/11 14:49:12 quinn
{
"finished",
"shutdown",
- "systemProblem",
- "costLimit",
+ "system problem",
+ "cost limit reached",
"resources",
- "securityViolation",
+ "security violation",
"protocolError",
- "lackOfActivity",
- "peerAbort",
+ "lack of activity",
+ "peer abort",
"unspecified"
};
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: tcpip.c,v $
- * Revision 1.6 1995-09-29 17:12:00 quinn
+ * Revision 1.7 1995-10-30 12:41:16 quinn
+ * Added hostname lookup for server.
+ *
+ * Revision 1.6 1995/09/29 17:12:00 quinn
* Smallish
*
* Revision 1.5 1995/09/29 17:01:48 quinn
int tcpip_bind(COMSTACK h, void *address, int mode);
int tcpip_listen(COMSTACK h, char *addrp, int *addrlen);
COMSTACK tcpip_accept(COMSTACK h);
+char *tcpip_addrstr(COMSTACK h);
int completeBER(unsigned char *buf, int len);
p->f_bind = tcpip_bind;
p->f_listen = tcpip_listen;
p->f_accept = tcpip_accept;
+ p->f_addrstr = tcpip_addrstr;
p->state = CS_UNBND;
p->event = CS_NONE;
free(h);
return 0;
}
+
+char *tcpip_addrstr(COMSTACK h)
+{
+ struct sockaddr_in addr;
+ static char buf[64];
+ char *r;
+ int len;
+ struct hostent *host;
+
+ len = sizeof(addr);
+ if (getpeername(h->iofile, (struct sockaddr*) &addr, &len) < 0)
+ {
+ h->cerrno = CSYSERR;
+ return 0;
+ }
+ if ((host = gethostbyaddr((char*)&addr.sin_addr, sizeof(addr.sin_addr),
+ AF_INET)))
+ r = (char*) host->h_name;
+ else
+ r = inet_ntoa(addr.sin_addr);
+ sprintf(buf, "tcp:%s", r);
+ return buf;
+}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: xmosi.c,v $
- * Revision 1.6 1995-09-29 17:12:00 quinn
+ * Revision 1.7 1995-10-30 12:41:17 quinn
+ * Added hostname lookup for server.
+ *
+ * Revision 1.6 1995/09/29 17:12:00 quinn
* Smallish
*
* Revision 1.5 1995/09/28 10:24:32 quinn
int mosi_bind(COMSTACK h, void *address, int mode);
int mosi_listen(COMSTACK h, char *addrp, int *addrlen);
COMSTACK mosi_accept(COMSTACK h);
+char *mosi_addrstr(COMSTACK h);
typedef struct mosi_state
{
r->f_bind = mosi_bind;
r->f_listen = mosi_listen;
r->f_accept = mosi_accept;
+ r->f_addrstr = mosi_addrstr;
if (!blocking)
flags |= O_NONBLOCK;
free(h);
return 0;
}
+
+char *mosi_addrstr(COMSTACK h)
+{
+ return "osi:[UNIMPLEMENTED";
+}
* OF THIS SOFTWARE.
*
* $Log: comstack.h,v $
- * Revision 1.11 1995-09-29 17:12:01 quinn
+ * Revision 1.12 1995-10-30 12:41:27 quinn
+ * Added hostname lookup for server.
+ *
+ * Revision 1.11 1995/09/29 17:12:01 quinn
* Smallish
*
* Revision 1.10 1995/09/29 17:01:48 quinn
int (*f_listen)(COMSTACK handle, char *addrp, int *addrlen);
COMSTACK (*f_accept)(COMSTACK handle);
int (*f_close)(COMSTACK handle);
+ char *(*f_addrstr)(COMSTACK handle);
};
#define cs_put(handle, buf, size) ((*(handle)->f_put)(handle, buf, size))
#define cs_getstate(handle) ((handle)->getstate)
#define cs_errno(handle) ((handle)->cerrno)
#define cs_getproto(handle) ((handle)->protocol)
+#define cs_addrstr(handle) ((*(handle)->f_addrstr)(handle))
const char *cs_strerror(COMSTACK h);
const char *cs_errmsg(int n);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: statserv.c,v $
- * Revision 1.28 1995-09-29 17:12:30 quinn
+ * Revision 1.29 1995-10-30 12:41:29 quinn
+ * Added hostname lookup for server.
+ *
+ * Revision 1.28 1995/09/29 17:12:30 quinn
* Smallish
*
* Revision 1.27 1995/09/27 15:03:02 quinn
"", /* diagnostic output to stderr */
"tcp:@:9999", /* default listener port */
PROTO_Z3950, /* default application protocol */
- 2*60, /* idle timeout (minutes) */
+ 60, /* idle timeout (minutes) */
1024*1024, /* maximum PDU size (approx.) to allow */
"default-config", /* configuration name to pass to backend */
"" /* set user id */
};
-#define DEFAULT_LISTENER "tcp:localhost:9999"
-
/*
* handle incoming connect requests.
* The dynamic mode is a bit tricky mostly because we want to avoid
{
COMSTACK new_line;
IOCHAN new_chan;
+ char *a;
if (!(new_line = cs_accept(line)))
{
}
iochan_setdata(new_chan, newas);
iochan_settimeout(new_chan, control_block.idle_timeout * 60);
- logf(LOG_LOG, "accepted connection");
+ a = cs_addrstr(new_line);
+ logf(LOG_LOG, "Accepted connection from %s", a ? a : "[Unknown]");
}
else
{