diff --git a/headers/posix/net/if.h b/headers/posix/net/if.h index 8aadc4157a..797b8426ce 100644 --- a/headers/posix/net/if.h +++ b/headers/posix/net/if.h @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_H @@ -56,16 +56,19 @@ struct ifreq { }; /* interface flags */ -#define IFF_UP 0x0001 -#define IFF_BROADCAST 0x0002 /* valid broadcast address */ -#define IFF_LOOPBACK 0x0008 -#define IFF_POINTOPOINT 0x0010 /* point-to-point link */ -#define IFF_NOARP 0x0040 /* no address resolution */ -#define IFF_AUTOUP 0x0080 /* auto dial */ -#define IFF_PROMISC 0x0100 /* receive all packets */ -#define IFF_ALLMULTI 0x0200 /* receive all multicast packets */ -#define IFF_SIMPLEX 0x0800 /* doesn't receive own transmissions */ -#define IFF_MULTICAST 0x8000 /* supports multicast */ +#define IFF_UP 0x0001 +#define IFF_BROADCAST 0x0002 /* valid broadcast address */ +#define IFF_LOOPBACK 0x0008 +#define IFF_POINTOPOINT 0x0010 /* point-to-point link */ +#define IFF_NOARP 0x0040 /* no address resolution */ +#define IFF_AUTOUP 0x0080 /* auto dial */ +#define IFF_PROMISC 0x0100 /* receive all packets */ +#define IFF_ALLMULTI 0x0200 /* receive all multicast packets */ +#define IFF_SIMPLEX 0x0800 /* doesn't receive own transmissions */ +#define IFF_LINK 0x1000 /* has link */ +#define IFF_AUTO_CONFIGURED 0x2000 /* has been automatically configured */ +#define IFF_CONFIGURING 0x4000 /* auto configuration in progress */ +#define IFF_MULTICAST 0x8000 /* supports multicast */ struct ifconf { int ifc_len; /* size of buffer */ diff --git a/headers/posix/net/if_media.h b/headers/posix/net/if_media.h new file mode 100644 index 0000000000..0b1ba1354b --- /dev/null +++ b/headers/posix/net/if_media.h @@ -0,0 +1,55 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _NET_IF_MEDIA_H +#define _NET_IF_MEDIA_H + + +/* bits usage + * ---- ----- + * 0-4 Media subtype + * 5-7 Media type + * 8-15 Type specific options + * 16-31 General options + */ + +/* Media types */ + +#define IFM_ETHER 0x00000020 /* Ethernet */ +#define IFM_TOKEN 0x00000040 /* Token Ring */ +#define IFM_FDDI 0x00000060 /* Fiber Distributed Data Interface */ +#define IFM_IEEE80211 0x00000080 /* Wireless IEEE 802.11 */ +#define IFM_ATM 0x000000a0 +#define IFM_CARP 0x000000c0 /* Common Address Redundancy Protocol */ + +/* Media subtypes */ + +/* Ethernet */ +#define IFM_10_T 3 /* 10Base-T - RJ45 */ +#define IFM_100_TX 6 /* 100Base-TX - RJ45 */ +#define IFM_1000_T 16 /* 1000Base-T - RJ45 */ + +/* General options */ + +#define IFM_FULL_DUPLEX 0x00100000 /* Full duplex */ +#define IFM_HALF_DUPLEX 0x00200000 /* Half duplex */ +#define IFM_LOOP 0x00400000 /* hardware in loopback */ +#define IFM_ACTIVE 0x00800000 /* Media link is active */ + +/* Masks */ + +#define IFM_NMASK 0x000000e0 /* Media type */ +#define IFM_TMASK 0x0000001f /* Media subtype */ +#define IFM_OMASK 0x0000ff00 /* Type specific options */ +#define IFM_GMASK 0xffff0000 /* Generic options */ + +/* Macros for the masks */ + +#define IFM_TYPE(x) ((x) & IFM_NMASK) +#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) +#define IFM_TYPE_OPTIONS(x) \ + ((x) & IFM_OMASK) +#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK)) + +#endif /* _NET_IF_MEDIA_H */ diff --git a/headers/private/net/ether_driver.h b/headers/private/net/ether_driver.h index 55dc18c466..f988c5aa7a 100644 --- a/headers/private/net/ether_driver.h +++ b/headers/private/net/ether_driver.h @@ -1,71 +1,41 @@ /* - * ether_driver.h - * - * Ethernet driver: handles NE2000 and 3C503 cards + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. */ -/* - Copyright 1999, Be Incorporated. All Rights Reserved. - This file may be used under the terms of the Be Sample Code License. -*/ #ifndef _ETHER_DRIVER_H #define _ETHER_DRIVER_H -#ifdef __cplusplus -extern "C" { -#endif +/*! Standard ethernet driver interface */ + #include -/* - * ioctls: belongs in a public header file - * somewhere, so that the net_server and other ethernet drivers can use. - */ + +/* ioctl() opcodes a driver should support */ enum { - ETHER_GETADDR = B_DEVICE_OP_CODES_END, /* get ethernet address */ - ETHER_INIT, /* set irq and port */ - ETHER_NONBLOCK, /* set/unset nonblocking mode */ - ETHER_ADDMULTI, /* add multicast addr */ - ETHER_REMMULTI, /* rem multicast addr */ - ETHER_SETPROMISC, /* set promiscuous */ - ETHER_GETFRAMESIZE, /* get frame size */ - ETHER_ADDTIMESTAMP, /* (try to) add timestamps to packets (BONE ext) */ - ETHER_HASIOVECS, /* does the driver implement writev ? (BONE ext) (bool *) */ - ETHER_GETIFTYPE, /* get the IFT_ type of the interface (int *) */ - ETHER_GETLINKSTATE /* get line speed, quality, duplex mode, etc. */ + ETHER_GETADDR = B_DEVICE_OP_CODES_END, + /* get ethernet address (required) */ + ETHER_INIT, /* (obsolete) */ + ETHER_NONBLOCK, /* change non blocking mode (int *) */ + ETHER_ADDMULTI, /* add multicast address */ + ETHER_REMMULTI, /* remove multicast address */ + ETHER_SETPROMISC, /* set promiscuous mode (int *) */ + ETHER_GETFRAMESIZE, /* get frame size (required) (int *) */ + ETHER_GETLINKSTATE + /* get line speed, quality, duplex mode, etc. (ether_link_state_t *) */ }; -/* - * 48-bit ethernet address, passed back from ETHER_GETADDR - */ +/* ETHER_GETADDR - MAC address */ typedef struct { - unsigned char ebyte[6]; + uint8 ebyte[6]; } ether_address_t; - -/* - * info passed to ETHER_INIT - */ - -typedef struct ether_init_params { - short port; - short irq; - unsigned long mem; -} ether_init_params_t; - -/* - * info returned from ETHER_GETLINKSTATE - */ - +/* ETHER_GETLINKSTATE */ typedef struct ether_link_state { - float link_speed; /* In Mbits per second */ - float link_quality; /* Set to zero if not connected */ - char duplex_mode; /* Set to 1 for full duplex, 0 for half */ + uint32 link_media; /* as specified in net/if_media.h */ + uint32 link_quality; /* in one tenth of a percent */ + uint64 link_speed; /* in Kbit/s */ } ether_link_state_t; -#ifdef __cplusplus -} -#endif - - -#endif /* _ETHER_DRIVER_H */ +#endif /* _ETHER_DRIVER_H */