diff options
author | craiggunther <craiggunther@yahoo.com> | 2014-01-30 15:51:32 -0700 |
---|---|---|
committer | craiggunther <craiggunther@yahoo.com> | 2014-01-30 15:51:32 -0700 |
commit | a123960d37f705406cdebf51cfb31937484fa6cb (patch) | |
tree | e01ace7e5de07455b486cc4f4a3b01e7aa900626 | |
parent | 8be96735b7d374cff00901008736d6c11dcb88fe (diff) | |
download | Open-AVB-a123960d37f705406cdebf51cfb31937484fa6cb.tar.gz |
Allow simple_listener to attach to a stream after simple_talker has been
running for at least 1 second (i.e. TA New{SNE} has changed to Join{SJO}).
Also fix compiler warning in usage() function: add a version_str.
Also fix warning in join_vlan() about send_msg() by moving join_vlan().
-rw-r--r-- | examples/simple_listener/simple_listener.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/examples/simple_listener/simple_listener.c b/examples/simple_listener/simple_listener.c index 25abe042..0cc61acd 100644 --- a/examples/simple_listener/simple_listener.c +++ b/examples/simple_listener/simple_listener.c @@ -78,6 +78,10 @@ pcap_t* handle; u_char ETHER_TYPE[] = { 0x22, 0xf0 }; SNDFILE* snd_file; +#define VERSION_STR "1.1" +static const char *version_str = "simple_listener v" VERSION_STR "\n" + "Copyright (c) 2012, Intel Corporation\n"; + static void help() { fprintf(stderr, "\n" @@ -87,7 +91,7 @@ static void help() " -h show this message\n" " -i specify interface for AVB connection\n" " -f set the name of the output wav-file\n" - "\n" "%s" "\n"); + "\n" "%s" "\n", version_str); exit(1); } @@ -180,8 +184,9 @@ int msg_process(char *buf, int buflen) uint32_t id; fprintf(stderr, "Msg: %s\n", buf); int l = 0; - if ('S' == buf[l++] && 'N' == buf[l++] && 'E' == buf[l++] && 'T' == buf[++l]) + if (strncmp(buf, "SNE T:", 6) == 0 || strncmp(buf, "SJO T:", 6) == 0) { + l = 6; // skip "Sxx T:" while ('S' != buf[l++]); l++; for(int j = 0; j < 8 ; l+=2, j++) @@ -214,20 +219,6 @@ int recv_msg() } -int join_vlan() -{ - int rc; - char *msgbuf = malloc(1500); - if (NULL == msgbuf) - return -1; - memset(msgbuf, 0, 1500); - sprintf(msgbuf, "V++:I=0002"); - rc = send_msg(msgbuf, 1500); - - free(msgbuf); - return rc; -} - int await_talker() { while (0 == talker) @@ -249,6 +240,20 @@ int send_msg(char *data, int data_len) return 0; } +int join_vlan() +{ + int rc; + char *msgbuf = malloc(1500); + if (NULL == msgbuf) + return -1; + memset(msgbuf, 0, 1500); + sprintf(msgbuf, "V++:I=0002"); + rc = send_msg(msgbuf, 1500); + + free(msgbuf); + return rc; +} + int mrp_disconnect() { int rc; |