mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-05 15:09:10 +02:00
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
* Removed 'Q3SocketDevice' dependencies from 'RDMulticaster'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
be4cbc291a
commit
b9641e45fe
@ -21135,3 +21135,5 @@
|
|||||||
* Removed 'Q3SocketDevice' dependencies from 'RDCae'.
|
* Removed 'Q3SocketDevice' dependencies from 'RDCae'.
|
||||||
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
|
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Fixed a regression in 'RDCae' that broke the build.
|
* Fixed a regression in 'RDCae' that broke the build.
|
||||||
|
2021-02-15 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Removed 'Q3SocketDevice' dependencies from 'RDMulticaster'.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Multi-interface multicast transciever
|
// Multi-interface multicast transciever
|
||||||
//
|
//
|
||||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Library General Public License
|
// it under the terms of the GNU Library General Public License
|
||||||
@ -30,10 +30,8 @@
|
|||||||
RDMulticaster::RDMulticaster(QObject *parent)
|
RDMulticaster::RDMulticaster(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
multi_socket=new Q3SocketDevice(Q3SocketDevice::Datagram);
|
multi_socket=new QUdpSocket(this);
|
||||||
multi_notifier=new QSocketNotifier(multi_socket->socket(),
|
connect(multi_socket,SIGNAL(readyRead()),this,SLOT(readyReadData()));
|
||||||
QSocketNotifier::Read,this);
|
|
||||||
connect(multi_notifier,SIGNAL(activated(int)),this,SLOT(activatedData(int)));
|
|
||||||
|
|
||||||
GetInterfaces();
|
GetInterfaces();
|
||||||
}
|
}
|
||||||
@ -58,7 +56,7 @@ void RDMulticaster::subscribe(const QHostAddress &addr)
|
|||||||
{
|
{
|
||||||
struct ip_mreqn mreq;
|
struct ip_mreqn mreq;
|
||||||
|
|
||||||
for(unsigned i=0;i<multi_iface_addresses.size();i++) {
|
for(int i=0;i<multi_iface_addresses.size();i++) {
|
||||||
memset(&mreq,0,sizeof(mreq));
|
memset(&mreq,0,sizeof(mreq));
|
||||||
mreq.imr_multiaddr.s_addr=htonl(addr.toIPv4Address());
|
mreq.imr_multiaddr.s_addr=htonl(addr.toIPv4Address());
|
||||||
mreq.imr_address.s_addr=htonl(multi_iface_addresses[i].toIPv4Address());
|
mreq.imr_address.s_addr=htonl(multi_iface_addresses[i].toIPv4Address());
|
||||||
@ -78,7 +76,7 @@ void RDMulticaster::unsubscribe(const QHostAddress &addr)
|
|||||||
{
|
{
|
||||||
struct ip_mreqn mreq;
|
struct ip_mreqn mreq;
|
||||||
|
|
||||||
for(unsigned i=0;i<multi_iface_addresses.size();i++) {
|
for(int i=0;i<multi_iface_addresses.size();i++) {
|
||||||
memset(&mreq,0,sizeof(mreq));
|
memset(&mreq,0,sizeof(mreq));
|
||||||
mreq.imr_multiaddr.s_addr=htonl(addr.toIPv4Address());
|
mreq.imr_multiaddr.s_addr=htonl(addr.toIPv4Address());
|
||||||
mreq.imr_address.s_addr=htonl(multi_iface_addresses[i].toIPv4Address());
|
mreq.imr_address.s_addr=htonl(multi_iface_addresses[i].toIPv4Address());
|
||||||
@ -97,11 +95,11 @@ void RDMulticaster::unsubscribe(const QHostAddress &addr)
|
|||||||
void RDMulticaster::send(const QString &msg,const QHostAddress &m_addr,
|
void RDMulticaster::send(const QString &msg,const QHostAddress &m_addr,
|
||||||
uint16_t port)
|
uint16_t port)
|
||||||
{
|
{
|
||||||
multi_socket->writeBlock(msg.utf8(),msg.utf8().length(),m_addr,port);
|
multi_socket->writeDatagram(msg.utf8(),msg.utf8().length(),m_addr,port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RDMulticaster::activatedData(int sock)
|
void RDMulticaster::readyReadData()
|
||||||
{
|
{
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
socklen_t sa_len=sizeof(struct sockaddr_in);
|
socklen_t sa_len=sizeof(struct sockaddr_in);
|
||||||
@ -109,7 +107,8 @@ void RDMulticaster::activatedData(int sock)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
memset(&sa,0,sizeof(sa));
|
memset(&sa,0,sizeof(sa));
|
||||||
while((n=recvfrom(multi_socket->socket(),data,1500,MSG_DONTWAIT,(sockaddr *)&sa,&sa_len))>0) {
|
while((n=recvfrom(multi_socket->socketDescriptor(),data,1500,MSG_DONTWAIT,
|
||||||
|
(sockaddr *)&sa,&sa_len))>0) {
|
||||||
data[n]=0;
|
data[n]=0;
|
||||||
QString msg(data);
|
QString msg(data);
|
||||||
emit received(msg,QHostAddress(ntohl(sa.sin_addr.s_addr)));
|
emit received(msg,QHostAddress(ntohl(sa.sin_addr.s_addr)));
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Multi-interface multicast transciever
|
// Multi-interface multicast transciever
|
||||||
//
|
//
|
||||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Library General Public License
|
// it under the terms of the GNU Library General Public License
|
||||||
@ -23,12 +23,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <QUdpSocket>
|
||||||
|
|
||||||
#include <qhostaddress.h>
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <q3socketdevice.h>
|
|
||||||
#include <qsocketnotifier.h>
|
|
||||||
|
|
||||||
class RDMulticaster : public QObject
|
class RDMulticaster : public QObject
|
||||||
{
|
{
|
||||||
@ -47,13 +42,12 @@ class RDMulticaster : public QObject
|
|||||||
void send(const QString &msg,const QHostAddress &m_addr,uint16_t port);
|
void send(const QString &msg,const QHostAddress &m_addr,uint16_t port);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void activatedData(int sock);
|
void readyReadData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetInterfaces();
|
void GetInterfaces();
|
||||||
Q3SocketDevice *multi_socket;
|
QUdpSocket *multi_socket;
|
||||||
QSocketNotifier *multi_notifier;
|
QList<QHostAddress> multi_iface_addresses;
|
||||||
std::vector<QHostAddress> multi_iface_addresses;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user