int inband_remote_cmd(unsigned char *cmd) { unsigned char *buf; unsigned int channel = -1; channel = inband_open(INBAND_INTF,INBAND_SLAVE,INBAND_IOCTL_TYPE,INBAND_DEBUG); if( channel < 0 || inband_write(channel, get_random(65535), sycall_cmd_type, cmd, strlen(cmd), 0) < 0) { printf("inband sent remote command failed\n"); }/* else { if( inband_rcv_data(channel, &syscall_cmd_type, &buf, -1) < 0 ) printf("inband try to receive respone but failed\n"); inband_close(channel); }*/ inband_close(channel); }
static void do_wps_event(struct network_info_t *info, char *data,int data_len) { char *wps_config="/tmp/wps.conf"; int fd,ret=0; fd = open(wps_config, O_RDWR | O_CREAT); if (fd < 0) { printf("Cannot Open file %s!\n", wps_config); return -1; } write( fd, data, data_len); close(fd); debug_message("wps event , the config is store to %s \n",wps_config); debug_message("get wps config from this file and set these mib to AP \n"); inband_write(info->channel,0,0,data,data_len,1); //send good reply }
int notify_host(int signo) { struct iwreq wrq; DOT11_REQUEST *req; /* Get wireless name */ memset(wrq.ifr_ifrn.ifrn_name, 0, sizeof wrq.ifr_ifrn.ifrn_name); strncpy(wrq.ifr_ifrn.ifrn_name, "wlan0", IFNAMSIZ); req = (DOT11_REQUEST *)malloc(MAXDATALEN); wrq.u.data.pointer = (caddr_t)req; req->EventId = DOT11_EVENT_REQUEST; wrq.u.data.length = sizeof(DOT11_REQUEST); //iw_message(MESS_DBG_IWCONTROL, "[RequestIndication] : Start\n"); //printf("\n[RequestIndication] : Start\n"); if(ioctl(ioctl_sock, SIOCGIWIND, &wrq) < 0) { // If no wireless name : no wireless extensions return(-1); } inband_write(event_channel,0,0xff,wrq.u.data.pointer,wrq.u.data.length,0); }
static int notif_host(void) { int i, ret,fd; int chan; unsigned int seq=0; char *data; char *buf_p,rx_cmd_type; int count; struct stat ffstat; int flen=0,len; chan = inband_open(INBAND_NETIF,"00e04c8196c1",ETH_P_RTK_NOTIFY,INBAND_DEBUG); if (chan < 0) { printf("open inband failed!\n"); return -1; } fd = open(WPS_CONF, O_RDONLY); if (fd < 0) { printf("Cannot Open file %s!\n", WPS_CONF); return -1; } fstat(fd, &ffstat); flen = ffstat.st_size; printf("flen = %d \n",flen); if((data = (char *)malloc(flen)) == NULL) { printf("data buffer allocation failed!\n"); return -1; } ret = read(fd, data, flen); if (ret != flen) { printf("Reading error\n"); free(data); //need free before return!!!!! return -1; } close(fd); len = flen; ret = inband_write(chan,0,0,data,len,0); //send request free(data); //need free before return!!!!! count = inband_rcv_data(chan,&rx_cmd_type,&buf_p,3); //return data length if(count < 0) { ret=-1; DEBUG_ERR("wps notify fail\n"); } if( (rx_cmd_type == 0) ) DEBUG_ERR("wps notify ok!\n"); else { ret=-1; DEBUG_ERR("wps notify fail!\n"); } inband_close(chan); return 0; }