handle ArtIpProg packets
This commit is contained in:
parent
47ac0220b4
commit
b6300cf80b
|
@ -34,6 +34,34 @@ Node::Node()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Node::rxArtIpProg
|
||||||
|
* @param packet
|
||||||
|
*/
|
||||||
|
void Node::rxArtIpProg(std::shared_ptr<ArtIpProg> packet)
|
||||||
|
{
|
||||||
|
auto data_opt = packet->data<ipprog_data>();
|
||||||
|
if (!data_opt.has_value())
|
||||||
|
return;
|
||||||
|
auto data = data_opt.value();
|
||||||
|
|
||||||
|
if (data->command.enable_programming)
|
||||||
|
{
|
||||||
|
if (data->command.enable_dhcp)
|
||||||
|
setDhcpEnable(true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setDhcpEnable(false);
|
||||||
|
if (data->command.program_ip)
|
||||||
|
setDeviceIP(data->ip_address);
|
||||||
|
if (data->command.program_netmask)
|
||||||
|
setDeviceSubnetMask(data->subnet_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
txArtIpProgReply(packet->originAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Node::rxArtAddress
|
* @brief Node::rxArtAddress
|
||||||
* @param packet
|
* @param packet
|
||||||
|
@ -56,4 +84,63 @@ void Node::rxArtAddress(std::shared_ptr<ArtAddress> packet)
|
||||||
txArtPollReply();
|
txArtPollReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Node::txArtIpProgReply
|
||||||
|
* @param dest
|
||||||
|
* @param reply
|
||||||
|
*/
|
||||||
|
void Node::txArtIpProgReply(const uint32_t dest, std::shared_ptr<ipprogreply_data> reply)
|
||||||
|
{
|
||||||
|
if (!reply)
|
||||||
|
reply = std::make_shared<ipprogreply_data>();
|
||||||
|
|
||||||
|
reply->ip_address = deviceIp().address.ipv4.value;
|
||||||
|
reply->subnet_mask = deviceSubnetMask();
|
||||||
|
reply->status.dhcp_enabled = deviceHasDHCP();
|
||||||
|
|
||||||
|
auto packet = std::make_shared<ArtIpProgReply>(reply);
|
||||||
|
auto controller = ipAddress();
|
||||||
|
controller.address.ipv4.value = dest;
|
||||||
|
send(packet, controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Node::setDhcpEnable
|
||||||
|
* @param state
|
||||||
|
*
|
||||||
|
* The default implimentation is to ignore the request.
|
||||||
|
* \note Platform aware nodes may reimpliment to accept the DHCP state.
|
||||||
|
*/
|
||||||
|
void Node::setDhcpEnable(const bool state)
|
||||||
|
{
|
||||||
|
(void)state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Node::setDeviceIP
|
||||||
|
* @param value
|
||||||
|
*
|
||||||
|
* The default implimentation is to ignore the request.
|
||||||
|
* \note Platform aware nodes may reimpliment to accept the IP address change.
|
||||||
|
*/
|
||||||
|
void Node::setDeviceIP(const uint32_t value)
|
||||||
|
{
|
||||||
|
(void)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Node::setDeviceSubnetMask
|
||||||
|
* @param value
|
||||||
|
*
|
||||||
|
* The default implimentation is to ignore the request.
|
||||||
|
* \note Platform aware nodes may reimpliment to accept the Subnet Mask change.
|
||||||
|
*/
|
||||||
|
void Node::setDeviceSubnetMask(const uint32_t value)
|
||||||
|
{
|
||||||
|
(void)value;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ARTNET
|
} // namespace ARTNET
|
||||||
|
|
|
@ -36,13 +36,21 @@ class Node
|
||||||
: public Device
|
: public Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Node();
|
explicit Node();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void rxArtAddress(std::shared_ptr<ArtAddress>) override;
|
virtual void rxArtIpProg(std::shared_ptr<ArtIpProg>) override;
|
||||||
|
virtual void rxArtAddress(std::shared_ptr<ArtAddress>) override;
|
||||||
|
|
||||||
|
virtual void txArtIpProgReply(const uint32_t dest, std::shared_ptr<ipprogreply_data> = nullptr);
|
||||||
|
|
||||||
|
// OSI layer 3
|
||||||
|
virtual void setDhcpEnable(const bool);
|
||||||
|
virtual void setDeviceIP(const uint32_t);
|
||||||
|
virtual void setDeviceSubnetMask(const uint32_t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Port*> _ports;
|
std::vector<Port*> _ports;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ARTNET
|
} // namespace ARTNET
|
||||||
|
|
Loading…
Reference in New Issue