OpenLightingProject / libartnet

An Open Source implementation of the ArtNet protocol
https://www.openlighting.org/libartnet-main/
GNU Lesser General Public License v2.1
124 stars 56 forks source link

packet rocognition #4

Open sl1200mk2 opened 10 years ago

sl1200mk2 commented 10 years ago

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 commented 10 years ago

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

nomis52 commented 10 years ago

Try removing the check.

sl1200mk2 commented 10 years ago

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

nomis52 commented 10 years ago

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

sl1200mk2 commented 10 years ago

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, ++

nomis52 commented 10 years ago

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

sl1200mk2 commented 10 years ago

Simon, thank you for taking time to answer me!

2014-06-13 4:42 GMT+02:00 Simon Newton notifications@github.com:

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 .

nomis52 commented 10 years ago

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.

sl1200mk2 commented 10 years ago

thanx, will be on my todo list.

++

2014-06-13 17:29 GMT+02:00 Simon Newton notifications@github.com:

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 .