title: C++ DGRAM socket get the RECEIVER address
body: <p>In C++,<br>
      how can I get the <strong>receiver address</strong> of the UDP packet which I have received using recvfrom. I know that it should be the same host on which I am receiving the packet, but I need to extract it from the received packet, in order to verify something. How can I do this?</p>
  
  <p>I found that one way of doing this is:</p>
  
  <pre><code>int r = getsockopt(receiver_sock, SOL_IP, SO_ORIGINAL_DST, (struct sockaddr *) &amp;sender_addr, (socklen_t *)&amp;addr_len);`
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>error: ‘SO_ORIGINAL_DST’ was not declared in this scope
  </code></pre>
  
  <p>I am using the appropriate headers </p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netinet/in.h&gt;
  #include &lt;/usr/src/linux-headers-2.6.32-21/include/linux/netfilter_ipv4.h&gt;
  #include &lt;arpa/inet.h&gt;    
  #include &lt;linux/netfilter.h&gt;
  </code></pre>
  
  <p>Using netfilter_ipv4 gives other errors like INT_MIN not declared. However, I think the mistake is something more fundamental rather than inclusion of proper header.</p>
  
  <p>Please help.</p>