临时

    技术2025-09-15  28

    在kernel声明空间并赋值。char *mem;mem = kmalloc(size, GFP_KERNEL);memcpy(mem,source,size);kfree(mem);不然会出错。 定义枚举类/*********************************/typedef enum _IW_TYPE{ IW_POINT_TYPE=0, IW_PARAM_TYPE, IW_FREQ_TYPE,} IW_TYPE;IW_TYPE type; /*********************************/struct iw_request_info{ __u16 cmd; /* Wireless Extension command */ __u16 flags; /* More to come ;-) */}; /* ------------------------ IOCTL REQUEST ------------------------ *//** This structure defines the payload of an ioctl, and is used */862 union iwreq_data863 {864 /* Config - generic */865 char name[IFNAMSIZ];866 /* Name : used to verify the presence of wireless extensions.867 * Name of the protocol/provider... */868 869 struct iw_point essid; /* Extended network name */870 struct iw_param nwid; /* network id (or domain - the cell) */871 struct iw_freq freq; /* frequency or channel :872 * 0-1000 = channel873 * > 1000 = frequency in Hz */874 875 struct iw_param sens; /* signal level threshold */876 struct iw_param bitrate; /* default bit rate */877 struct iw_param txpower; /* default transmit power */878 struct iw_param rts; /* RTS threshold threshold */879 struct iw_param frag; /* Fragmentation threshold */880 __u32 mode; /* Operation mode */881 struct iw_param retry; /* Retry limits & lifetime */882 883 struct iw_point encoding; /* Encoding stuff : tokens */884 struct iw_param power; /* PM duration/timeout */885 struct iw_quality qual; /* Quality part of statistics */886 887 struct sockaddr ap_addr; /* Access point address */888 struct sockaddr addr; /* Destination address (hw/mac) */889 890 struct iw_param param; /* Other small parameters */891 struct iw_point data; /* Other large parameters */892 }; 894 /*895 * The structure to exchange data for ioctl.896 * This structure is the same as 'struct ifreq', but (re)defined for897 * convenience...898 * Do I need to remind you about structure size (32 octets) ?899 */900 struct iwreq 901 {902 union903 {904 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */905 } ifr_ifrn;906 907 /* Data part (defined just above) */908 union iwreq_data u;909 }; /* Send a single event to user space */extern void wireless_send_event(struct net_device *dev, unsigned int cmd, union iwreq_data *wrqu, char *extra); struct net_device dev->flags 在ifconfig命令时候有用。 unsigned dev_get_flags(const struct net_device *dev)int dev_change_flags(struct net_device *dev, unsigned flags)example:dev_change_flags(dev, dev->flags & ~IFF_UP); netif_carrier_on(net_deviece **);大多数涉及物理设备可以感知信号载波(carrier)的存在,载波的存在意味着设备可以工作据个例子来讲:当一个用户拔掉了网线,也就意味着信号载波的消失利用netif_carrier_on(net_device  * dev),netif_carrier_off(net_device * dev),这些关于载波的函数,你可以改变载波状态netif_carrier_ok可以用来检测载波状态 netif_start_queue(net_device **);函数告诉系统可以使用hard_start_xmit进行数据发送了

     

    最新回复(0)