iface.h

Go to the documentation of this file.
00001 /*
00002 ** if.h for  in /home/anoman/work/lse/atomix/lseos-net
00003 ** 
00004 ** Copyright (c)2004 Arthur Kopatsy
00005 ** Login   <kopats_a@epita.fr>
00006 ** 
00007 ** Started on  Fri Jun 18 14:48:51 2004 Arthur Kopatsy
00008 ** Last update Tue Dec 21 11:51:38 2004 Arthur Kopatsy
00009 */
00010 
00011 #ifndef IFACE_H_
00012 #define IFACE_H_
00013 
00014 struct s_pkbuf;
00015 struct s_entry;
00016 struct s_of;
00017 struct s_iface;
00018 
00019 /* 
00020 ** if_type
00021 */
00022 
00023 #define IF_TYPE_ETHERNET        0
00024 #define IF_TYPE_LOOPBACK        1
00025 
00026 /*
00027 ** if_state 
00028 */
00029 
00030 #define IF_STATE_DOWN           (0<<0)
00031 #define IF_STATE_UP             (1<<0)
00032 #define IF_STATE_BROADCAST      (1<<1)
00033 #define IF_STATE_MULTICAST      (1<<2)
00034 #define IF_STATE_PROMISC        (1<<3)
00035 
00036 /* 
00037 ** if_ops
00038 */
00039 
00040 /* Called to initialise the driver */
00041 typedef int (*if_start_fn_t)(struct s_iface *iface, int if_minor);
00042 /* Called to stop driver */
00043 typedef int (*if_stop_fn_t)(struct s_iface *iface);
00044 /* Call to send a packet to the interface */
00045 typedef int (*if_send_fn_t)(struct s_iface *iface, struct s_pkbuf *pk);
00046 /* Useful and used only for server driver to give to inet part transmission result */
00047 typedef int (*if_ack_fn_t)(struct s_iface *iface, int tx_id, int tx_state);
00048 /* Used to warn driver of if_* modification */
00049 typedef int (*if_update_fn_t)(struct s_iface *iface);
00050 
00051 struct s_if_ops
00052 {
00053   int                   if_drv_id;
00054   int                   if_type;
00055   if_start_fn_t         if_start;
00056   if_stop_fn_t          if_stop;
00057   if_send_fn_t          if_send;
00058   if_ack_fn_t           if_ack;
00059   if_update_fn_t        if_update;
00060 };
00061 
00062 /* 
00063 ** if_name
00064 */
00065 
00066 #define IF_NAME_SIZE            10
00067 
00068 /*
00069 ** if_stat
00070 */
00071 
00072 struct s_if_stat
00073 {
00074   
00075 };
00076 
00077 /* 
00078 ** if_addr_list
00079 */
00080 struct s_iface;
00081 
00082 struct s_ifaddr
00083 {
00084   LIST_ENTRY(s_ifaddr)  ifa_next;
00085   int                   ifa_type;
00086 
00087   struct s_iface        *ifa_if;                /* Corresponding interface */
00088   
00089   struct sockaddr       *ifa_addr;              /* Interface address */
00090   struct sockaddr       *ifa_broadaddr;         /* Broadcast address */
00091   struct sockaddr       *ifa_netmask;           /* Netmask */
00092 
00093   struct s_route_entry  *ifa_route;
00094 };
00095 
00096 /* 
00097 ** iface structure
00098 */
00099 
00100 typedef struct s_iface
00101 {
00102   LIST_ENTRY(s_iface)                   if_next;
00103 
00104   char                                  if_name[IF_NAME_SIZE];          /* Interface name */
00105   u_int32_t                             if_id;                          /* ID for inet */
00106   pid_t                                 if_pgid;
00107   u_int32_t                             if_state;                       /* State of interface */
00108   struct s_entry                        *if_dir;                        /* Inetfs directory corresponding to the interface */
00109 
00110   u_int32_t                             if_mtu;
00111   struct s_ifaddr                       *if_nl_addr;
00112   struct sockaddr                       *if_ll_addr;
00113 
00114   struct s_if_stat                      if_stat;                        /* Interface statistic. Updated by both inet and interfaces process */
00115 
00116   /* In Construction */
00117   struct s_if_ops                       *if_ops;
00118   void                                  *if_drv_info;
00119 } t_iface;
00120 
00121 LIST_HEAD(s_iface_list, s_iface);
00122 
00123 /* PROTO iface.c */
00124 #ifdef __INET__
00125 /* iface.c */
00126 struct s_iface *iface_find(u_int32_t if_id);
00127 u_int32_t iface_find_id(void);
00128 int iface_register(int if_type, int if_minor, pid_t if_pgid);
00129 int iface_ll_output(struct s_pkbuf *pk, int type);
00130 void ifstate_update(struct s_iface *iface);
00131 void ifaddrip_update(struct s_iface *iface);
00132 void ifaddrip_change(struct s_of *of);
00133 void ifnetmask_change(struct s_of *of);
00134 void ifaddrmac_change(struct s_of *of);
00135 int iface_create_entry(struct s_entry *father, char *filename, struct s_entry **new);
00136 #endif /* __INET__ */
00137 #endif

Generated on Wed May 24 23:05:52 2006 for LSE/OS by  doxygen 1.4.6