[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 2/5] tcpip: Unterstützung für Broadcasts



+ tcpip: Bei einem Broadcast sollte man nicht ARP versuchen, sondern
  einfach die Ethernet-Broadcastadresse benutzen

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/tcpip/ip.c  |    8 ++++++--
 src/modules/tcpip/udp.c |    4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/modules/tcpip/ip.c b/src/modules/tcpip/ip.c
index d3c9d14..705b8e7 100644
--- a/src/modules/tcpip/ip.c
+++ b/src/modules/tcpip/ip.c
@@ -132,8 +132,12 @@ static bool ip_send_packet_direct(struct device* device, uint32_t dest_ip,
     char packet[packet_size];
 
     // MAC-Adresse ausfindig machen, an die das Paket gesendet wird
-    if (!(mac = arp_resolve(device, dest_ip))) {
-        return false;
+    if (dest_ip == 0xffffffff) {
+        mac = 0xffffffffffffULL;
+    } else {
+        if (!(mac = arp_resolve(device, dest_ip))) {
+            return false;
+        }
     }
 
     // Paket zusammenkopieren in unseren Lokalen Puffer
diff --git a/src/modules/tcpip/udp.c b/src/modules/tcpip/udp.c
index 9a472d9..49853eb 100644
--- a/src/modules/tcpip/udp.c
+++ b/src/modules/tcpip/udp.c
@@ -256,7 +256,7 @@ void udp_receive(uint32_t source_ip, void* data, uint32_t data_size)
 
     p();
     for (i = 0; (s = list_get_element_at(udp_sockets, i)); i++) {
-        if (   s->remote_ip   == source_ip
+        if (  (s->remote_ip   == source_ip || s->remote_ip == 0xffffffff)
             && s->remote_port == big_endian_word(hdr->src_port)
             && s->local_port  == big_endian_word(hdr->dest_port))
         {
@@ -275,7 +275,7 @@ found:
     payload_size = pktlen - sizeof(struct udp_header);
 
     struct udp_pseudo_header phdr = {
-        .source_ip  = s->remote_ip,
+        .source_ip  = source_ip,
         .dest_ip    = s->local_ip,
         .proto      = big_endian_word(IP_PROTO_UDP),
         .length     = big_endian_word(data_size),
-- 
1.6.0.2