libartnet icon indicating copy to clipboard operation
libartnet copied to clipboard

packet rocognition

Open sl1200mk2 opened this issue 11 years ago • 9 comments

in artnet_net_recv() this check is make: if (cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr || ntohl(cliAddr.sin_addr.s_addr) == LOOPBACK_IP) { p->length = 0; return ARTNET_EOK; }

this prevent to use a node that is bound on the 0.0.0.0:6454 address:port... in your opinion what check can be done to avoid returning at this stage....

sl1200mk2 avatar Apr 21 '14 17:04 sl1200mk2

this one i sa stopper too... can't we check for p->data.ar.longname != n->state.long_name or something else? ++

sl1200mk2 avatar Apr 22 '14 22:04 sl1200mk2

Try removing the check.

nomis52 avatar Apr 23 '14 05:04 nomis52

if I remove the check I got my own node address (e.g the libartnet server)...

sl1200mk2 avatar Apr 23 '14 06:04 sl1200mk2

I'm not clear what you're asking for. Can you please clearly describe the problem and what you'd like to see.

nomis52 avatar Apr 23 '14 16:04 nomis52

I'm trying to make D::Light and Capture Polar working on the same computer.... I register an ArtNet node in DL as a server with artnet_new(), artnet_init(), and so... I set the long Name, etc... when I send an ArtPoll, I don't want to see the node I've created to be listed... this can be done by: if (((cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr) && !memcmp(p->data.ar.longname, n->state.long_name, ARTNET_LONG_NAME_LENGTH * sizeof(uint8_t))) || ntohl(cliAddr.sin_addr.s_addr) == LOOPBACK_IP) { p->length = 0; return ARTNET_EOK; }

but I would like to know for a more elegant way.... in case of DL and Capture Polar on the same computer, cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr

best regards, ++

sl1200mk2 avatar Apr 23 '14 16:04 sl1200mk2

Let me make sure I understand: You want to respond to messages send from the same machine, except you also don't want the local node to show up when you try to discover devices?

To do the former you'll need to introduce a new function to control this behavior since we don't want to break existing clients. Something like

artnet_allow_loopback(artnet_node, bool);

There is no good way to filter Polls / PoolReplies from the same node. Comparing the node name is a bit of a hack, esp. since it could be set from the hostname. At a minimum I'd compare the manufacturer ID and the name

nomis52 avatar Jun 13 '14 02:06 nomis52

Simon, thank you for taking time to answer me!

2014-06-13 4:42 GMT+02:00 Simon Newton [email protected]:

Let me make sure I understand: You want to respond to messages send from the same machine, except you also don't want the local node to show up when you try to discover devices?

that is exactly it! DL and the 3D visualizer runs on the same host, and when I send a poll, I don't want DL to be listed

To do the former you'll need to introduce a new function to control this behavior since we don't want to break existing clients. Something like

artnet_allow_loopback(artnet_node, bool);

There is no good way to filter Polls / PoolReplies from the same node. Comparing the node name is a bit of a hack, esp. since it could be set from the hostname. At a minimum I'd compare the manufacturer ID and the name

do you mean something like that?: if (((cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr) && !artnet_allow_loopback(artnet_node, bool))|| ntohl(cliAddr.sin_addr.s_addr) == LOOPBACK_IP) { p->length = 0; return ARTNET_EOK; }

++ Nico

— Reply to this email directly or view it on GitHub https://github.com/OpenLightingProject/libartnet/issues/4#issuecomment-45970561 .

sl1200mk2 avatar Jun 13 '14 07:06 sl1200mk2

Here are the steps:

i) add a new bool to the node_state_t struct to track if loopback is enabled / disabled. It should default to disabled. ii) add a artnet_allow_loopback function to toggle this state iii) In artnet_net_recv, if loopback is disabled, and (cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr || ntohl(cliAddr.sin_addr.s_addr) == LOOPBACK_IP ) the packet should be skipped iv) In handle_reply if the node name and the manufacturer match our name and the packet was send from this machine the poll reply is discarded.

nomis52 avatar Jun 13 '14 15:06 nomis52

thanx, will be on my todo list.

++

2014-06-13 17:29 GMT+02:00 Simon Newton [email protected]:

Here are the steps:

i) add a new bool to the node_state_t struct to track if loopback is enabled / disabled. It should default to disabled. ii) add a artnet_allow_loopback function to toggle this state iii) In artnet_net_recv, if loopback is disabled, and (cliAddr.sin_addr.s_addr == n->state.ip_addr.s_addr || ntohl(cliAddr.sin_addr.s_addr) == LOOPBACK_IP ) the packet should be skipped iv) In handle_reply if the node name and the manufacturer match our name and the packet was send from this machine the poll reply is discarded.

— Reply to this email directly or view it on GitHub https://github.com/OpenLightingProject/libartnet/issues/4#issuecomment-46025102 .

sl1200mk2 avatar Jun 14 '14 12:06 sl1200mk2