make ramdisk support generic, some cleanups
[openwrt.git] / package / switch / src / switch-core.h
1 #ifndef __SWITCH_CORE_H
2 #define __SWITCH_CORE_H
3
4 #include <linux/version.h>
5 #include <linux/list.h>
6 #define SWITCH_MAX_BUFSZ 4096
7
8 #define SWITCH_MEDIA_AUTO 1
9 #define SWITCH_MEDIA_100 2
10 #define SWITCH_MEDIA_FD 4
11
12 #ifndef KERNEL_VERSION
13 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
14 #endif
15
16 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
17 #define LINUX_2_4
18 #endif
19
20 typedef int (*switch_handler)(void *driver, char *buf, int nr);
21
22 typedef struct {
23 char *name;
24 switch_handler read, write;
25 } switch_config;
26
27 typedef struct {
28 struct list_head list;
29 char *name;
30 char *version;
31 char *interface;
32 int cpuport;
33 int ports;
34 int vlans;
35 switch_config *driver_handlers, *port_handlers, *vlan_handlers;
36 void *data;
37 void *priv;
38 } switch_driver;
39
40 typedef struct {
41 u32 port, untag, pvid;
42 } switch_vlan_config;
43
44
45 extern int switch_register_driver(switch_driver *driver);
46 extern void switch_unregister_driver(char *name);
47 extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
48 extern int switch_parse_media(char *buf);
49 extern int switch_print_media(char *buf, int media);
50
51 static inline char *strdup(char *str)
52 {
53 char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
54 strcpy(new, str);
55 return new;
56 }
57
58
59 #endif
This page took 0.043358 seconds and 5 git commands to generate.