etherif.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. enum
  10. {
  11. Eaddrlen = 6,
  12. ETHERMINTU = 60, /* minimum transmit size */
  13. ETHERMAXTU = 1514, /* maximum transmit size */
  14. ETHERHDRSIZE = 14, /* size of an ethernet header */
  15. MaxEther = 48,
  16. Ntypes = 8,
  17. };
  18. typedef struct Ether Ether;
  19. struct Ether {
  20. ISAConf; /* hardware info */
  21. int ctlrno;
  22. int tbdf; /* type+busno+devno+funcno */
  23. uchar ea[Eaddrlen];
  24. void (*attach)(Ether*); /* filled in by reset routine */
  25. void (*detach)(Ether*);
  26. void (*transmit)(Ether*);
  27. void (*interrupt)(Ureg*, void*);
  28. long (*ifstat)(Ether*, void*, long, ulong);
  29. long (*ctl)(Ether*, void*, long); /* custom ctl messages */
  30. void (*power)(Ether*, int); /* power on/off */
  31. void (*shutdown)(Ether*); /* shutdown hardware before reboot */
  32. void *ctlr;
  33. int scan[Ntypes]; /* base station scanning interval */
  34. int nscan; /* number of base station scanners */
  35. Netif;
  36. };
  37. typedef struct Etherpkt Etherpkt;
  38. struct Etherpkt
  39. {
  40. uchar d[Eaddrlen];
  41. uchar s[Eaddrlen];
  42. uchar type[2];
  43. uchar data[1500];
  44. };
  45. extern Block* etheriq(Ether*, Block*, int);
  46. extern void addethercard(char*, int(*)(Ether*));
  47. extern uint32_t ethercrc(uchar*, int);
  48. extern int parseether(uchar*, char*);
  49. #define NEXT(x, l) (((x)+1)%(l))
  50. #define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1)