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 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; } inband_close(chan); return 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; }