Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved my problem a few months ago. Here's the solution I used.</p> <p>The standard packet-sending API (sock_create, connect, ...) cannot be used in a few contexts (interruptions). Using it in the wrong place leads to a KP.</p> <p>The netpoll API is more "low-level" and works in every context. However, there are several conditions :</p> <ul> <li>Ethernet devices</li> <li>IP network</li> <li>UDP only (no TCP)</li> <li>Different computers for sending and receiving packets (You can't send to yourself.)</li> </ul> <p>Make sure to respect them, because you won't get any error message if there's a problem. It will just silently fail :) Here's a bit of code.</p> <p>Declaration</p> <pre><code>#include &lt;linux/netpoll.h&gt; #define MESSAGE_SIZE 1024 #define INADDR_LOCAL ((unsigned long int)0xc0a80a54) //192.168.10.84 #define INADDR_SEND ((unsigned long int)0xc0a80a55) //192.168.10.85 static struct netpoll* np = NULL; static struct netpoll np_t; </code></pre> <p>Initialization</p> <pre><code>np_t.name = "LRNG"; strlcpy(np_t.dev_name, "eth0", IFNAMSIZ); np_t.local_ip = htonl(INADDR_LOCAL); np_t.remote_ip = htonl(INADDR_SEND); np_t.local_port = 6665; np_t.remote_port = 6666; memset(np_t.remote_mac, 0xff, ETH_ALEN); netpoll_print_options(&amp;np_t); netpoll_setup(&amp;np_t); np = &amp;np_t; </code></pre> <p>Use</p> <pre><code>char message[MESSAGE_SIZE]; sprintf(message,"%d\n",42); int len = strlen(message); netpoll_send_udp(np,message,len); </code></pre> <p>Hope it can help someone.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload