Index: net.h =================================================================== RCS file: /cvs/ecos/ecos/packages/redboot/current/include/net/net.h,v retrieving revision 1.3 diff -U8 -r1.3 net.h --- net.h 8 Dec 2000 03:30:08 -0000 1.3 +++ net.h 8 Jul 2002 18:39:49 -0000 @@ -48,17 +48,19 @@ #include #include #include extern bool net_debug; extern unsigned long do_ms_tick(void); -#define MS_TICKS() do_ms_tick() +extern unsigned long get_ms_ticks(void); +#define MS_TICKS() get_ms_ticks() +#define MS_TICKS_DELAY() do_ms_tick() /* #define NET_SUPPORT_RARP 1 */ #define NET_SUPPORT_ICMP 1 #define NET_SUPPORT_UDP 1 #define NET_SUPPORT_TCP 1 #if (CYG_BYTEORDER == CYG_LSBFIRST) #ifndef __LITTLE_ENDIAN__ @@ -74,16 +76,17 @@ #define htonl(x) ntohl(x) #define htons(x) ntohs(x) /* * Minimum ethernet packet length. */ #define ETH_MIN_PKTLEN 60 #define ETH_MAX_PKTLEN 1514 +#define ETH_HDR_SIZE 14 typedef unsigned char enet_addr_t[6]; typedef unsigned char ip_addr_t[4]; typedef unsigned char octet; typedef unsigned short word; typedef unsigned int dword; @@ -160,17 +163,17 @@ #define RARP_REPLY 4 enet_addr_t sender_enet; ip_addr_t sender_ip; enet_addr_t target_enet; ip_addr_t target_ip; } arp_header_t; -#define ARP_PKT_SIZE (sizeof(arp_header_t) + sizeof(eth_header_t)) +#define ARP_PKT_SIZE (sizeof(arp_header_t) + ETH_HDR_SIZE) /* * Internet Protocol header. */ typedef struct { #ifdef __LITTLE_ENDIAN__ octet hdr_len:4, version:4; @@ -188,17 +191,17 @@ #define IP_PROTO_TCP 6 #define IP_PROTO_UDP 17 word checksum; ip_addr_t source; ip_addr_t destination; } ip_header_t; -#define IP_PKT_SIZE (60 + sizeof(eth_header_t)) +#define IP_PKT_SIZE (60 + ETH_HDR_SIZE) /* * A IP<->ethernet address mapping. */ typedef struct { ip_addr_t ip_addr; enet_addr_t enet_addr; @@ -255,19 +258,17 @@ word checksum; word ident; word seqnum; } icmp_header_t; typedef struct _pktbuf { struct _pktbuf *next; -#if 0 eth_header_t *eth_hdr; /* pointer to ethernet header */ -#endif union { ip_header_t *__iphdr; /* pointer to IP header */ arp_header_t *__arphdr; /* pointer to ARP header */ } u1; #define ip_hdr u1.__iphdr #define arp_hdr u1.__arphdr union { udp_header_t *__udphdr; /* pointer to UDP header */ @@ -330,17 +331,18 @@ char pktbuf[ETH_MAX_PKTLEN]; } tcp_socket_t; /* * Our address. */ extern enet_addr_t __local_enet_addr; extern ip_addr_t __local_ip_addr; - +extern ip_addr_t __local_ip_gate; +extern ip_addr_t __local_ip_mask; /* * Set a timer. Caller is responsible for providing the timer_t struct. */ extern void __timer_set(timer_t *t, unsigned long delay, tmr_handler_t handler, void *user_data); /* @@ -393,16 +395,21 @@ */ extern void __enet_poll(void); /* * Send an ethernet packet. */ extern void __enet_send(pktbuf_t *pkt, enet_addr_t *dest, int eth_type); +/* + * return true if addr is on local subnet + */ +extern int __ip_addr_local(ip_addr_t *addr); + /* * Handle incoming ARP packets. */ extern void __arp_handler(pktbuf_t *pkt); /* * Find the ethernet address of the machine with the given @@ -437,19 +444,19 @@ extern void __ip_handler(pktbuf_t *pkt, enet_addr_t *src_enet_addr); /* * Send an IP packet. * * The IP data field should contain pkt->pkt_bytes of data. * pkt->[udp|tcp|icmp]_hdr points to the IP data field. Any * IP options are assumed to be already in place in the IP - * options field. + * options field. Returns 0 for success. */ -extern void __ip_send(pktbuf_t *pkt, int protocol, ip_route_t *dest); +extern int __ip_send(pktbuf_t *pkt, int protocol, ip_route_t *dest); /* * Handle incoming ICMP packets. */ extern void __icmp_handler(pktbuf_t *pkt, ip_route_t *r); /* @@ -468,17 +475,17 @@ /* * Remove the handler for the given socket. */ extern void __udp_remove_listener(word port); /* * Send a UDP packet. */ -extern void __udp_send(char *buf, int len, ip_route_t *dest_ip, +extern int __udp_send(char *buf, int len, ip_route_t *dest_ip, word dest_port, word src_port); // Send a UDP packet extern int __udp_sendto(char *buf, int len, struct sockaddr_in *server, struct sockaddr_in *local); // Receive a UDP packet extern int __udp_recvfrom(char *buf, int len,