00001
00002
00003
00004
00005 typedef union etheraddr
00006 {
00007 unsigned char bytes[6];
00008 unsigned short shorts[3];
00009 }
00010 ether_addr;
00011
00012 typedef struct etherpacket
00013 {
00014 ether_addr dest;
00015 ether_addr src;
00016 unsigned char type[2];
00017 unsigned short pktlen;
00018 char *pktbuf;
00019 }
00020 ether_packet;
00021
00022 typedef struct ethervec
00023 {
00024 ether_addr dest;
00025 ether_addr src;
00026 unsigned char type[2];
00027 unsigned short iovcnt;
00028 struct iovec *iov;
00029 }
00030 ether_vec;
00031
00032 #ifndef __ETHER_BCAST_ADDR__
00033 extern ether_addr ether_bcast_addr;
00034 #endif
00035
00036 #ifdef __STDC__
00037
00038 int ether_open (char *name, unsigned type, ether_addr * address);
00039
00040 ether_addr *ether_address (int fd, ether_addr * address);
00041
00042 ether_addr *ether_intfaddr (char *intf, ether_addr * address);
00043
00044 char **ether_interfaces (void);
00045
00046 int ether_write (int fd, ether_packet * packet);
00047
00048 int ether_writev (int fd, ether_vec * packet);
00049
00050 int ether_read (int fd, ether_packet * packet);
00051
00052 int ether_readv (int fd, ether_vec * packet);
00053
00054 int ether_blocking (int fd, int state);
00055
00056 int ether_send_self (int fd);
00057
00058 int ether_mcast_self (int fd);
00059
00060 int ether_bcast_self (int fd);
00061
00062 char *ether_ntoa (ether_addr *);
00063
00064 ether_addr *ether_aton (char *);
00065
00066 #ifdef __GNUC__
00067
00068
00069
00070
00071
00072 typedef struct in_addr *_ether_NoNsEnSe;
00073 typedef struct hostent *_ether_nOnSeNsE;
00074
00075 #endif
00076
00077 char *ether_e2a (ether_addr *, char *);
00078
00079 ether_addr *ether_a2e (char *, ether_addr *);
00080
00081 struct in_addr *ether_e2ip (ether_addr *, struct in_addr *);
00082
00083 ether_addr *ether_ip2e (struct in_addr *, ether_addr *);
00084
00085 char *ether_e2host (ether_addr *, char *);
00086
00087 ether_addr *ether_host2e (char *, ether_addr *);
00088
00089 ether_addr *ether_hostent2e (struct hostent *, ether_addr *);
00090
00091 #else
00092
00093 int ether_open ();
00094 ether_addr *ether_address ();
00095 ether_addr *ether_intfaddr ();
00096 char **ether_interfaces ();
00097 int ether_write ();
00098 int ether_writev ();
00099 int ether_read ();
00100 int ether_readv ();
00101 int ether_blocking ();
00102 int ether_send_self ();
00103 int ether_mcast_self ();
00104 int ether_bcast_self ();
00105
00106 char *ether_ntoa ();
00107 ether_addr *ether_aton ();
00108 char *ether_e2a ();
00109 ether_addr *ether_a2e ();
00110 struct in_addr *ether_e2ip ();
00111 ether_addr *ether_ip2e ();
00112 char *ether_e2host ();
00113 ether_addr *ether_host2e ();
00114 ether_addr *ether_hostent2e ();
00115
00116 #endif
00117
00118 #undef ether_cmp
00119
00120 #define ether_cmp(addr1,addr2) \
00121 ((addr1)->shorts[0] != (addr2)->shorts[0] \
00122 || (addr1)->shorts[1] != (addr2)->shorts[1] \
00123 || (addr1)->shorts[2] != (addr2)->shorts[2])
00124
00125 #define ETHERSTRLEN 18
00126
00127 #ifdef NOFILE
00128 #ifndef MAXHOSTNAMELEN
00129 #define MAXHOSTNAMELEN 64
00130 #endif
00131 #endif
00132
00133
00134
00135 #define ETHER_DST 0
00136 #define ETHER_SRC 6
00137 #define ETHER_TYPE 12
00138 #define ETHER_PKT 14
00139 #define ETHER_MIN 46
00140 #define ETHER_MAX 1500
00141
00142 #define ETHER_MINTYPE 0x5DD
00143 #define ETHER_MAXTYPE 0xFFFF
00144
00145 #define ETHER_MCAST(addr) (((unsigned char *) (addr))[0] & 0x01)
00146
00147 #ifdef NT_ALLTYPES
00148 #define ETHER_ALLTYPES NT_ALLTYPES
00149 #else
00150 #define ETHER_ALLTYPES ((unsigned) -1)
00151 #endif