--- trunk/src/include/net.h 2007/10/08 16:19:23 20 +++ trunk/src/include/net.h 2007/10/08 16:20:58 32 @@ -2,7 +2,7 @@ #define NET_H /* - * Copyright (C) 2004-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2004-2006 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * - * $Id: net.h,v 1.13 2005/11/24 12:32:11 debug Exp $ + * $Id: net.h,v 1.16 2006/09/05 06:13:27 debug Exp $ * * Emulated network support. (See net.c for more info.) */ @@ -42,6 +42,23 @@ struct remote_net; +/* Default emulated "simple" IPv4 network, if nothing else is specified: */ +#define NET_DEFAULT_IPV4_MASK "10.0.0.0" +#define NET_DEFAULT_IPV4_LEN 8 + + +/*****************************************************************************/ + +/* + * NOTE: These are already defined in on e.g. FreeBSD, + * but they are missing in some systems (at least in Linux). + */ +#define ETHERTYPE_SPRITE 0x0500 +#define ETHERTYPE_IP 0x0800 +#define ETHERTYPE_ARP 0x0806 +#define ETHERTYPE_REVARP 0x8035 +#define ETHERTYPE_IPV6 0x86DD + /*****************************************************************************/ /* NOTE: udp_connection and tcp_connection are actually for @@ -136,8 +153,28 @@ struct remote_net *remote_nets; }; -/* net.c: */ +/* net_misc.c: */ +void net_debugaddr(void *addr, int type); void net_generate_unique_mac(struct machine *, unsigned char *macbuf); +void send_udp(struct in_addr *addrp, int portnr, unsigned char *packet, + size_t len); + +/* net_ip.c: */ +void net_ip_checksum(unsigned char *ip_header, int chksumoffset, int len); +void net_ip_tcp_checksum(unsigned char *tcp_header, int chksumoffset, + int tcp_len, unsigned char *srcaddr, unsigned char *dstaddr, + int udpflag); +void net_ip_tcp_connectionreply(struct net *net, void *extra, + int con_id, int connecting, unsigned char *data, int datalen, int rst); +void net_ip_broadcast(struct net *net, void *extra, + unsigned char *packet, int len); +void net_ip(struct net *net, void *extra, unsigned char *packet, int len); +void net_udp_rx_avail(struct net *net, void *extra); +void net_tcp_rx_avail(struct net *net, void *extra); + +/* net.c: */ +struct ethernet_packet_link *net_allocate_ethernet_packet_link( + struct net *net, void *extra, size_t len); int net_ethernet_rx_avail(struct net *net, void *extra); int net_ethernet_rx(struct net *net, void *extra, unsigned char **packetp, int *lenp); @@ -146,8 +183,8 @@ void net_dumpinfo(struct net *net); void net_add_nic(struct net *net, void *extra, unsigned char *macaddr); struct net *net_init(struct emul *emul, int init_flags, - char *ipv4addr, int netipv4len, char **remote, int n_remote, - int local_port); + const char *ipv4addr, int netipv4len, char **remote, int n_remote, + int local_port, const char *settings_prefix); /* Flag used to signify that this net should have a gateway: */ #define NET_INIT_FLAG_GATEWAY 1 @@ -180,4 +217,8 @@ #define TCP_INCOMING_BUF_LEN 2000 +#define NET_ADDR_IPV4 1 +#define NET_ADDR_IPV6 2 +#define NET_ADDR_ETHERNET 3 + #endif /* NET_H */