Because there were some requests on github for things that would otherwise use the functionality, or direct appeals for the functionality itself, I finally bit the bullet and added a simple packet intercept callback to ENetHost, usage looks sorta like this:<div>
<br></div><div><br></div><div>int intercept_callback(ENetHost *host, ENetEvent *event)</div><div>{</div><div>   // the first two bytes of a valid ENet protocol packet will never be 0xFFFF, so you should ideally use this to distinguish user data packets from ENet protocol packets</div>
<div>   if(host->receivedDataLength >= 2 && *(unsigned short *)host->receivedData == 0xFFFF)</div><div>   {</div><div>      // host->receivedAddress contains the address the UDP packet came from</div><div>
      // do magical stuff with packet here...</div><div>      // if event is non-NULL, you can also set event->type with your own non-zero event number that ENet will pass out of enet_host_service(), but this is not required, just optional</div>
<div>      // if event->type is untouched, ENet will still skip the packet so long as you return 1... </div><div>      return 1; // tell ENet to skip the packet</div><div>   }</div><div>   return 0; // tell ENet to continue processing the packet</div>
<div>   // returning -1 will propagate the -1 return value out of enet_host_service...</div><div>}</div><div><br></div><div>....</div><div>host -> intercept = intercept_callback;</div><div>....</div><div>enet_host_service(host, event, timeout); // intercept gets called from in here when ENet receives a raw udp packet</div>
<div>// if you propagated a custom event type from within the intercept callback, it will get returned out here too with enet_host_service returning 1 like for any other event</div><div><br></div><div>This system can be used to implement all manner of fun things, from simulating packet loss to multiplexing your own data like pings or whatever over the ENet socket.</div>
<div>This is currently in the github repo, going to let it stew a bit before I release anything in case people have suggestions.</div><div><br></div>