Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.2:Test
xibod
ibod.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ibod.dif of Package xibod
Index: ibod.1 =================================================================== --- ibod.1.orig +++ ibod.1 @@ -2,7 +2,7 @@ .SH NAME ibod \- ISDN MPPP bandwidth on demand daemon .SH SYNOPSIS -.B ibod [file configfile] [pid pidfile] +.B ibod [file configfile] [pid pidfile] [listen ip-address] .SH DESCRIPTION .B Ibod @@ -33,7 +33,10 @@ interface. .B Ibod is also listening on TCP port 6051 for eventual connection from control panels -.Bxibod(1). +.B xibod(1). +.br +Default is to listen on all IP addresses (0.0.0.0), except an IP address +is explicitely specified via command line. .SH SIGNALS Upon receiving SIGHUP, the configuration file is re-read. Index: ibod.c =================================================================== --- ibod.c.orig +++ ibod.c @@ -1,8 +1,3 @@ -static char *rcsId = "$Id: ibod.c,v 2.1 2001/03/09 10:15:09 kkeil Exp $"; -static char *rcsSymbol = "$Symbol$"; - -#include <stdlib.h> -#include <string.h> #include <stdio.h> #include <signal.h> #include <sys/types.h> @@ -11,6 +6,7 @@ static char *rcsSymbol = "$Symbol$"; #include <sys/socket.h> #include <netinet/in.h> #include <syslog.h> +#include <sys/ioctl.h> #include <errno.h> #include <linux/isdn.h> #include <linux/isdnif.h> @@ -44,7 +40,7 @@ static int bring_down_allslave(Bundle_t static int debug=0; static char conffile[256]; -static char *pidfile = 0; +static char *pidfile = IBOD_PIDFILE; static int usageflags[ISDN_MAX_CHANNELS]; static char phone[ISDN_MAX_CHANNELS][32]; static Siobytes iobytes[ISDN_MAX_CHANNELS]; @@ -251,7 +247,7 @@ list_config(void) int main(int argc, char *argv[]) { - fd_set readfds, writefds, execptfds; + fd_set readfds, execptfds; int i; int s; /* Listening socket descriptor */ struct sockaddr_in server; /* Socket protocol descriptor */ @@ -261,6 +257,7 @@ int main(int argc, char *argv[]) Bundle_t *act; int rval; int tmpsock = -1; + char listen_to[16]; openlog("ibod", LOG_PID, LOG_DAEMON); @@ -268,15 +265,27 @@ int main(int argc, char *argv[]) if ((home = getenv("IBOD_HOME")) == NULL) home = IBOD_DEFAULT_DIR; - sprintf(conffile, "%s/ibod.cf", home); + memset(conffile, 0, sizeof(conffile)); + snprintf(conffile, sizeof(conffile), "%s/ibod.cf", home); + + memset(listen_to, 0, sizeof(listen_to)); + strncpy(listen_to, LISTEN_TO, sizeof(listen_to)-1); + listen_to[sizeof(listen_to)-1] = '\0'; for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "file") == 0 && i < argc-1) - strcpy(conffile, argv[++i]); + if (strcmp(argv[i], "file") == 0 && i < argc-1) { + strncpy(conffile, argv[++i], sizeof(conffile)-1); + conffile[sizeof(conffile)-1] = '\0'; + } if (strcmp(argv[i], "pid") == 0 && i < argc-1) pidfile = argv[++i]; if (strcmp(argv[i], "debug") == 0 && i < argc-1) debug = atoi(argv[++i]); + if (strcmp(argv[i], "listen") == 0 && i < argc-1) { + /* should be a valid IPv4 listen IP address */ + strncpy(listen_to, argv[++i], sizeof(listen_to)-1); + listen_to[sizeof(listen_to)-1] = '\0'; + } } syslog(LOG_NOTICE, "ibod start: Configuration=%s\n", conffile); @@ -296,7 +305,7 @@ int main(int argc, char *argv[]) switch((rval=daemon(0,0))) { case -1: - syslog(LOG_ERR, "daemon() call failed: %s\n", sys_errlist[errno]); + syslog(LOG_ERR, "daemon() call failed: %s\n", strerror(errno)); bye(1); case 0: setpgrp(); @@ -310,7 +319,7 @@ int main(int argc, char *argv[]) if (pidfile) { FILE *fd = fopen(pidfile, "w"); if (fd == 0) { - syslog(LOG_ERR, "open %s: %s\n", pidfile, sys_errlist[errno]); + syslog(LOG_ERR, "open %s: %s\n", pidfile, strerror(errno)); bye(1); } @@ -328,15 +337,20 @@ int main(int argc, char *argv[]) /* Create a socket for control panel communication */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) { - syslog(LOG_ERR, "creating socket: %s\n", sys_errlist[errno]); + syslog(LOG_ERR, "creating socket: %s\n", strerror(errno)); bye(1); } server.sin_family = AF_INET; - server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(IBOD_PORT); + server.sin_addr.s_addr = INADDR_ANY; + if(inet_pton(AF_INET, listen_to, &server.sin_addr) <= 0) { + syslog(LOG_ERR, "unable to convert listen address '%s': %s\n", + listen_to, strerror(errno)); + bye(1); + } if (bind(s, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0) { - syslog(LOG_ERR, "binding stream socket: %s\n", sys_errlist[errno]); + syslog(LOG_ERR, "binding stream socket: %s\n", strerror(errno)); bye(1); } @@ -375,16 +389,16 @@ int main(int argc, char *argv[]) } if ((rc = select(max_fd + 1, &readfds, NULL, &execptfds, &timeout)) < 0) { - syslog(LOG_ERR, "select: %s\n", sys_errlist[errno]); + syslog(LOG_ERR, "select: %s\n", strerror(errno)); continue; } if ((debug & DEBUG_SEL) & rc) syslog(LOG_DEBUG, "select: %d\n", rc); if (FD_ISSET(s, &readfds)) { - tmpsock = accept(s, (struct sockaddr *)0, (int *)0); + tmpsock = accept(s, (struct sockaddr *)0, (unsigned int *)0); if (tmpsock == -1) - syslog(LOG_ERR, "accept: %s\n", sys_errlist[errno]); + syslog(LOG_ERR, "accept: %s\n", strerror(errno)); } if (FD_ISSET(s, &execptfds)) { @@ -395,12 +409,11 @@ int main(int argc, char *argv[]) memset(buf, 0, sizeof(buf)); if ((rval = read(tmpsock, buf, 1024)) < 0) { syslog(LOG_ERR, "reading stream(%d) message: %s\n", - tmpsock, sys_errlist[errno]); + tmpsock, strerror(errno)); close(tmpsock); tmpsock = -1; } else { OpenCMD_t *oc = (OpenCMD_t*)buf; - int i; if (debug & DEBUG_CMD) syslog(LOG_DEBUG, "get tmpsock(%d) command(%d) rval(%d)\n", @@ -441,7 +454,7 @@ int main(int argc, char *argv[]) memset(buf, 0, sizeof(buf)); if ((rval = read(act->msgsock, buf, 1024)) < 0) { syslog(LOG_ERR, "reading stream(%d) message: %s\n", - act->msgsock, sys_errlist[errno]); + act->msgsock, strerror(errno)); errsocket = act->msgsock; } else { int cmd = *(int *)buf; @@ -500,7 +513,10 @@ int main(int argc, char *argv[]) memcpy(&buf[INBOUND_RATE_POS], &act->in_bytes_per_sec, POBJ_SIZE); memcpy(&buf[OUTBOUND_RATE_POS], &act->out_bytes_per_sec, POBJ_SIZE); - write(act->msgsock, buf, STATUS_FRAME_SIZE); + if ((rval = write(act->msgsock, buf, STATUS_FRAME_SIZE)) < 0) { + syslog(LOG_ERR, "writing msgsock(%d) message: %s\n", + act->msgsock, strerror(errno)); + } } act = act->next; } @@ -531,7 +547,7 @@ static void pipehndl(int sig) Bundle_t *b = bundle_list; syslog(LOG_ERR, "errsocket(%d) caught SIGPIPE: %s\n", errsocket, - sys_errlist[errno]); + strerror(errno)); while(b) { if ((b->msgsock != -1) && (b->msgsock == errsocket)) { @@ -560,7 +576,7 @@ static int phone_index(char *number, int static void get_if_state() { - static char buf[4096]; + static char buf[4096] = {0}; struct timeval tv_now; unsigned long in_bytes_now, out_bytes_now; int ms_delta; @@ -572,7 +588,7 @@ get_if_state() /* Open the info device */ if ((fd = open(ISDN_INFO_DEV, O_RDONLY | O_NDELAY)) < 0) { - syslog(LOG_ERR, "%s: %s\n", ISDN_INFO_DEV, sys_errlist[errno]); + syslog(LOG_ERR, "%s: %s\n", ISDN_INFO_DEV, strerror(errno)); bye(1); } @@ -653,14 +669,14 @@ get_if_state() /* Get byte in/out for all channels */ if (ioctl(fd, IIOCGETCPS, &iobytes)) { - syslog(LOG_ERR, "%s: %s\n", IIOCGETCPS, sys_errlist[errno]); + syslog(LOG_ERR, "ioctl IOCGETCPS(%x): %s\n", IIOCGETCPS, strerror(errno)); bye(1); } if (debug & DEBUG_ISDN) { p = buf; for (i=0; i<max_usable_channels;i++) - p += sprintf(p," %d/%d", iobytes[i].ibytes, iobytes[i].obytes); + p += sprintf(p," %ld/%ld", iobytes[i].ibytes, iobytes[i].obytes); syslog(LOG_DEBUG, "i/o bytes:%s\n", buf); } @@ -719,7 +735,7 @@ get_if_state() act->channels_now++; } if (debug & DEBUG_ISDN) - syslog(LOG_DEBUG, "bundle %s:%d channels up i/o: %u,%u\n", + syslog(LOG_DEBUG, "bundle %s:%d channels up i/o: %lu,%lu\n", act->cfg.dev, act->channels_now, in_bytes_now, out_bytes_now); if ((act->channels_last == -1) || (act->channels_now < act->channels_last)) { @@ -751,7 +767,7 @@ get_if_state() act->out_bytes_last = out_bytes_now; if (debug & DEBUG_RATE) - syslog(LOG_DEBUG, "%s rates: %d/%d\n", act->cfg.dev, + syslog(LOG_DEBUG, "%s rates: %ld/%ld\n", act->cfg.dev, act->in_bytes_per_sec, act->out_bytes_per_sec); /* Take up or down slave channel */ @@ -767,7 +783,7 @@ get_if_state() /* Start stay up timer */ gettimeofday(&act->tv_up, NULL); if (debug & DEBUG_UPDOWN) - syslog(LOG_DEBUG, "%s: up channel %d/%d time=%d sec\n", + syslog(LOG_DEBUG, "%s: up channel %d/%d time=%ld sec\n", act->cfg.dev, act->channels_now, act->cfg.maxchan, act->tv_up.tv_sec); @@ -784,7 +800,7 @@ get_if_state() /* Check that the min stay up timer has expired */ gettimeofday(&tv_now, NULL); if (debug & DEBUG_UPDOWN) - syslog(LOG_DEBUG, "%s: down channel %d/%d time=%d sec diff %d sec\n", + syslog(LOG_DEBUG, "%s: down channel %d/%d time=%ld sec diff %ld sec\n", act->cfg.dev, act->channels_now, act->cfg.maxchan, tv_now.tv_sec, tv_now.tv_sec - act->tv_up.tv_sec); if (tv_now.tv_sec - act->tv_up.tv_sec > act->cfg.stayup_time) { @@ -811,12 +827,12 @@ static int bring_up_slave(Bundle_t *b) { int fd, rc; if ((fd = open(ISDN_CTLR_DEV, O_RDWR)) < 0) { - syslog(LOG_ERR, "%s: %s\n", ISDN_CTLR_DEV, sys_errlist[errno]); + syslog(LOG_ERR, "%s: %s\n", ISDN_CTLR_DEV, strerror(errno)); return -1; } if ((rc = ioctl(fd, IIOCNETALN, b->cfg.dev)) < 0) { - syslog(LOG_ERR, "%s: %s\n", b->cfg.dev, sys_errlist[errno]); + syslog(LOG_ERR, "%s: %s\n", b->cfg.dev, strerror(errno)); return -1; } @@ -825,7 +841,7 @@ static int bring_up_slave(Bundle_t *b) if (rc) syslog(LOG_NOTICE, "unable to attach additional link: %d\n", rc); else { - syslog(LOG_NOTICE, "added new link for %s (in cps=%d, out cps=%d)\n", + syslog(LOG_NOTICE, "added new link for %s (in cps=%ld, out cps=%ld)\n", b->cfg.dev, b->in_bytes_per_sec, b->out_bytes_per_sec); } @@ -838,12 +854,12 @@ static int bring_down_slave(Bundle_t *b) int fd, rc; if ((fd = open(ISDN_CTLR_DEV, O_RDWR)) < 0) { - syslog(LOG_ERR, "%s: %s\n", ISDN_CTLR_DEV, sys_errlist[errno]); + syslog(LOG_ERR, "%s: %s\n", ISDN_CTLR_DEV, strerror(errno)); return -1; } if ((rc = ioctl(fd, IIOCNETDLN, b->cfg.dev)) < 0) { - syslog(LOG_ERR, "%s: %s\n", b->cfg.dev, sys_errlist[errno]); + syslog(LOG_ERR, "%s: %s\n", b->cfg.dev, strerror(errno)); return -1; } @@ -852,7 +868,7 @@ static int bring_down_slave(Bundle_t *b) if (rc) syslog(LOG_ERR, "unable to remove additional link: %d\n", rc); else { - syslog(LOG_NOTICE, "removed link(%d) for %s(in cps=%d, out cps=%d)\n", + syslog(LOG_NOTICE, "removed link(%d) for %s(in cps=%ld, out cps=%ld)\n", b->channels_last, b->cfg.dev, b->in_bytes_per_sec, b->out_bytes_per_sec); } Index: ibod.h =================================================================== --- ibod.h.orig +++ ibod.h @@ -3,6 +3,13 @@ */ #include <sys/time.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <ctype.h> +#include <string.h> #define INTERVAL 500 #define DEVICE "ippp0" @@ -18,6 +25,7 @@ #define ISDN_INFO_DEV "/dev/isdninfo" #define ISDN_CTLR_DEV "/dev/isdnctrl" #define IBOD_PORT 6051 +#define IBOD_PIDFILE "/var/run/ibod.pid" /* Protocol specification */ #define MAX_MSG_LEN 1024 @@ -35,6 +43,9 @@ #define CMD_UP2 4 #define CMD_DOWN2 5 +/* defaults to any for compatibility */ +#define LISTEN_TO "0.0.0.0" + typedef struct _Conf Conf_t; struct _Conf {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor