00001
00002
00003
00004
00005
00006
00007
00008
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
00021
00022
00023 #define IF_TYPE_ETHERNET 0
00024 #define IF_TYPE_LOOPBACK 1
00025
00026
00027
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
00038
00039
00040
00041 typedef int (*if_start_fn_t)(struct s_iface *iface, int if_minor);
00042
00043 typedef int (*if_stop_fn_t)(struct s_iface *iface);
00044
00045 typedef int (*if_send_fn_t)(struct s_iface *iface, struct s_pkbuf *pk);
00046
00047 typedef int (*if_ack_fn_t)(struct s_iface *iface, int tx_id, int tx_state);
00048
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
00064
00065
00066 #define IF_NAME_SIZE 10
00067
00068
00069
00070
00071
00072 struct s_if_stat
00073 {
00074
00075 };
00076
00077
00078
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;
00088
00089 struct sockaddr *ifa_addr;
00090 struct sockaddr *ifa_broadaddr;
00091 struct sockaddr *ifa_netmask;
00092
00093 struct s_route_entry *ifa_route;
00094 };
00095
00096
00097
00098
00099
00100 typedef struct s_iface
00101 {
00102 LIST_ENTRY(s_iface) if_next;
00103
00104 char if_name[IF_NAME_SIZE];
00105 u_int32_t if_id;
00106 pid_t if_pgid;
00107 u_int32_t if_state;
00108 struct s_entry *if_dir;
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;
00115
00116
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
00124 #ifdef __INET__
00125
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
00137 #endif