diff options
Diffstat (limited to 'usr.bin/aucat/aucat.c')
-rw-r--r-- | usr.bin/aucat/aucat.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 2f59d1eac6d..cc4121b04cc 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.112 2011/04/27 21:20:36 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.113 2011/04/28 06:19:57 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -258,6 +258,16 @@ struct cfdev { SLIST_HEAD(cfdevlist, cfdev); +/* + * local network addresse to listen on + */ +struct cfnet { + SLIST_ENTRY(cfnet) entry; + char *addr; +}; + +SLIST_HEAD(cfnetlist, cfnet); + void cfdev_add(struct cfdevlist *list, struct cfdev *templ, char *path) { @@ -318,6 +328,20 @@ cfmid_add(struct cfmidlist *list, char *path) } void +cfnet_add(struct cfnetlist *list, char *addr) +{ + struct cfnet *cn; + + cn = malloc(sizeof(struct cfnet)); + if (cn == NULL) { + perror("malloc"); + abort(); + } + cn->addr = addr; + SLIST_INSERT_HEAD(list, cn, entry); +} + +void setsig(void) { struct sigaction sa; @@ -414,11 +438,11 @@ aucat_usage(void) { (void)fputs("usage: " PROG_AUCAT " [-dlnu] [-a flag] [-b nframes] " "[-C min:max] [-c min:max] [-e enc]\n\t" - "[-f device] [-h fmt] [-i file] [-j flag] [-m mode]" - "[-o file] [-q device]\n\t" - "[-r rate] [-s name] [-t mode] [-U unit] " - "[-v volume] [-x policy]\n\t" - "[-z nframes]\n", + "[-f device] [-h fmt] [-i file] [-j flag] [-L addr] [-m mode] " + "[-o file]\n\t" + "[-q device] [-r rate] [-s name] [-t mode] [-U unit] " + "[-v volume]\n\t" + "[-x policy] [-z nframes]\n", stderr); } @@ -426,9 +450,11 @@ int aucat_main(int argc, char **argv) { struct cfdevlist cfdevs; + struct cfnetlist cfnets; struct cfmid *cm; struct cfstr *cs; struct cfdev *cd; + struct cfnet *cn; int c, u_flag, d_flag, l_flag, n_flag, unit; char base[PATH_MAX], path[PATH_MAX]; unsigned mode, rate; @@ -447,6 +473,7 @@ aucat_main(int argc, char **argv) l_flag = 0; n_flag = 0; SLIST_INIT(&cfdevs); + SLIST_INIT(&cfnets); nfile = nsock = 0; /* @@ -485,7 +512,7 @@ aucat_main(int argc, char **argv) cd->round = 0; cd->hold = 1; - while ((c = getopt(argc, argv, "a:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:t:j:z:")) != -1) { + while ((c = getopt(argc, argv, "a:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:L:t:j:z:")) != -1) { switch (c) { case 'd': #ifdef DEBUG @@ -505,6 +532,9 @@ aucat_main(int argc, char **argv) if (str) errx(1, "%s: unit number is %s", optarg, str); break; + case 'L': + cfnet_add(&cfnets, optarg); + break; case 'm': cs->mode = opt_mode(); cd->mode = cs->mode; @@ -766,6 +796,11 @@ aucat_main(int argc, char **argv) snprintf(path, sizeof(path), "%s/%s%u", base, AUCAT_PATH, unit); listen_new_un(path); + while (!SLIST_EMPTY(&cfnets)) { + cn = SLIST_FIRST(&cfnets); + SLIST_REMOVE_HEAD(&cfnets, entry); + listen_new_tcp(cn->addr, AUCAT_PORT + unit); + } } if (geteuid() == 0) privdrop(); @@ -825,7 +860,7 @@ void midicat_usage(void) { (void)fputs("usage: " PROG_MIDICAT " [-dl] " - "[-i file] [-o file] [-q port] [-s name] [-U unit]\n", + "[-i file] [-L addr] [-o file] [-q port] [-s name] [-U unit]\n", stderr); } @@ -833,9 +868,11 @@ int midicat_main(int argc, char **argv) { struct cfdevlist cfdevs; + struct cfnetlist cfnets; struct cfmid *cm; struct cfstr *cs; struct cfdev *cd; + struct cfnet *cn; int c, d_flag, l_flag, unit, fd; char base[PATH_MAX], path[PATH_MAX]; struct file *stdx; @@ -852,6 +889,7 @@ midicat_main(int argc, char **argv) d_flag = 0; l_flag = 0; SLIST_INIT(&cfdevs); + SLIST_INIT(&cfnets); nsock = 0; /* @@ -910,6 +948,9 @@ midicat_main(int argc, char **argv) if (str) errx(1, "%s: unit number is %s", optarg, str); break; + case 'L': + cfnet_add(&cfnets, optarg); + break; default: midicat_usage(); exit(1); @@ -1033,6 +1074,11 @@ midicat_main(int argc, char **argv) snprintf(path, sizeof(path), "%s/%s%u", base, MIDICAT_PATH, unit); listen_new_un(path); + while (!SLIST_EMPTY(&cfnets)) { + cn = SLIST_FIRST(&cfnets); + SLIST_REMOVE_HEAD(&cfnets, entry); + listen_new_tcp(cn->addr, MIDICAT_PORT + unit); + } } if (geteuid() == 0) privdrop(); |