Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 266 → Rev 267

/shark/trunk/drivers/net/udpip.c
20,11 → 20,11
 
/**
------------
CVS : $Id: udpip.c,v 1.2 2003-09-02 16:12:40 giacomo Exp $
CVS : $Id: udpip.c,v 1.3 2003-10-06 13:57:21 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2003-09-02 16:12:40 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-10-06 13:57:21 $
------------
**/
 
83,13 → 83,14
extern struct ip_addr myIpAddr;
struct ip_table ipTable[IP_MAX_ENTRIES];
extern ARP_TABLE arpTable[ARP_MAX_ENTRIES];
IP_ADDR IPbroadcastaddress;
 
int udpIsInstalled = FALSE;
struct netbuff udp_txbuff;
struct netbuff udp_rxbuff;
struct udp_table udpTable[UDP_MAX_HANDLES];
struct eth_addr broadcast;
 
 
IP_ADDR *ip_getAddr()
{
return &myIpAddr;
341,25 → 342,32
sprintf(msg,"serv type : %d\n",iphd->servType);
win_puts(&wip,msg);
#endif
/* Is the destination ethernet address in the ARP table? */
i = 0; done = 0;
while (i < ARP_MAX_ENTRIES && !done)
if (arpTable[i].valid == TRUE) {
if (ip_compAddr(dest,arpTable[i].ip)) {
done = TRUE;
} else i++;
} else i++;
if (done == FALSE) {
/* No: call ARP to get the ethernet address */
arp_send(pkt,dest,len + sizeof(IP_HEADER));
}
else {
/* Yes: directly send the packet */
eth_setHeader(pkt,arpTable[i].eth,ETH_IP_TYPE);
/* Is the destination IP address the broadcast address?*/
if (ip_compAddr(dest,IPbroadcastaddress)) {
/* Send the packet*/
eth_setHeader(pkt,broadcast,ETH_IP_TYPE);
eth_sendPkt(pkt,len + sizeof(IP_HEADER));
netbuff_release(&udp_txbuff, (void *)pkt);
arpTable[i].used++;
if (arpTable[i].used > ARP_MAX_USED) arpTable[i].used = ARP_MAX_USED;
} else {
/* Is the destination ethernet address in the ARP table? */
i = 0; done = 0;
while (i < ARP_MAX_ENTRIES && !done)
if (arpTable[i].valid == TRUE) {
if (ip_compAddr(dest,arpTable[i].ip)) {
done = TRUE;
} else i++;
} else i++;
if (done == FALSE) {
/* No: call ARP to get the ethernet address */
arp_send(pkt,dest,len + sizeof(IP_HEADER));
} else {
/* Yes: directly send the packet */
eth_setHeader(pkt,arpTable[i].eth,ETH_IP_TYPE);
eth_sendPkt(pkt,len + sizeof(IP_HEADER));
netbuff_release(&udp_txbuff, (void *)pkt);
arpTable[i].used++;
if (arpTable[i].used > ARP_MAX_USED) arpTable[i].used = ARP_MAX_USED;
}
}
}
 
387,19 → 395,21
// return(0);
//}
 
/* Initialize the IP layer: it also call the ARP initialization function */
void ip_init(void *localAddr)
/* Initialize the IP layer: it also call the ARP initialization function, pass a struct ip_params* */
void ip_init(void *p)
{
int i;
 
if (!ipIsInstalled) {
arp_init(localAddr);
arp_init(((struct ip_params*)p)->localAddr);
//exc_set(IP_INIT_ERROR,ip_error);
for (i=0; i < IP_MAX_ENTRIES; i++) ipTable[i].rfun = NULL;
 
eth_setProtocol(ETH_IP_TYPE, ip_server_recv);
ip_str2addr(((struct ip_params*)p)->broadcastAddr,&IPbroadcastaddress);
ipIsInstalled = TRUE;
} else cprintf("IP: already installed!!!\n");
eth_str2Addr("FF:FF:FF:FF:FF:FF",&broadcast);
} else cprintf("IP: already installed!!!\n");
}
 
/* Receive an UDP packet from a socket */
460,8 → 470,11
*/
if (bindlist != NULL) {
while (*(int*)bindlist != 0) {
j = arp_req(*bindlist);
arp_sendRequest(j);
/* Ignore broadcast IP address */
if (!ip_compAddr(*bindlist,IPbroadcastaddress)) {
j = arp_req(*bindlist);
arp_sendRequest(j);
}
bindlist ++;
}
}