#include "trbrpc.h"
-static const char trbnetd_version[] = "$Revision: 1.13 $";
+static const char trbnetd_version[] = "$Revision: 1.14 $";
+static uint32_t server_rpc_prog_id = TRBNETRPCPROG;
static int daemon_lock = 0;
void usage(const char *progName)
{
- fprintf(stdout, "Usage: %s [-h] [-f]\n", progName);
+ fprintf(stdout, "Usage: %s [-h] [-f] [-i progId]\n", progName);
fprintf(stdout, "Options:\n");
fprintf(stdout, " -h give this help\n");
+ fprintf(stdout, " -i set an individual RPC-ProgId (0-255), default 0\n");
fprintf(stdout, " -f execute as foreground process\n");
fprintf(stdout, " -V version number\n");
fprintf(stdout, "\nSignals:\n");
int opt;
optind = 1;
- while ((opt = getopt(argc, argv, "+hfVd:")) != -1) {
+ while ((opt = getopt(argc, argv, "+hfi:Vd:")) != -1) {
switch (opt) {
case '?':
usage(basename(argv[0]));
case 'h':
usage(basename(argv[0]));
return 0;
+ case 'i':
+ server_rpc_prog_id = ((server_rpc_prog_id & 0xffff00ff) |
+ ((strtoul(optarg, NULL, 0) & 0xff) << 8));
+ break;
case 'f':
daemonMode = 0;
break;
case 'd':
- trb_debug = strtoul(optarg, NULL, 0);
+ trb_debug = strtoul(optarg, NULL, 0);
break;
case 'V':
printf("%s %s, using libtrbnet %s\n",
break;
}
}
-
+
/* Block Signal SIGPIPE */
sigemptyset(&blockSet);
sigaddset(&blockSet, SIGPIPE);
if (signal(SIGUSR1, blockDaemon) == SIG_ERR) abort();
if (signal(SIGUSR2, blockDaemon) == SIG_ERR) abort();
- pmap_unset(TRBNETRPCPROG, TRBNETRPCVERS);
+ pmap_unset(server_rpc_prog_id, TRBNETRPCVERS);
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
if (transp == NULL) {
exit(EXIT_FAILURE);
}
if (!svc_register
- (transp, TRBNETRPCPROG, TRBNETRPCVERS, trbnetrpcprog_1, IPPROTO_TCP)) {
+ (transp, server_rpc_prog_id, TRBNETRPCVERS, trbnetrpcprog_1, IPPROTO_TCP)) {
fprintf(stderr, "%s",
- "unable to register (TRBNETRPCPROG, TRBNETRPCVERS, tcp).");
+ "unable to register (server_rpc_prog_id, TRBNETRPCVERS, tcp).");
exit(EXIT_FAILURE);
}
#include <stdio.h>
#include <rpc/rpc.h> /* always needed */
#include <unistd.h>
+#include <strings.h>
#include "trbrpc.h" /* will be generated by rpcgen */
#include <trberror.h>
#include "trbnet.h"
-const char trbnet_version[] = "$Revision: 1.12 $ RPC";
+const char trbnet_version[] = "$Revision: 1.13 $ RPC";
unsigned int trb_debug = 0;
unsigned int trb_dma = 0;
static CLIENT *trb_client = NULL;
int trb_connect(const char *server)
{
+ uint32_t server_rpc_prog_id = TRBNETRPCPROG;
+
if (server == NULL) {
char *tmp;
tmp = getenv("DAQOPSERVER");
if (tmp != NULL) {
+ uint32_t id = 0;
+ char* separator = NULL;
+ if ((separator = rindex(tmp, ':')) != NULL) {
+ *separator = '\0';
+ id = strtoul(separator + 1, NULL, 0);
+ }
strncpy(trb_server, tmp, 128);
+ server_rpc_prog_id = ((server_rpc_prog_id & 0xffff00ff) | (id << 8));
} else {
sprintf(trb_server, "etraxp023");
}
} else {
strncpy(trb_server, server, 128);
}
- trb_client = clnt_create(trb_server, TRBNETRPCPROG, TRBNETRPCVERS, "tcp");
+ trb_client = clnt_create(trb_server, server_rpc_prog_id,
+ TRBNETRPCVERS, "tcp");
if (trb_client == NULL) {
/*
* Couldn't establish connection with server.