summaryrefslogtreecommitdiff
path: root/src/ivyecho.c
diff options
context:
space:
mode:
authorsc1999-02-18 17:33:32 +0000
committersc1999-02-18 17:33:32 +0000
commit2732f1ee8cf7590c53fd52abc9be0c4ee6a4a3c2 (patch)
tree024a4d9385680a6985fc7a57b99abeee9f645f7f /src/ivyecho.c
parent3dfd47dde8bb049a797f5dc653105c1cb57af617 (diff)
downloadivyd-2732f1ee8cf7590c53fd52abc9be0c4ee6a4a3c2.zip
ivyd-2732f1ee8cf7590c53fd52abc9be0c4ee6a4a3c2.tar.gz
ivyd-2732f1ee8cf7590c53fd52abc9be0c4ee6a4a3c2.tar.bz2
ivyd-2732f1ee8cf7590c53fd52abc9be0c4ee6a4a3c2.tar.xz
Port registration is now based on bus number.
This allows to have one server per bus.
Diffstat (limited to 'src/ivyecho.c')
-rw-r--r--src/ivyecho.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/ivyecho.c b/src/ivyecho.c
index 468a908..e2ed076 100644
--- a/src/ivyecho.c
+++ b/src/ivyecho.c
@@ -44,7 +44,7 @@ Usage (const char* progname) {
/* Get in touch with super-server and retrieve server's port number */
int
-GetPort (long addr)
+GetPort (long addr, int key)
{
struct servent *serv;
u_short serv_port;
@@ -79,8 +79,12 @@ GetPort (long addr)
sin.sin_port = serv_port;
sin.sin_addr.s_addr = addr;
- /* build request */
- msg.msg_uid = getuid ();
+ /* build request */
+#if 0
+ msg.msg_key = getuid ();
+#else
+ msg.msg_key = key;
+#endif
msg.msg_port = 0;
msg.msg_type = MSG_CLIENT;
@@ -107,7 +111,7 @@ failed:
}
int
-ServerOpen (const char *host)
+ServerOpen (const char *host, int key)
{
int sock;
static struct sockaddr_in addr;
@@ -137,7 +141,7 @@ ServerOpen (const char *host)
/* build address from host addr, asking port number to super-server */
memcpy (&addr.sin_addr, hp->h_addr, hp->h_length);
addr.sin_family = AF_INET;
- addr.sin_port = GetPort (addr.sin_addr.s_addr);
+ addr.sin_port = GetPort (addr.sin_addr.s_addr, key);
if (! addr.sin_port)
return 0;
@@ -255,9 +259,17 @@ bufferfull: /* now we have a full buffer */
}
-/*
- * Demande un numero de port au super-serveur de la machine addr
- */
+int
+ExtractPort (const char* bus)
+{
+ int res = 2010;
+ const char* p;
+ if (bus && (p = index (bus, ':'))) {
+ res = atoi (p+1);
+ }
+ return res;
+}
+
int
@@ -265,6 +277,7 @@ main (int argc, char** argv)
{
char busbuf [128];
const char* bus = 0;
+ int busport;
char serverhostbuf [128];
const char* serverhost = 0;
const struct option options [] = {
@@ -298,9 +311,10 @@ main (int argc, char** argv)
}
}
+ busport = ExtractPort (bus);
/* Se connecter au serveur. */
- servfd = ServerOpen (serverhost);
+ servfd = ServerOpen (serverhost, busport);
if (!servfd) {
fprintf (stderr, "No server.\n");
return 0;