mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:25:42 +01:00
aseqnet: add ipv6 support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
c8e5762750
commit
5471a0b285
1 changed files with 11 additions and 5 deletions
|
@ -75,6 +75,7 @@ static int cur_connected;
|
||||||
static int seq_port;
|
static int seq_port;
|
||||||
|
|
||||||
static int server_mode;
|
static int server_mode;
|
||||||
|
static int ipv6 = 0;
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
static int info = 0;
|
static int info = 0;
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ static int info = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const struct option long_option[] = {
|
static const struct option long_option[] = {
|
||||||
|
{"ipv6", 0, NULL, '6'},
|
||||||
{"port", 1, NULL, 'p'},
|
{"port", 1, NULL, 'p'},
|
||||||
{"source", 1, NULL, 's'},
|
{"source", 1, NULL, 's'},
|
||||||
{"dest", 1, NULL, 'd'},
|
{"dest", 1, NULL, 'd'},
|
||||||
|
@ -106,8 +108,11 @@ int main(int argc, char **argv)
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "p:s:d:n:,vi", long_option, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "p:s:d:n:6hvi", long_option, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case '6':
|
||||||
|
ipv6 = 1;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = optarg;
|
port = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -169,6 +174,7 @@ static void usage(void)
|
||||||
printf(_(" server mode: aseqnet [-options]\n"));
|
printf(_(" server mode: aseqnet [-options]\n"));
|
||||||
printf(_(" client mode: aseqnet [-options] server_host\n"));
|
printf(_(" client mode: aseqnet [-options] server_host\n"));
|
||||||
printf(_("options:\n"));
|
printf(_("options:\n"));
|
||||||
|
printf(_(" -6,--ipv6 : use IPv6 TCP protocol\n"));
|
||||||
printf(_(" -p,--port # : specify TCP port (digit or service name)\n"));
|
printf(_(" -p,--port # : specify TCP port (digit or service name)\n"));
|
||||||
printf(_(" -s,--source addr : read from given addr (client:port)\n"));
|
printf(_(" -s,--source addr : read from given addr (client:port)\n"));
|
||||||
printf(_(" -d,--dest addr : write to given addr (client:port)\n"));
|
printf(_(" -d,--dest addr : write to given addr (client:port)\n"));
|
||||||
|
@ -348,7 +354,7 @@ static void init_server(const char *port)
|
||||||
int save_errno = 0;
|
int save_errno = 0;
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = ipv6 ? AF_INET6 : AF_INET;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
|
@ -357,7 +363,7 @@ static void init_server(const char *port)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){
|
if ((sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0){
|
||||||
perror("create socket");
|
perror("create socket");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -433,7 +439,7 @@ static void init_client(const char *server, const char *port)
|
||||||
int save_errno = 0;
|
int save_errno = 0;
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
|
@ -442,7 +448,7 @@ static void init_client(const char *server, const char *port)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){
|
if ((fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0){
|
||||||
perror("create socket");
|
perror("create socket");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue