#include <string.h>
#include "monitor.h"
#include "agentapi.h"
#include "dyn_api.h"
#include "dyn_wireless.h"
#include "debug.h"
#include "util.h"
#include "mn.h"
#include "owntypes.h"
Include dependency graph for monitor_api.c:
Go to the source code of this file.
Defines | |
#define | DEBUG_FLAG 'm' |
Functions | |
int | monitor_api_get_ch (unsigned char *buffer, __u16 *length) |
int | monitor_api_set_ch (char *ifname, int channel) |
int | monitor_api_mon_conf (char *buffer, int len, int type) |
Variables | |
monitor_global_data | mon_conf |
GLOBAL VARIABLES. | |
monitor_interface | mon_devs [MAX_INTERFACES] |
monitor_conf_vars | monitor_conf [] |
STRUCTURES. |
#define DEBUG_FLAG 'm' |
Definition at line 24 of file monitor_api.c.
int monitor_api_get_ch | ( | unsigned char * | buffer, | |
__u16 * | length | |||
) |
Definition at line 31 of file monitor_api.c.
References monitor_interface::channel, DEBUG(), DEBUG_FLAG, dyn_wireless_get_ap_address(), dyn_wireless_get_channel(), ifname, IFNAMSIZ, MAX_INTERFACES, mon_devs, and sock.
00032 { 00033 int ch, len, count = 0, i; 00034 struct dynamics_mn_iw_ch_info *info 00035 = (struct dynamics_mn_iw_ch_info *)buffer; 00036 00037 len = sizeof(struct dynamics_mn_iw_ch_info); 00038 for (i = 0; i < MAX_INTERFACES; i++) { 00039 if (!mon_devs[i].in_use) 00040 continue; 00041 00042 /* get channel */ 00043 ch = dyn_wireless_get_channel(mon_devs[i].sock, 00044 mon_devs[i].ifname); 00045 if (ch < 0) { 00046 DEBUG(DEBUG_FLAG, "monitor_api_get_ch: channel " 00047 "< 0 (%s)\n", mon_devs[i].ifname); 00048 continue; 00049 } 00050 mon_devs[i].channel = ch; /* if changed */ 00051 00052 /* copy to caller */ 00053 if (*length+len > API_DATA_SIZE) { 00054 DEBUG(DEBUG_FLAG, "monitor_api_get_ch: Not enough " 00055 "room for interface name (%d, %d)\n", *length, 00056 *length+len); 00057 return 1; 00058 } 00059 00060 memcpy(info[count].ifname, mon_devs[i].ifname, IFNAMSIZ); 00061 info[count].channel = mon_devs[i].channel; 00062 00063 /* get AP hw addr */ 00064 if (dyn_wireless_get_ap_address(mon_devs[i].sock, 00065 mon_devs[i].ifname, 00066 info[count].ap_hwaddr) < 0) { 00067 DEBUG(DEBUG_FLAG, "monitor_api_get_ch: get AP hw " 00068 "addr failed\n"); 00069 continue; 00070 } 00071 00072 *length += len; 00073 DEBUG(DEBUG_FLAG, "monitor_api_get_ch: %s: %d - %s\n", 00074 info[count].ifname, info[count].channel, 00075 ether_hwtoa(info[count].ap_hwaddr)); 00076 } 00077 00078 return 0; 00079 }
Here is the call graph for this function:
int monitor_api_mon_conf | ( | char * | buffer, | |
int | len, | |||
int | type | |||
) |
Definition at line 202 of file monitor_api.c.
References DEBUG(), DEBUG_FLAG, GET_MONCONF, GET_MONCONF_VAR, and SET_MONCONF_VAR.
00203 { 00204 switch (type) { 00205 case GET_MONCONF: 00206 DEBUG(DEBUG_FLAG, "monitor_api_mon_conf: get_mon_conf\n"); 00207 return get_mon_conf(buffer, len); 00208 case GET_MONCONF_VAR: 00209 DEBUG(DEBUG_FLAG, "monitor_api_mon_conf: get_mon_conf_var\n"); 00210 return get_mon_conf_var(buffer, len); 00211 case SET_MONCONF_VAR: 00212 DEBUG(DEBUG_FLAG, "monitor_api_mon_conf: set_mon_conf_var\n"); 00213 return set_mon_conf_var(buffer, len); 00214 default: 00215 DEBUG(DEBUG_FLAG, "monitor_api_mon_conf: unknown type\n"); 00216 return API_UNDEFINED; 00217 } 00218 00219 /* never reached */ 00220 return 0; 00221 }
Here is the call graph for this function:
int monitor_api_set_ch | ( | char * | ifname, | |
int | channel | |||
) |
Definition at line 82 of file monitor_api.c.
References DEBUG(), DEBUG_FLAG, dyn_wireless_set_channel(), MAX_INTERFACES, mon_devs, and sock.
00083 { 00084 int r, i; 00085 00086 for (i = 0; i < MAX_INTERFACES; i++) { 00087 if (!mon_devs[i].in_use || 00088 memcmp(ifname, mon_devs[i].ifname, strlen(ifname))) 00089 continue; 00090 /* set channel */ 00091 r = dyn_wireless_set_channel(mon_devs[i].sock, 00092 mon_devs[i].ifname, 00093 channel); 00094 return r; 00095 } 00096 00097 DEBUG(DEBUG_FLAG, "monitor_set_ch: not wireless interface (%s)\n", 00098 ifname); 00099 return -1; 00100 }
Here is the call graph for this function:
struct monitor_global_data mon_conf |
struct monitor_interface mon_devs[MAX_INTERFACES] |
struct monitor_conf_vars monitor_conf[] |