2002-08-27 11:59:57 +04:00
|
|
|
/* net_misc.h
|
|
|
|
* Miscellaneous networking stuff that doesn't yet have a home.
|
|
|
|
*/
|
|
|
|
|
2002-10-30 04:21:54 +03:00
|
|
|
//#ifdef _NETWORK_STACK
|
2002-08-27 11:59:57 +04:00
|
|
|
|
|
|
|
#ifndef OBOS_NET_MISC_H
|
|
|
|
#define OBOS_NET_MISC_H
|
|
|
|
|
2002-10-30 04:21:54 +03:00
|
|
|
//#include <kernel/OS.h>
|
|
|
|
#include <Errors.h>
|
|
|
|
#include <mbuf.h>
|
|
|
|
|
|
|
|
#ifdef _KERNEL_MODE
|
2002-08-27 11:59:57 +04:00
|
|
|
#include <KernelExport.h>
|
|
|
|
#define printf dprintf
|
|
|
|
#endif
|
|
|
|
|
2005-11-07 23:09:10 +03:00
|
|
|
#ifndef __HAIKU__
|
2002-08-27 11:59:57 +04:00
|
|
|
/* Not really sure if this is safe... */
|
|
|
|
#define EHOSTDOWN (B_POSIX_ERROR_BASE + 45)
|
2005-11-07 23:09:10 +03:00
|
|
|
#endif
|
2002-08-27 11:59:57 +04:00
|
|
|
|
|
|
|
/* These are GCC only, so we'll need PPC version eventually... */
|
|
|
|
struct quehead {
|
|
|
|
struct quehead *qh_link;
|
|
|
|
struct quehead *qh_rlink;
|
|
|
|
};
|
|
|
|
|
|
|
|
static __inline void insque(void *a, void *b)
|
|
|
|
{
|
|
|
|
struct quehead *element = (struct quehead *)a,
|
|
|
|
*head = (struct quehead *)b;
|
|
|
|
|
|
|
|
element->qh_link = head->qh_link;
|
|
|
|
element->qh_rlink = head;
|
|
|
|
head->qh_link = element;
|
|
|
|
element->qh_link->qh_rlink = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void remque(void *a)
|
|
|
|
{
|
|
|
|
struct quehead *element = (struct quehead *)a;
|
|
|
|
|
|
|
|
element->qh_link->qh_rlink = element->qh_rlink;
|
|
|
|
element->qh_rlink->qh_link = element->qh_link;
|
|
|
|
element->qh_rlink = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DEBUG Options!
|
|
|
|
*
|
|
|
|
* Having a single option is sort of lame so I'm going to start adding more here...
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define SHOW_DEBUG 0 /* general debugging stuff (verbose!) */
|
|
|
|
#define SHOW_ROUTE 0 /* show routing information */
|
|
|
|
#define ARP_DEBUG 0 /* show ARP debug info */
|
|
|
|
#define USE_DEBUG_MALLOC 0 /* use the debug malloc code*/
|
|
|
|
|
|
|
|
typedef struct ifnet ifnet;
|
|
|
|
|
|
|
|
/* ARP lookup return codes... */
|
|
|
|
enum {
|
|
|
|
ARP_LOOKUP_OK = 1,
|
|
|
|
ARP_LOOKUP_QUEUED = 2,
|
|
|
|
ARP_LOOKUP_FAILED = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef uint32 ipv4_addr;
|
|
|
|
|
|
|
|
/* XXX - add some macro's for inserting various types of address
|
|
|
|
*/
|
|
|
|
|
|
|
|
void net_server_add_device(ifnet *ifn);
|
2002-10-30 04:21:54 +03:00
|
|
|
//XXX already in netinet/in.h
|
|
|
|
//uint16 in_cksum(struct mbuf *m, int len, int off);
|
2002-08-27 11:59:57 +04:00
|
|
|
void local_init(void);
|
|
|
|
|
|
|
|
/* sockets and in_pcb init */
|
|
|
|
int sockets_init(void);
|
|
|
|
void sockets_shutdown(void);
|
|
|
|
int inpcb_init(void);
|
|
|
|
|
|
|
|
void start_tx_thread(ifnet *dev);
|
|
|
|
void start_rx_thread(ifnet *dev);
|
|
|
|
|
|
|
|
/* Useful debugging functions */
|
|
|
|
void dump_ipv4_addr(char *msg, void *ad);
|
|
|
|
void print_ipv4_addr(void *ad);
|
|
|
|
void dump_ether_addr(char *msg, void *ma);
|
|
|
|
void print_ether_addr(void *ea);
|
|
|
|
void dump_buffer(char *buffer, int len);
|
|
|
|
void dump_sockaddr(void *ptr);
|
|
|
|
|
|
|
|
#endif /* OBOS_NET_MISC_H */
|
|
|
|
|
2002-10-30 04:21:54 +03:00
|
|
|
//#endif /* _NETWORK_STACK */
|
2002-08-27 11:59:57 +04:00
|
|
|
|