|
From: <ljs...@us...> - 2008-04-29 00:48:23
|
Revision: 568
http://cadcdev.svn.sourceforge.net/cadcdev/?rev=568&view=rev
Author: ljsebald
Date: 2008-04-28 17:48:20 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
A slight modification to net_default_input, as well as a more sane way to handle loopback sends in net_ipv4 (sending it directly back into net_ipv4_input).
Modified Paths:
--------------
kos/kernel/net/net_input.c
kos/kernel/net/net_ipv4.c
Modified: kos/kernel/net/net_input.c
===================================================================
--- kos/kernel/net/net_input.c 2008-04-26 20:58:15 UTC (rev 567)
+++ kos/kernel/net/net_input.c 2008-04-29 00:48:20 UTC (rev 568)
@@ -7,7 +7,6 @@
#include <stdio.h>
#include <kos/net.h>
-#include <arpa/inet.h>
#include "net_ipv4.h"
CVSID("$Id: net_input.c,v 1.2 2002/03/24 00:27:05 bardtx Exp $");
@@ -19,17 +18,19 @@
*/
static int net_default_input(netif_t *nif, const uint8 *data, int len) {
- uint16 *proto = (uint16 *)(data + 12);
+ uint16 proto = (uint16)((data[12] << 8) | (data[13]));
- switch(ntohs(*proto)) {
+ switch(proto) {
case 0x0800:
return net_ipv4_input(nif, data + sizeof(eth_hdr_t),
len - sizeof(eth_hdr_t));
+
case 0x0806:
return net_arp_input(nif, data, len);
+
default:
dbglog(DBG_KDEBUG, "net_input: unhandled ethernet "
- "protocol: %x\n", ntohs(*proto));
+ "protocol: %x\n", proto);
return 0;
}
}
Modified: kos/kernel/net/net_ipv4.c
===================================================================
--- kos/kernel/net/net_ipv4.c 2008-04-26 20:58:15 UTC (rev 567)
+++ kos/kernel/net/net_ipv4.c 2008-04-29 00:48:20 UTC (rev 568)
@@ -73,7 +73,7 @@
return 1;
}
-/* Send a packet on the specified network adaptor */
+/* Send a packet on the specified network adapter */
int net_ipv4_send_packet(netif_t *net, ip_hdr_t *hdr, const uint8 *data,
int size) {
uint8 dest_ip[4];
@@ -89,26 +89,12 @@
/* Is this the loopback address (127.0.0.1)? */
if(ntohl(hdr->dest) == 0x7F000001) {
- /* Fill in the ethernet header */
- ehdr = (eth_hdr_t *)pkt;
- memset(ehdr->dest, 0, 6);
- memset(ehdr->src, 0, 6);
-
- ehdr->dest[0] = 0xCF;
- ehdr->src[0] = 0xCF;
-
- ehdr->type[0] = 0x08;
- ehdr->type[1] = 0x00;
-
- /* Put the IP header / data into our ethernet packet */
- memcpy(pkt + sizeof(eth_hdr_t), hdr,
- 4 * (hdr->version_ihl & 0x0f));
- memcpy(pkt + sizeof(eth_hdr_t) + 4 * (hdr->version_ihl & 0x0f),
- data, size);
+ /* Put the IP header / data into our packet */
+ memcpy(pkt, hdr, 4 * (hdr->version_ihl & 0x0f));
+ memcpy(pkt + 4 * (hdr->version_ihl & 0x0f), data, size);
- /* Send it away */
- net_input(NULL, pkt, sizeof(eth_hdr_t) + sizeof(ip_hdr_t) +
- size);
+ /* Send it "away" */
+ net_ipv4_input(NULL, pkt, 4 * (hdr->version_ihl & 0x0f) + size);
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|