Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Print a banner a connecting client. The banner contains rum...
details: https://anonhg.NetBSD.org/src/rev/33d63a253f8c
branches: trunk
changeset: 759771:33d63a253f8c
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Dec 16 12:38:20 2010 +0000
description:
Print a banner a connecting client. The banner contains rump sp
protocol version, os name, os revision and machine.
diffstat:
lib/librumpclient/rumpclient.c | 18 +++++++++++++++++-
lib/librumpuser/rumpuser_sp.c | 23 ++++++++++++++++++-----
lib/librumpuser/sp_common.c | 4 +++-
sys/rump/include/rump/rumpuser.h | 7 ++++---
sys/rump/librump/rumpkern/rump.c | 6 +++---
5 files changed, 45 insertions(+), 13 deletions(-)
diffs (186 lines):
diff -r c19e520515d3 -r 33d63a253f8c lib/librumpclient/rumpclient.c
--- a/lib/librumpclient/rumpclient.c Thu Dec 16 12:08:16 2010 +0000
+++ b/lib/librumpclient/rumpclient.c Thu Dec 16 12:38:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpclient.c,v 1.8 2010/11/30 22:30:43 pooka Exp $ */
+/* $NetBSD: rumpclient.c,v 1.9 2010/12/16 12:38:21 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -207,9 +207,11 @@
int
rumpclient_init()
{
+ char banner[MAXBANNER];
struct sockaddr *sap;
char *p;
unsigned idx;
+ ssize_t n;
int error, s;
if ((p = getenv("RUMP_SERVER")) == NULL) {
@@ -244,5 +246,19 @@
pthread_mutex_init(&clispc.spc_mtx, NULL);
pthread_cond_init(&clispc.spc_cv, NULL);
+ if ((n = read(s, banner, sizeof(banner)-1)) < 0) {
+ fprintf(stderr, "rump_sp: failed to read banner\n");
+ return -1;
+ }
+
+ if (banner[n-1] != '\n') {
+ fprintf(stderr, "rump_sp: invalid banner\n");
+ errno = EINVAL;
+ return -1;
+ }
+ banner[n] = '\0';
+
+ /* parse the banner some day */
+
return 0;
}
diff -r c19e520515d3 -r 33d63a253f8c lib/librumpuser/rumpuser_sp.c
--- a/lib/librumpuser/rumpuser_sp.c Thu Dec 16 12:08:16 2010 +0000
+++ b/lib/librumpuser/rumpuser_sp.c Thu Dec 16 12:38:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_sp.c,v 1.25 2010/12/12 17:58:28 pooka Exp $ */
+/* $NetBSD: rumpuser_sp.c,v 1.26 2010/12/16 12:38:20 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.25 2010/12/12 17:58:28 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.26 2010/12/16 12:38:20 pooka Exp $");
#include <sys/types.h>
#include <sys/atomic.h>
@@ -81,6 +81,11 @@
static struct rumpuser_sp_ops spops;
+static char banner[MAXBANNER];
+
+#define PROTOMAJOR 0
+#define PROTOMINOR 0
+
/*
* Manual wrappers, since librump does not have access to the
* user namespace wrapped interfaces.
@@ -415,8 +420,6 @@
return 0;
}
- /* XXX: should do some sort of handshake too */
-
flags = fcntl(newfd, F_GETFL, 0);
if (fcntl(newfd, F_SETFL, flags | O_NONBLOCK) == -1) {
close(newfd);
@@ -428,6 +431,12 @@
return 0;
}
+ /* write out a banner for the client */
+ if (write(newfd, banner, strlen(banner)) != (ssize_t)strlen(banner)) {
+ close(newfd);
+ return 0;
+ }
+
/* find empty slot the simple way */
for (i = 0; i < MAXCLI; i++) {
if (pfdlist[i].fd == -1 && spclist[i].spc_dying == 0)
@@ -809,7 +818,8 @@
static unsigned cleanupidx;
static struct sockaddr *cleanupsa;
int
-rumpuser_sp_init(const struct rumpuser_sp_ops *spopsp, const char *url)
+rumpuser_sp_init(const char *url, const struct rumpuser_sp_ops *spopsp,
+ const char *ostype, const char *osrelease, const char *machine)
{
pthread_t pt;
struct spservarg *sarg;
@@ -826,6 +836,9 @@
if (error)
return error;
+ snprintf(banner, sizeof(banner), "RUMPSP-%d.%d-%s-%s/%s\n",
+ PROTOMAJOR, PROTOMINOR, ostype, osrelease, machine);
+
s = socket(parsetab[idx].domain, SOCK_STREAM, 0);
if (s == -1)
return errno;
diff -r c19e520515d3 -r 33d63a253f8c lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c Thu Dec 16 12:08:16 2010 +0000
+++ b/lib/librumpuser/sp_common.c Thu Dec 16 12:38:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sp_common.c,v 1.15 2010/12/12 17:58:28 pooka Exp $ */
+/* $NetBSD: sp_common.c,v 1.16 2010/12/16 12:38:20 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -99,6 +99,8 @@
#define rsp_sysnum u.sysnum
#define rsp_error u.error
+#define MAXBANNER 96
+
/*
* Data follows the header. We have two types of structured data.
*/
diff -r c19e520515d3 -r 33d63a253f8c sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Thu Dec 16 12:08:16 2010 +0000
+++ b/sys/rump/include/rump/rumpuser.h Thu Dec 16 12:38:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.58 2010/12/12 17:10:36 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.59 2010/12/16 12:38:20 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -36,7 +36,7 @@
#include <stdint.h>
#endif
-#define RUMPUSER_VERSION 7
+#define RUMPUSER_VERSION 8
int rumpuser_getversion(void);
int rumpuser_daemonize_begin(void);
@@ -220,7 +220,8 @@
pid_t (*spop_getpid)(void);
};
-int rumpuser_sp_init(const struct rumpuser_sp_ops *, const char *);
+int rumpuser_sp_init(const char *, const struct rumpuser_sp_ops *,
+ const char *, const char *, const char *);
int rumpuser_sp_copyin(void *, const void *, void *, size_t);
int rumpuser_sp_copyinstr(void *, const void *, void *, size_t *);
int rumpuser_sp_copyout(void *, const void *, void *, size_t);
diff -r c19e520515d3 -r 33d63a253f8c sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Thu Dec 16 12:08:16 2010 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Thu Dec 16 12:38:20 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.211 2010/12/13 14:03:59 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.212 2010/12/16 12:38:20 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.211 2010/12/13 14:03:59 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.212 2010/12/16 12:38:20 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -450,7 +450,7 @@
rump_init_server(const char *url)
{
- return rumpuser_sp_init(&spops, url);
+ return rumpuser_sp_init(url, &spops, ostype, osrelease, MACHINE);
}
void
Home |
Main Index |
Thread Index |
Old Index