home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / bsd / net / netif.h < prev    next >
Text File  |  1992-07-29  |  4KB  |  151 lines

  1. /* 
  2.  * Copyright (C) 1990 by NeXT, Inc., All Rights Reserved
  3.  *
  4.  */
  5.  
  6. /*
  7.  * Network Interface API
  8.  *
  9.  * HISTORY
  10.  * 09-Apr-90  Bradley Taylor (btaylor) at NeXT, Inc.
  11.  *    Created. Some parts originally part of <net/if.h>.
  12.  */
  13. #ifndef _NETIF_
  14. #define _NETIF_
  15.  
  16. #import <net/netbuf.h>
  17.  
  18. /*
  19.  * BEGIN: BSD copyrighted material
  20.  */
  21. /*
  22.  * Copyright (c) 1982, 1986 Regents of the University of California.
  23.  * All rights reserved.  The Berkeley software License Agreement
  24.  * specifies the terms and conditions for redistribution.
  25.  *
  26.  */
  27. #define    IFF_UP        0x1        /* interface is up */
  28. #define    IFF_BROADCAST    V"    /* broadcast address valid */
  29. #define    IFF_DEBUG    0x4        /* turn on debugging */
  30. #define    IFF_LOOPBACK    0x8        /* is a loopback net */
  31. #define    IFF_POINTTOPOINT    0x10        /* interface is point-to-point link */
  32. #define    IFF_POINTOPOINT    0x10        /* interface is point-to-point link */
  33. #define    IFF_NOTRAILERS    0x20        /* avoid use of trailers */
  34. #define    IFF_RUNNING    0x40        /* resources allocated */
  35. #define    IFF_NOARP    0x80        /* no address resolution protocol */
  36. /* next two not supported now, but reserved: */
  37. #define    IFF_PROMISC    0x100        /* receive all packets */
  38. #define    IFF_ALLMULTI    0x200        /* receive all multicast packets */
  39. #define IFF_D1        0x400        /* For CSLIP */
  40. #define IFF_D2        0x800        /* For CSLIP */    
  41. #define IFF_D3        0x1000        /* For CSLIP */    
  42. #define IFF_COMPAC    IFF_D1        /* For PPP */
  43. #define IFF_COMPPROT    0x2000        /* For PPP */
  44. /*
  45.  * END: BSD copyrighted material
  46.  */
  47.  
  48. #define    IFF_AUTOCONF    0x4000        /* Network is autoconfiguring */
  49. #define IFF_AUTODONE    0x8000        /* Network has autoconfigured */
  50.  
  51. typedef enum netif_class {
  52.     NETIFCLASS_REAL = 0,
  53.     NETIFCLASS_VIRTUAL = 0x1000,
  54.     NETIFCLASS_SNIFFER = 0x2000
  55. } netif_class_t;
  56.  
  57. #ifdef KERNEL
  58.  
  59. extern const char IFCONTROL_SETFLAGS[];
  60. extern const char IFCONTROL_SETADDR[];
  61. extern const char IFCONTROL_GETADDR[];
  62. extern const char IFCONTROL_AUTOADDR[];
  63. extern const char IFCONTROL_UNIXIOCTL[];
  64.  
  65.  
  66. typedef struct if_ioctl {
  67.     unsigned ioctl_command;
  68.     void *ioctl_data;
  69. } if_ioctl_t;
  70.     
  71. typedef struct { char opaque[1]; } *netif_t;
  72.  
  73.  
  74. typedef int (*if_input_func_t)(netif_t netif, netif_t realnetif,
  75.                 netbuf_t nb, void *extra);
  76. typedef int (*if_init_func_t)(netif_t netif);
  77.  
  78. typedef int (*if_output_func_t)(netif_t netif, netbuf_t nb, void *address);
  79. typedef netbuf_t (*if_getbuf_func_t)(netif_t netif);
  80. typedef int (*if_control_func_t)(netif_t netif, const char *command, 
  81.                  void *data);
  82.  
  83. typedef void (*if_attach_func_t)(void *private, netif_t realif);
  84.  
  85. extern int if_output(netif_t netif, netbuf_t packet, void *addr);
  86. extern int if_init(netif_t netif);
  87. extern int if_control(netif_t netif, const char *command, void *data);
  88.  
  89.  
  90. extern int if_ioctl(netif_t netif, unsigned command, void *data);
  91.  
  92. extern netbuf_t if_getbuf(netif_t netif);
  93. extern int if_handle_input(netif_t netif, netbuf_t nb, void *extra);
  94.  
  95.  
  96.  
  97. extern netif_t if_attach(if_init_func_t init_func, 
  98.              if_input_func_t input_func,
  99.              if_output_func_t output_func,
  100.     V#f_getbuf_func_t getbuf_func,
  101.              if_control_func_t control_func,
  102.              const char *name,
  103.              unsigned unit,
  104.              const char *type,
  105.              unsigned mtu,
  106.              unsigned flags,
  107.              netif_class_t class,
  108.              void *private);
  109.  
  110. extern void if_registervirtual(if_attach_func_t attach_func, void *private);
  111.  
  112. extern void if_detach(netif_t);
  113.  
  114. extern netif_t iflist_first(void);
  115. extern netif_t iflist_next(netif_t);
  116.           
  117. /*
  118.  * Readable attributes
  119.  */
  120. extern const char *if_type(netif_t netif);
  121. extern const char *if_name(netif_t netif);
  122. extern unsigned if_unit(netif_t netif);
  123. extern unsigned if_mtu(netif_t netif);
  124. extern netif_class_t if_class(netif_t netif);
  125. extern void *if_private(netif_t netif);
  126.  
  127. /*
  128.  * Writable attributes 
  129.  */
  130. extern unsigned if_flags(netif_t netif);
  131. extern void if_flags_set(netif_t netif, unsigned flags);
  132.  
  133. extern unsigned if_ipackets(netif_t netif);
  134. extern void if_ipackets_set(netif_t netif, unsigned ipackets);
  135.  
  136. extern unsigned if_opackets(netif_t netif);
  137. extern void if_opackets_set(netif_t netif, unsigned opackets);
  138.  
  139. extern unsigned if_oerrors(netif_t netif);
  140. extern void if_oerrors_set(netif_t netif, unsigned oerrors);
  141.  
  142. extern unsigned if_ierrors(netif_t netif);
  143. extern void if_ierrors_set(netif_t netif, unsigned ierrors);
  144.  
  145. extern unsigned if_collisions(netif_t netif);
  146. extern void if_collisions_set(netif_t netif, unsigned collisions);
  147.  
  148. #endif /* KERNEL */
  149.  
  150. #endif /* _NETIF_ */
  151.