diff --git a/cwDnsSd.cpp b/cwDnsSd.cpp index 44caa59..57da197 100644 --- a/cwDnsSd.cpp +++ b/cwDnsSd.cpp @@ -123,6 +123,9 @@ namespace cw void tcpSendCallback( void* arg, const void* buf, unsigned bufByteN ) { rc_t rc; + + printf("Send:%i\n",bufByteN); + dnssd_t* p = (dnssd_t*)arg; if((rc = srv::send(p->tcpH,buf,bufByteN)) != kOkRC ) cwLogError(rc,"TCP send failed."); @@ -239,7 +242,8 @@ namespace cw free(formatStr); - p->dnsSd->gen_question(); + //p->dnsSd->gen_question(); + p->dnsSd->gen_response(); return rc; } @@ -395,7 +399,7 @@ cw::rc_t cw::net::dnssd::start( handle_t h ) cw::rc_t cw::net::dnssd::test() { rc_t rc = kOkRC; - const char* netIFace = "wlp3s0"; + const char* netIFace = "ens9"; const char* serviceName = "MC Mix - 1"; const char* serviceType = "_EuConProxy._tcp"; const char* serviceDomain = "local"; @@ -427,9 +431,9 @@ cw::rc_t cw::net::dnssd::test() // // Override the host name and mac address to match the example Wireshark captures // - strcpy(hostname,"Euphonix-MC-0090D580F4DE"); - unsigned char tmp_mac[] = { 0x00, 0x90, 0xd5, 0x80, 0xf4, 0xde }; - memcpy(hostMac,tmp_mac,6); + //strcpy(hostname,"Euphonix-MC-0090D580F4DE"); + //unsigned char tmp_mac[] = { 0x00, 0x90, 0xd5, 0x80, 0xf4, 0xde }; + //memcpy(hostMac,tmp_mac,6); // create the DNS-SD server diff --git a/cwEuCon.cpp b/cwEuCon.cpp index 8f7376e..76daf96 100644 --- a/cwEuCon.cpp +++ b/cwEuCon.cpp @@ -348,14 +348,14 @@ namespace cw return rc; } - rc_t _send_response( socket::handle_t sockH, const char* packet ) + rc_t _send_response( socket::handle_t sockH, const char* packet, unsigned packetN ) { rc_t rc = kOkRC; // send the initial handshake - if((rc = socket::send( sockH, packet, strlen(packet) )) != kOkRC ) + if((rc = socket::send( sockH, packet, packetN )) != kOkRC ) { - rc = cwLogError(rc,"TCP '%s' request failed."); + rc = cwLogError(rc,"TCP '%s' send failed."); } return rc; @@ -363,40 +363,12 @@ namespace cw rc_t _sendHandshake_0( socket::handle_t sockH, const char* label ) { - /* - rc_t rc = kOkRC; - unsigned char buf[88]; - memset(buf,0,88); - buf[0] = 0x0a; - - // send the initial handshake - if((rc = socket::send( sockH, buf, 88 )) != kOkRC ) - { - rc = cwLogError(rc,"Initial TCP '%s' request failed.",label); - } - - return rc; - */ - return _send_response(sockH,RESPONSE_1); + return _send_response(sockH,RESPONSE_1,sizeof(RESPONSE_1)-1); } rc_t _sendHandshake_1( socket::handle_t sockH ) { - /* - rc_t rc = kOkRC; - unsigned char buf[4]; - memset(buf,0,4); - buf[0] = 0x0c; - - // send the initial handshake - if((rc = socket::send( sockH, buf, 4 )) != kOkRC ) - { - rc = cwLogError(rc,"TCP '%s' request failed."); - } - - return rc; - */ - return _send_response(sockH,RESPONSE_2); + return _send_response(sockH,RESPONSE_2,sizeof(RESPONSE_2)-1); } @@ -416,7 +388,7 @@ namespace cw // if this a 'MC Mix' DNS-SD SRV reply if( strncmp(name+1, label, name[0]) == 0 ) - { + { // get the address of the advertising 'MC Mix' char addrBuf[ INET_ADDRSTRLEN+1 ]; if(socket::addrToString( fromAddr, addrBuf, INET_ADDRSTRLEN ) == kOkRC ) @@ -465,7 +437,7 @@ namespace cw { if( dataByteCnt >= 4 ) { - printHex(data,dataByteCnt); + //printHex(data,dataByteCnt); unsigned hdr = *(const unsigned*)data; @@ -476,6 +448,7 @@ namespace cw { p->protoState = kWaitForHandshake_2_Id; _sendHandshake_1( socketHandle(p->tcpH) ); + printf("Rcvd Beat - sent 0xc\n"); } break; @@ -483,32 +456,43 @@ namespace cw if( hdr == 0x0d ) { p->protoState = kResponse_3_A_Id; + printf("Rcvd 0xd\n"); } break; - case kResponse_3_A_Id: - _send_response(socketHandle(p->tcpH),RESPONSE_3_A); - p->protoState = kResponse_3_B_Id; - break; - - case kResponse_3_B_Id: - _send_response(socketHandle(p->tcpH),RESPONSE_3_B); - p->protoState = kResponse_4_A_Id; - break; - - case kResponse_4_A_Id: - _send_response(socketHandle(p->tcpH),RESPONSE_4_A); - p->protoState = kResponse_4_B_Id; - break; - - case kResponse_4_B_Id: - _send_response(socketHandle(p->tcpH),RESPONSE_4_B); - p->protoState = kRunning_Id; - break; - } - + } } } + + switch(p->protoState) + { + case kResponse_3_A_Id: + _send_response(socketHandle(p->tcpH),RESPONSE_3_A,sizeof(RESPONSE_3_A)-1); + p->protoState = kResponse_3_B_Id; + break; + + case kResponse_3_B_Id: + _send_response(socketHandle(p->tcpH),RESPONSE_3_B,sizeof(RESPONSE_3_B)-1); + p->protoState = kResponse_4_A_Id; + break; + + case kResponse_4_A_Id: + _send_response(socketHandle(p->tcpH),RESPONSE_4_A,sizeof(RESPONSE_4_A)-1); + p->protoState = kResponse_4_B_Id; + break; + + case kResponse_4_B_Id: + _send_response(socketHandle(p->tcpH),RESPONSE_4_B,sizeof(RESPONSE_4_B)-1); + p->protoState = kRunning_Id; + break; + + case kRunning_Id: + printf("Rcv: %i : ",dataByteCnt ); + for(unsigned i=0; icbCnt+=1; @@ -516,8 +500,8 @@ namespace cw { time::spec_t t1; time::get(t1); - unsigned ms = time::elapsedMs( &p->t0, &t1 ); - printf("cb: %i %i\n",p->cbCnt,ms); + //unsigned ms = time::elapsedMs( &p->t0, &t1 ); + //printf("cb: %i %i\n",p->cbCnt,ms); } }