Commit 514cc892 authored by jcaceres's avatar jcaceres
Browse files

IPv6 WORKKING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

parent 85a63aa7
......@@ -97,8 +97,21 @@ StreamBD::cmd (MainDialog *eventThread)
args->secondsBetweenPlucks,
args->jack, lastTickTime,
args->jack_alsa_readable_offset );
NetworkInfoT netInfo = new NetworkInfo (*localhostName,
//**********IPv4*******************************************
//NetworkInfoT netInfo = new NetworkInfo (*localhostName,
// audioInfo->
// getBytesPerBuffer (),
// UDP_IN_PORT +
// args->networkPortOffset,
// UDP_OUT_PORT +
// args->networkPortOffset,
// args->redundancy,
//args->networkInputQueueLengthInPackets);
//**********************************************************
//##########IPv4###################################################
NetworkInfoT netInfo = new NetworkInfo (args->localHostIP,
audioInfo->
getBytesPerBuffer (),
UDP_IN_PORT +
......@@ -107,6 +120,13 @@ StreamBD::cmd (MainDialog *eventThread)
args->networkPortOffset,
args->redundancy,
args->networkInputQueueLengthInPackets);
//##################################################################
// AudioDeviceT audioDevice;
......@@ -471,23 +491,58 @@ StreamBD::ParseCommandLine (int argc, char *argv[])
secondsBetweenPlucks << " seconds." << endl;
}
// If we're in transmit or harpt mode, make sure we have
// a hostname to connect to.
if (args->runMode == TRANSMIT || args->runMode == HARPT)
{
if (argc > 0)
{ /* Copy remote hostname */
strncpy (args->remoteHostname, argv[0], 99);
cout << "remote hostname is " << args->
remoteHostname << endl;
}
else
{
cerr << "You must specify a remote hostname to run in transmit mode." << endl;
cerr << "Run streambd with no arguments for command line instructions." << endl;
return 0;
}
//**********IPv4*******************************************
/*
if (argc > 1)
{ // Copy remote hostname
strncpy (args->remoteHostname, argv[0], 99);
cout << "remote hostname is " << args->
remoteHostname << endl;
}
*/
//**********************************************************
//#############################################################
//*****IPv6*************
if (argc > 1)
{ /* Copy remote hostname */
strncpy (args->localHostIP, argv[0], 99);
cout << "local hostname is " << args->
localHostIP << endl;
strncpy (args->remoteHostname, argv[1], 99);
cout << "remote hostname is " << args->
remoteHostname << endl;
}
else if (argc > 0)
{ /* Copy remote hostname */
strncpy (args->localHostIP, argv[0], 99);
cout << "local hostname is " << args->
localHostIP << endl;
}
//#############################################################
else
{
cerr << "You must specify a remote hostname to run in transmit mode." << endl;
cerr << "Run streambd with no arguments for command line instructions." << endl;
return 0;
}
}
//#############################################################
//*****IPv6*************
else { // This is the SERVER MODE
if (argc > 0)
{ /* Copy remote hostname */
strncpy (args->localHostIP, argv[0], 99);
cout << "local hostname is " << args->
localHostIP << endl;
}
}
//#############################################################
return 1;
}
......@@ -567,8 +622,16 @@ StreamBD::EstablishConnection (runModeT runMode, char *hostname, UDPOutput * net
{
cout << "Requesting Connection...........";
QHostAddress *ha = new QHostAddress ();
//**********IPv4*******************************************
/*
QString *s = IPv4Addr (hostname); // dotted integer from name
ha->setAddress (*s);
*/
//**********************************************************
//#############################################################
ha->setAddress (hostname);//*****IPv6*************
cout << "IPv6 Remote Address CACA CACA CACACA CACACA: " << ha->toString().latin1() << endl;//*****IPv6*************
//#############################################################
netout->connect (*ha);
}
else
......
......@@ -113,6 +113,9 @@ typedef struct cmdLineArgs
int audioInputQueueLengthInAudioBuffers; /*! Number of buffers of size framesPerAudioBuffer with which the
* audio output is buffered. */
char remoteHostname[100]; /*! Holds the hostname to connect to in TRANSMIT and HARPT mode. */
//###############################################################################################################
char localHostIP[100]; /*! Holds the IP to connect to in TRANSMIT and HARPT mode. */ //**IPv6*******
//###############################################################################################################
int networkPortOffset; /*! Network port offset. */
int audioDeviceID; /*! Will use default audio device if not specified. */
int runFifo; /*! Run streambd with fifo priority (reduces delay). */
......
#!/bin/bash
#####################################
APP_NAME=jacktrip
APP_NAME=jacktrip6
APP_NAME_QUOTES=\\\"$APP_NAME\\\"
######################################
......
......@@ -11,7 +11,7 @@
#include "networkInfo.h"
#include <iostream.h>
NetworkInfo::NetworkInfo (QString localHostName, int dataBytesPerPacket,
NetworkInfo::NetworkInfo (char* localHostName, int dataBytesPerPacket,
int in_port, int out_port, int chunksPerPacket, int q):
_localHostName (localHostName),
in_port (in_port),
......@@ -84,3 +84,9 @@ NetworkInfo::localAddress ()
{
return (_localAddress);
}
QString
NetworkInfo::getLocalIP ()
{
return (_localHostName);
}
......@@ -74,7 +74,7 @@ typedef class NetworkInfo
* @param in_port - network input port.
* @param out_port - network output port.
*/
NetworkInfo (QString localHostName,
NetworkInfo (char* localHostName,
int dataBytesPerPacket, int in_port,
int out_port, int chunksPerPacket, int q);
......@@ -90,11 +90,13 @@ typedef class NetworkInfo
int getDataBytesPerPacket ();
QHostAddress localAddress ();
QString getLocalIP ();
unsigned short checksum (unsigned short *buffer, int size);
int pCopies ();
int getMaxSeq ();
}
*NetworkInfoT;
......
......@@ -16,8 +16,12 @@ InputPlugin ("UDP Input"), netInfo (netInfo), audInfo (audInfo)
char localhostbuf[100];
has_peer = false;
_rcvr = NULL;
sock = new Q3SocketDevice (Q3SocketDevice::Datagram); // for an unreliable UDP socket
int dummy; dummy = 1;
sock = new Q3SocketDevice (Q3SocketDevice::Datagram, Q3SocketDevice::IPv6, dummy); // for an unreliable UDP socket
sock->setAddressReusable(true);
//**********IPv4*******************************************
/*
if (gethostname (localhostbuf, 99))
{
perror ("gethostname");
......@@ -27,6 +31,14 @@ InputPlugin ("UDP Input"), netInfo (netInfo), audInfo (audInfo)
QHostAddress *ha = new QHostAddress ();
QString *s = IPv4Addr (localhostbuf); // dotted integer from name
ha->setAddress (*s);
*/
//**********************************************************
QHostAddress *ha = new QHostAddress ();
//#############################################################
ha->setAddress (netInfo->getLocalIP());//*****IPv6*************
//#############################################################
if (!(sock->bind (*ha, netInfo->getInPort ())))
{
perror ("bind\n");
......@@ -43,8 +55,16 @@ InputPlugin ("UDP Input"), netInfo (netInfo), audInfo (audInfo)
memset (packetData, 0, wholeSize);
numRedundantBuffers = netInfo->getChunksPerPacket() - 1;
maxPacketIndex = netInfo->getMaxSeq();
//**********IPv4*******************************************
/*
cout << endl << "UDPInput binding to " << localhostbuf
<< " port " << netInfo->getInPort () << endl;
*/
//**********************************************************
//#############################################################
cout << "IPv6 Local Address: " << ha->toString().latin1() << endl;//*****IPv6*************
//#############################################################
}
/** cout that the UDPInput thread has started */
......
......@@ -30,7 +30,7 @@ class UDPInput:public InputPlugin
void setPacketSize (int size);
public:
UDPInput (NetworkInfoT netInfo, AudioInfoT audInfo);
UDPInput (NetworkInfoT netInfo, AudioInfoT audInfo);
int rcvz1 (char *bufz1, int z);
int rcv (char *buf);
bool hasPeer ();
......
......@@ -14,8 +14,12 @@ audInfo (audInfo)
{
bpp = netInfo->getDataBytesPerPacket ();
char localhostbuf[100];
sock = new Q3SocketDevice (Q3SocketDevice::Datagram);
int dummy; dummy = 1;
sock = new Q3SocketDevice (Q3SocketDevice::Datagram, Q3SocketDevice::IPv6, dummy);
sock->setAddressReusable(true);
//**********IPv4*******************************************
/*
if (gethostname (localhostbuf, 99))
{
perror ("gethostname");
......@@ -24,6 +28,13 @@ audInfo (audInfo)
QHostAddress *ha = new QHostAddress ();
QString *s = IPv4Addr (localhostbuf); // dotted integer from name
ha->setAddress (*s);
*/
//**********************************************************
QHostAddress *ha = new QHostAddress ();
//#############################################################
ha->setAddress (netInfo->getLocalIP());//*****IPv6*************
//#############################################################
if (!(sock->bind (*ha, netInfo->getOutPort ())))
{
perror ("bind\n");
......@@ -48,9 +59,13 @@ audInfo (audInfo)
numBuffers = netInfo->getChunksPerPacket();
maxPacketIndex = netInfo->getMaxSeq();
//**********IPv4*******************************************
/*
cout << "UDPOuput binding to " << localhostbuf
<< " port " << netInfo->getOutPort () << endl;
*/
//**********************************************************
cout << "IPv6 Local Address: " << ha->toString().latin1() << endl;
}
void
......@@ -67,12 +82,11 @@ UDPOutput::connect (QHostAddress remote)
cerr << "Error! connect called with no valid socket" << endl;
exit ();
}
// sets peerAddress
// sets peerAddress
//cout << "REMOTE *************** " << remote.toString().latin1() << endl;
sock->connect (remote, netInfo->getInPort ());
//**************JPC COMENTED OUT*******************
//cout << "Connecting to " << remote.toString () << ":" << netInfo->
// getInPort () << endl;
//*************************************************
cout << "Connecting to " << remote.toString ().latin1() << " UDP-Port " << netInfo->
getInPort () << endl;
return 0;
}
......@@ -92,16 +106,21 @@ UDPOutput::send (char *buf)
memcpy (datapart, buf, bpp);
//######################################################
//########## Error is here #############################
int rv = sock->writeBlock (packetData, wholeSize,
sock->peerAddress (),
sock->peerPort ());
return rv;
//######################################################
//########## Error is here #############################
return rv;
}
void
UDPOutput::run ()
{
_running = true;
_running = true;
int res = 1;
char *buf = (char *) new char[bpp];
......@@ -128,10 +147,8 @@ UDPOutput::run ()
if (res < 0)
{
perror ("Send");
//**************JPC COMENTED OUT*******************
//cout << "error sending to " << sock->peerAddress ().
// toString () << endl;
//*************************************************
cout << "error sending to " << sock->peerAddress ().
toString ().latin1() << endl;
return;
}
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment