00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00018
00019
00020 #include <netinet/in.h>
00021 #include <linux/if.h>
00022 #include <sys/msg.h>
00023 #include <errno.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026
00027 extern int (*vif_debug)(const char *format, ...);
00028 extern int (*vif_error)(const char *format, ...);
00029
00030
00031
00032 #define VIF_NOTIFY_KEY 1337
00035 typedef struct {
00036 long mtype;
00037 int ioctl_type;
00038 char dev_name[IFNAMSIZ + 1];
00039 } ioctl_msg;
00040
00041 #define IOCTL_MSG_SIZE sizeof(ioctl_msg)
00042 #define VIF_SIOCSIW 0x10
00045
00046
00053 int
00054 vif_notify_ioctl(int ioctl_type, const char *dev_name)
00055 {
00056 ioctl_msg msg;
00057 int write_flags = 0600;
00058
00059 int msgq_id = msgget(VIF_NOTIFY_KEY, write_flags);
00060 if (msgq_id < 0)
00061 {
00062 vif_debug("vif_notify_ioctl(): Failed to update WlanModel\n");
00063 return -1;
00064 }
00065
00066
00067 memset(&msg, 0, IOCTL_MSG_SIZE);
00068 msg.mtype = VIF_SIOCSIW;
00069 msg.ioctl_type = ioctl_type;
00070 strncpy(msg.dev_name, dev_name, IFNAMSIZ);
00071 msg.dev_name[IFNAMSIZ] = '\0';
00072
00073 if (msgsnd(msgq_id, &msg, IOCTL_MSG_SIZE, 0) < 0)
00074 {
00075 vif_debug("vif_notify_ioctl(): msgsnd (%s)\n", strerror(errno));
00076 return -1;
00077 }
00078
00079 return 0;
00080 }