示例#1
0
int16 lprConnect(char* host)
{
	CAB cab;
	int16 tcpHndl, state;

/* remote and local port numbers for lpr connection */

	cab.rport = LPR_REM_PORT;
	cab.lport = LPR_LOC_PORT+(int)(Random() % 10);
	cab.lhost = 0;

	if (resolve(host, NULL, &(cab.rhost), 1) < 1) {
		uiPrintf(uiH, uiPrERR, "unknown remote host");
		return 0;
	}

	if( (tcpHndl = TCP_open((uint32)&cab, TCP_ACTIVE, 0, tcpBuffSize)) <= 0 ) {
		uiPrintf(uiH, uiPrERR, "could not open connection");
		return 0;
	}

    if ( (state = TCP_wait_state(tcpHndl, TESTABLISH, 30)) < 0 ) {
		uiPrintf(uiH, uiPrERR, "%s", get_err_text(state));
		return 0;
    }

	return tcpHndl;
}
示例#2
0
struct _Socket *osSockCreate
(
	char *pname
)
{
	struct _Socket *pOSSock;

    pOSSock = (struct _Socket *) malloc(sizeof(*pOSSock));
    if (!pOSSock) {
	        uiPrintf("osSockCreate: malloc failed for pOSSock \n");
	        return NULL;
    }

    strcpy(pOSSock->hostname, "localhost");
    pOSSock->port_num = -1;

    pOSSock->sockfd = socket_create_and_accept(pOSSock->port_num);

    if (pOSSock->sockfd == -1) {
	        uiPrintf("Socket create failed \n");
	        return NULL;
    }

    return pOSSock;
}
示例#3
0
static void printFile(char *fileNam)
{
	int fi, fo;
#define NBUFF 256
	char buff[NBUFF];
	long len;
	
	fileNam[0] = 'd';			/* force data file */

	if ( (fi=Fopen(fileNam, FO_READ)) >= 0 ) {
		if ( (fo=Fcreate(prDevice, 0)) < 0)
			fo=Fopen(prDevice, FO_WRITE);
		/* Fopen may return < 0 for devices like PRN: ! */
		if ( fo > -31) {
	
			while ( (len=Fread(fi, NBUFF, buff)) > 0)
				Fwrite(fo, len, buff);
	
			Fclose(fo);
		} else {
	        uiPrintf(uiH, uiPrERR, "cannot open device|>%s<", prDevice);
		}
		Fclose(fi);
	} else {
        uiPrintf(uiH, uiPrERR, "cannot open dFile");
	}

	Fdelete(fileNam);
	fileNam[0] = 'c';			/* force control file */
	Fdelete(fileNam);
}	
示例#4
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
HANDLE open_device(A_UINT32 device_fn, A_UINT32 instance, char * pipeName) {
   char        dev_name[16];
   HANDLE       hDevice;

    if (device_fn == WMAC_FUNCTION) {
       strcpy(dev_name,"/dev/dk");
       dev_name[7]='0'+instance;
       dev_name[8]='\0';
    }
    else
    if (device_fn == SDIO_FUNCTION) {
       strcpy(dev_name,"/dev/dksdio");
       dev_name[11]='0'+instance;
       dev_name[12]='\0';
	}
    else {
       strcpy(dev_name,"/dev/dk_uart");
       dev_name[12]='0'+ (instance - (device_fn * MDK_MAX_NUM_DEVICES));
       dev_name[13]='\0';
    }
    uiPrintf("Opening device %s\n", dev_name);

	hDevice = open(dev_name,O_RDWR|O_SYNC);

	if (hDevice < 0) {
       uiPrintf("@Error opening device %s:%d\n", dev_name, hDevice);
	}
    return hDevice;

}
示例#5
0
/**************************************************************************
* uiOpenYieldLog - open the yield log file.
*
* A user interface command which turns on logging to the yield log file
*
* RETURNS: 1 if file opened, 0 if not
*/
A_UINT16 uiOpenYieldLog
(
    char *filename,        /* name of file to log to */
	A_BOOL append
)
{
    /* open file for writing */
    if (append) {
		yieldLogFile = fopen(filename, "a+");
	}
	else {
		yieldLogFile = fopen(filename, "w");
	}
    if (yieldLogFile == NULL) {
        uiPrintf("Unable to open yield log file %s\n", filename);
        return(0);
    } else {
		uiPrintf("Opened file %s for yieldLog\n", filename);
	}

    /* set flag to say yield logging enabled */
    yieldLogging = 1;

    return(1);
}
示例#6
0
static void recvJob(int16 cnId)
{
	int16 nInQueue;
	clock_t tQuit;

	while (1) {		/* loop over subcommands */

		tQuit = clock() + TIMEOUT * CLK_TCK;	/* time to quit at */
		while ( (nInQueue = CNbyte_count(cnId)) == 0 || nInQueue == E_NODATA) {
			if (clock() > tQuit) {
		        uiPrintf(uiH, uiPrERR, "rcvJob|timed out");
				return;
			}
			uiYield(uiH, YIELDMS);		/* wait till something arrives */
		} 

		if (nInQueue == E_EOF)
			return;						/* connection closed, no more subcommands */
	
		if (nInQueue > 0) {
			NDB* ndb;
			if ( (ndb = CNget_NDB(cnId)) != NULL ) {
				dispatchSubCmd(cnId, ndb);
			} else {
		        uiPrintf(uiH, uiPrERR, "recvJob|get_NDB");
			}

		} else {
			uiPrintf(uiH, uiPrERR, "recvJob|%s", get_err_text(nInQueue));
			return;
		}

	}	/* while..more subcommands */

}	/* recvJob */
示例#7
0
/**************************************************************************
* SocketAccept - Wait for a connection
*
*/
struct _Socket *SocketAccept ( struct _Socket *pOSSock, int noblock )
{
	struct _Socket *pOSNewSock;
	A_INT32		i;
	A_INT32		sfd;
	struct sockaddr_in	sin;
	int         oldfl;

    //    uiPrintf("SNOOP:: SocketAccept called\n");
	
   	i = sizeof(sin);
   	
   	oldfl = fcntl(pOSSock->sockfd, F_GETFL); 
	if(noblock==1) {
	    if (!(oldfl & O_NONBLOCK))
	        fcntl(pOSSock->sockfd, F_SETFL, oldfl | O_NONBLOCK);
	}
	else {
	    if (oldfl & O_NONBLOCK)
            fcntl(pOSSock->sockfd, F_SETFL, oldfl & ~O_NONBLOCK);	    
	}
	
   	sfd = accept(pOSSock->sockfd, (struct sockaddr *) &sin, (socklen_t *)&i);


   	if (sfd == -1) {
		if(errno == EWOULDBLOCK) {

			return NULL;
		} else {

			uiPrintf( "ERROR::accept failed: %s\n", strerror(errno));
			return NULL;
		}
	}

	pOSNewSock = (struct _Socket *) malloc(sizeof(*pOSNewSock));
	if (!pOSNewSock) {
		uiPrintf("ERROR:: SocketAccept: malloc failed for pOSNewSock \n");
		return NULL;
	}
  
  	strcpy(pOSNewSock->hostname, inet_ntoa(sin.sin_addr));
	pOSNewSock->port_num = sin.sin_port;

	pOSNewSock->sockDisconnect = 0;
	pOSNewSock->sockClose = 0;
	pOSNewSock->sockfd = sfd;
    pOSNewSock->nbuffer = 0;

	return pOSNewSock;
}
示例#8
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
/**************************************************************************
* hwCfgRead32 - read an 32 bit value
*
* This routine will call into the driver
* 32 bit PCI configuration read.
*
* RETURNS: the value read
*/
A_UINT32 hwCfgRead32
(
	A_UINT16 devIndex,
	A_UINT32 offset                    /* the address to read from */
)
{
	struct cfg_op co;
	A_UINT32 data;
	MDK_WLAN_DEV_INFO    *pdevInfo;

	pdevInfo =globDrvInfo.pDevInfoArray[devIndex] ;

	co.offset=offset;
	co.size = 4;
	co.value = 0;
#ifdef OWL_PB42
        if(!isHowlAP(devIndex)){
	  if (ioctl(pdevInfo->hDevice,DK_IOCTL_CFG_READ,&co) < 0) {
		uiPrintf("Error::PCI Config read32 failed::co.value=%x\n", co.value);
		data = 0xdeadbeef;
	  } else { 
		data = co.value;
	 } 
         return data;
        }
        else{//howlAP
           if(offset==0){
            return 0xa027168c;// hwDevID; it will be right shifted by 16
           }
           if(offset==0x2c){
             return 0xa0810000;// subsystemID
           }
           if(offset==0x2e){
             return 0xa0810000;// subsystemID
           }      
        }
#else 
          // For OB42 and AP71 platforms
	  if (ioctl(pdevInfo->hDevice,DK_IOCTL_CFG_READ,&co) < 0) {
		uiPrintf("Error::PCI Config read32 failed::co.value=%x\n", co.value);
		data = 0xdeadbeef;
	  } else { 
		data = co.value;
	 } 
         return data;

#endif
       return 1; // will not take this return anyway

}
示例#9
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
A_UINT32 hwSysRegRead
(
        A_UINT16 devIndex,
        A_UINT32 offset                    /* the address to read from */
)
{
        struct cfg_op co;
        A_UINT32 data;
        MDK_WLAN_DEV_INFO    *pdevInfo;
        pdevInfo =globDrvInfo.pDevInfoArray[devIndex] ;
 
        co.offset=offset;
        co.size = 4;
        co.value = 0;
 
	// if(isHowlAP(devIndex))
        {
        	if (ioctl(pdevInfo->hDevice,DK_IOCTL_SYS_REG_READ_32,&co) < 0) {
 	                uiPrintf("Error::RTC Reg read failed::co.value=%x\n", co.value);
        	        data = 0xdeadbeef;
         	} else {
                	data = co.value;
         	}

         	return data;
        }

        return 1;
}
/* verify_trustzone("TZ_VERSION", "TZ_VERSION", ...) */
Value * VerifyTrustZoneFn(const char *name, State *state, int argc, Expr *argv[]) {
    char current_tz_version[TZ_VER_BUF_LEN];
    int i, ret;

    ret = get_tz_version(current_tz_version, TZ_VER_BUF_LEN);
    if (ret) {
        return ErrorAbort(state, "%s() failed to read current TZ version: %d",
                          name, ret);
    }

    char** tz_version = ReadVarArgs(state, argc, argv);
    if (tz_version == NULL) {
        return ErrorAbort(state, "%s() error parsing arguments", name);
    }

    ret = 0;
    for (i = 0; i < argc; i++) {
        uiPrintf(state, "Comparing TZ version %s to %s",
                 tz_version[i], current_tz_version);
        if (strncmp(tz_version[i], current_tz_version, strlen(tz_version[i])) == 0) {
            ret = 1;
            break;
        }
    }

    for (i = 0; i < argc; i++) {
        free(tz_version[i]);
    }
    free(tz_version);

    return StringValue(strdup(ret ? "1" : "0"));
}
示例#11
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
A_INT16 hwCreateEvent
(
	A_UINT16 devIndex,
	PIPE_CMD *pCmd
)
{
	struct event_op event;
	MDK_WLAN_DEV_INFO    *pdevInfo;

		pdevInfo = globDrvInfo.pDevInfoArray[devIndex];

		event.valid = 1;
		event.param[0] = pCmd->CMD_U.CREATE_EVENT_CMD.type;
		event.param[1] = pCmd->CMD_U.CREATE_EVENT_CMD.persistent;
		event.param[2] = pCmd->CMD_U.CREATE_EVENT_CMD.param1;
		event.param[3] = pCmd->CMD_U.CREATE_EVENT_CMD.param2;
		event.param[4] = pCmd->CMD_U.CREATE_EVENT_CMD.param3;
		event.param[5] = (pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.f2Handle << 16) | pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.eventID;

		if (ioctl(pdevInfo->hDevice,DK_IOCTL_CREATE_EVENT,&event) < 0) {
			uiPrintf("Error:Create Event failed \n");
			return -1;
		}

	   return(0);
}
示例#12
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
A_STATUS get_version_info(HANDLE hDevice, PDRV_VERSION_INFO pDrvVer) {
        A_UINT32 version;

	if (ioctl(hDevice,DK_IOCTL_GET_VERSION,&version) < 0) {
        uiPrintf("Error: get version ioctl failed !\n");
        return(A_ERROR);
	}

    pDrvVer->minorVersion = version & 0xffff;
    pDrvVer->majorVersion = (version>>16) & 0xffff;
    if (pDrvVer->majorVersion != DRV_MAJOR_VERSION) {
		uiPrintf("Error: Driver (%d) and application (%d) version mismatch \n");
        return(A_ERROR);
	}
    return A_OK;
}
示例#13
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
unsigned long FullAddrRead(unsigned long address)
//unsigned long FullAddrRead()
{
        struct cfg_op co;
        A_UINT32 data;
        MDK_WLAN_DEV_INFO    *pdevInfo;
//unsigned int address;
        pdevInfo = globDrvInfo.pDevInfoArray[0];

        co.offset=address;
        co.size = 1;
        co.value = 0;

           if (ioctl(pdevInfo->hDevice,DK_IOCTL_FULL_ADDR_READ,&co) < 0) {
                  uiPrintf("Error: FullAddrRead read failed \n");
                  data = 0xdeadbeef;
           } else {
                  data = co.value;
           }


          return data;


}
示例#14
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
void hwSysRegWrite
(
        A_UINT16 devIndex,
        A_UINT32  offset,                    /* the address to write */
        A_UINT32  value                        /* value to write */
)
{
        struct cfg_op co;
        A_UINT32 data;
        MDK_WLAN_DEV_INFO    *pdevInfo;

        pdevInfo =globDrvInfo.pDevInfoArray[devIndex] ;

        co.offset=offset;
        co.size = 4;
        co.value = value;

        //if(isHowlAP(devIndex))
        {
  	        if (ioctl(pdevInfo->hDevice,DK_IOCTL_SYS_REG_WRITE_32,&co) < 0) {
      	      		uiPrintf("Error: SYS reg write failed \n");
	        }
       	}

        return;
}
示例#15
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
/**************************************************************************
* hwCreateEvent - Handle event creation within windows environment
*
* Create an event within windows environment
*
*
* RETURNS: 0 on success, -1 on error
*/
A_INT16 hwCreateEvent
(
	A_UINT16 devIndex,
    A_UINT32 type, 
    A_UINT32 persistent, 
    A_UINT32 param1,
    A_UINT32 param2,
    A_UINT32 param3,
    EVT_HANDLE eventHandle
)
{
    MDK_WLAN_DEV_INFO *pdevInfo;
	A_BOOL status; 
	struct event_op event;

	    pdevInfo = globDrvInfo.pDevInfoArray[devIndex];

		event.valid = 1;
		event.param[0] = type;
		event.param[1] = persistent;
		event.param[2] = param1;
		event.param[3] = param2;
		event.param[4] = param3;
		event.param[5] = (eventHandle.f2Handle << 16) | eventHandle.eventID;

		if (ioctl(pdevInfo->hDevice,DK_IOCTL_CREATE_EVENT,&event) < 0) {
			uiPrintf("Error:Create Event failed \n");
			return -1;
		}

	   return(0);
}
示例#16
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
/**************************************************************************
* hwCfgWrite32 - write a 32 bit value
*
* This routine will call into the driver to activate a
* 32 bit PCI configuration write.
*
* RETURNS: N/A
*/
void hwCfgWrite32
(
	A_UINT16 devIndex,
	A_UINT32  offset,                    /* the address to write */
	A_UINT32  value                        /* value to write */
)
{
	struct cfg_op co;
	A_UINT32 data;
	MDK_WLAN_DEV_INFO    *pdevInfo;

	pdevInfo =globDrvInfo.pDevInfoArray[devIndex] ;

	co.offset=offset;
	co.size = 4;
	co.value = value;

#ifdef OWL_PB42	
       if(!isHowlAP(devIndex)){
#endif
	if (ioctl(pdevInfo->hDevice,DK_IOCTL_CFG_WRITE,&co) < 0) {
		uiPrintf("Error: PCI Config write failed \n");
	}
#ifdef OWL_PB42	 
       }	
#endif
	return;
}
示例#17
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
/**************************************************************************
* hwCfgRead16 - read a 16 bit value
*
* This routine will call into the driver to activate a 16 bit PCI configuration 
* read cycle.
*
* RETURNS: the value read
*/
A_UINT16 hwCfgRead16
(
	A_UINT16 devIndex,
	A_UINT32 address                    /* the address to read from */
)
{
	struct cfg_op co;
	A_UINT32 data;
	A_UINT16 out;
	MDK_WLAN_DEV_INFO    *pdevInfo;

	pdevInfo = globDrvInfo.pDevInfoArray[devIndex];

	address = address & 0xfffffffe;
	co.offset=address;
	co.size = 2;
	co.value = 0;

#ifdef OWL_PB42
       if(!isHowlAP(devIndex)){
#endif
	    if (ioctl(pdevInfo->hDevice,DK_IOCTL_CFG_READ,&co) < 0) {
	        	uiPrintf("Error: PCI Config read failed \n");
		        data = 0xdeadbeef;
	    } else { 
	        	data = co.value;
	    } 
        	        out = (A_UINT16)(data & 0x0000ffff);
 
            return out;
#ifdef OWL_PB42
      }
#endif
}
示例#18
0
int socketListen (struct _Socket *pOSSock)
{
	A_INT32     sockfd;
	A_INT32     res;
	struct sockaddr_in  sin;
	A_INT32     i;
	A_INT32     j;

	sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (sockfd == -1) {
          uiPrintf( "ERROR::socket failed: %s\n", strerror(errno));
          return -1;
	}

	// Allow immediate reuse of port
	i = 1;
	j = sizeof(i);
	res = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (A_INT8 *)&i, j);
	if (res == -1) {
		uiPrintf( "ERROR::setsockopt failed: %s\n", strerror(errno));
		return -1;
	}

	i = 1;
	j = sizeof(i);
	res = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (A_INT8 *)&i, j);
	if (res == -1) {
		uiPrintf( "ERROR::setsockopt failed: %s\n", strerror(errno));
		return -1;
	}

	sin.sin_family = AF_INET;
	sin.sin_addr.s_addr =  INADDR_ANY;
	sin.sin_port = htons(pOSSock->port_num);
	res = bind(sockfd, (struct sockaddr *) &sin, sizeof(sin)); 
	if (res == -1) { 
		uiPrintf( "ERROR::bind failed: %s\n", strerror(errno)); 
		return -1; 
	}
	res = listen(sockfd, 4);
	if (res == -1) { 
		uiPrintf( "ERROR::listen failed: %s\n", strerror(errno)); 
		return -1; 
	} 
						
	return sockfd;
}
示例#19
0
int lprInit(JOBDEF* pjd)
{
	char *p;
	char spoolFileName[50];				/* temporary */

	memset(pjd, 0, sizeof(JOBDEF));		/* set to known state */
	pjd->optFormat[0] = 'l';			/* binary is default */
	pjd->optFormat[1] = 'd';			/* 'd' for data file */
	

	if ( (p = getenv("TCPWND")) != NULL ) tcpBuffSize = atoi(p);

/* user name on local host AND on remote host (for *nix systems mandatory) */
	pjd->userName = getvstr("USERNAME");
	if (pjd->userName[0] == '0'
	||  pjd->userName[0] == '1' && pjd->userName[1] == '\0') {
		uiPrintf(uiH, uiPrERR, "USERNAME missing in default.cfg");
		return -1;
	}

/* local host */
	pjd->hostName = getvstr("HOSTNAME");
	if (pjd->hostName[0] == '0'
	||  pjd->hostName[0] == '1' && pjd->hostName[1] == '\0') {
		uiPrintf(uiH, uiPrERR, "HOSTNAME missing in default.cfg");
		return -1;
	}
	strtok(pjd->hostName,".");		/* chop off domainname */

/* spool file name */
	getSpoolFileName(spoolFileName, pjd->hostName);
	strncpy(pjd->spoolFile, spoolFileName, 8);	/* sorry, no more for TOS */

/* these are the defaults */

/* remote queue name */
	pjd->rmPrinter = DEF_RP;

/* remote host */
	pjd->rmHost = DEF_RM;

/* spool directory */
	pjd->spoolDir = DEF_SD;

	return 0;
}
示例#20
0
void
halDebugPrintTxDesc(WLAN_DEV_INFO *pDev, ATHEROS_DESC *pDesc, A_BOOL verbose)
{
    ASSERT(pDev);
    ASSERT(pDesc);

    /* Display all 6 words of the descriptor */
    if (verbose) {
        uiPrintf(DESC_ADDR        "%08x  ", pDesc->thisPhysPtr);
        uiPrintf(NEXT_DESC        "%08x  ", pDesc->nextPhysPtr);
        uiPrintf(BUFFER_PTR       "%08x\n", pDesc->bufferPhysPtr);
        uiPrintf(ORIG_BUFVIRT_PTR "%p\n",   pDesc->pOrigBufferVirtPtr);
    }

    /* Display the hardware specific stuff */
    pDev->pHwFunc->hwDebugPrintTxDesc(pDev, pDesc, verbose);
}
示例#21
0
static void output(int16 cnId, char *oStr, int oLen)
{
	int16 rc;
	clock_t tQuit = clock() + TIMEOUT * CLK_TCK;	/* time to quit at */

	while ( (rc = TCP_send(cnId, oStr, oLen)) == E_OBUFFULL ) {
		if (clock() > tQuit) {
	        uiPrintf(uiH, uiPrERR, "output timed out");
			return;
		}
		uiYield(uiH, YIELDMS);
	} 

	if (rc != E_NORMAL) {
        uiPrintf(uiH, uiPrERR, "output|%s", get_err_text(rc));
	}

}	/* end output */
示例#22
0
static void output(int16 cnId, char *o_str, int o_len)
{
	int16 rc;
	clock_t to = clock() + TIMEOUT * CLK_TCK;	/* time to quit at */

	/* wait if previous stuff was not yet sent */
	while ( (rc = TCP_send(cnId, o_str, o_len)) == E_OBUFFULL) {
		if (clock() > to) {
			uiPrintf(uiH, uiPrERR, "output: send timed out");
			return;
		}
		uiYield(uiH, YIELDMS);
	} 

	if (rc != E_NORMAL) {
		uiPrintf(uiH, uiPrERR, "output: %s", get_err_text(rc));
	}

}	/* end output */
示例#23
0
static void dispatchSubCmd(int16 cnId, NDB *ndb)
{
	char *pCnt;
	char *pNam;
	char fileNam[9];
	long fileLen;
	char cmd;
	static int havCnt, havDat;

	cmd = ndb->ndata[0];	/* get copies because we are going to throw ndb away */
	pCnt = strtok(ndb->ndata+1, " ");
	pNam = strtok(NULL, "\n");
	strncpy(fileNam, pNam, 8);
	fileNam[8] = '\0';
	fileLen = atol(pCnt);		/* get file length */

	KRfree(ndb->ptr); KRfree(ndb);	/* not needed any more */

	switch (cmd) {
	case '\1':		/* Abort jobs */
		output(cnId, "\1", 1);	/* unimplemented */
		break;

	case '\2':		/* Receive control file */
		output(cnId, "\0", 1);	/* acknowledge */
		dumpFile(cnId, fileNam, fileLen);
		output(cnId, "\0", 1);	/* success */
		havCnt=1;
		if (havDat) {
			printFile(fileNam);
			havDat=0;
			havCnt=0;
		}
		break;

	case '\3':		/* Receive data file */
		output(cnId, "\0", 1);	/* acknowledge */
		dumpFile(cnId, fileNam, fileLen);
		output(cnId, "\0", 1);	/* success */
		havDat=1;
		if (havCnt) {
			printFile(fileNam);
			havDat=0;
			havCnt=0;
		}
		break;

	default:
		output(cnId, "\1", 1);		/* error */
        uiPrintf(uiH, uiPrERR, "dispatchSubCmd|funny deamon rec subcmd");
		break;
	}


}	/* dispatchSubCmd */
示例#24
0
A_STATUS
halAttach(WLAN_DEV_INFO *pDev)
{
    A_STATUS      status;
    unsigned int  i;
    A_UINT32      numDeviceIDs;

    ASSERT(pDev);

    halGetDeviceId(pDev);

    /* Find a matching DeviceID attach routine */
    numDeviceIDs = (sizeof(ar5kAttachData)/sizeof(DEVICE_ATTACH_DATA));
    for (i = 0; i < numDeviceIDs; i++) {
        if (pDev->pciInfo.DeviceID == ar5kAttachData[i].deviceID) {
            break;
        }
    }
    if (i == numDeviceIDs) {
        uiPrintf("halAttach: Failed to find an attachable driver for devid 0x%04X\n", pDev->pciInfo.DeviceID);
        return A_DEVICE_NOT_FOUND;
    }

    pDev->pHalInfo = (HAL_INFO *) A_DRIVER_MALLOC(sizeof(*pDev->pHalInfo));
    if (pDev->pHalInfo == NULL) {
        uiPrintf("halAttach: Error allocating memory for info struct\n");
        return A_ERROR;
    }
    A_MEM_ZERO(pDev->pHalInfo, sizeof(HAL_INFO));

    /* Call the device specific attach function */
    status = ar5kAttachData[i].hwAttach(pDev, pDev->pciInfo.DeviceID);

    /* If unsuccessful, free any allocated memory */
    if (status != A_OK) {
        A_DRIVER_FREE(pDev->pHalInfo, sizeof(HAL_INFO));
        pDev->pHalInfo = NULL;
    }

    return status;
}
示例#25
0
文件: cli.c 项目: jhbsz/cpe
int tokenPopNum(CLI * pCli, A_UINT32 * pV, int base)
{
    char *p;
    char *pEnd;

    pCli->tokenLvl++;
    p = tokenPop(pCli);
    if (p)
    {
        CLIDEBUG(("p: %s, len: %d\n", p, strlen(p)));
        *pV = strtoul(p, &pEnd, base);
        if (p == pEnd || *pEnd)
        {
            uiPrintf("Invalid input\n");
            return CLI_PARSE_ERROR;
        }
        return CLI_PARSE_OK;
    }

    uiPrintf("Error -- No value specified\n");
    return CLI_PARSE_ERROR;
}
示例#26
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
void sig_hDevicer
(
 	int arg
) 
{
		uiPrintf("Received SIGINT !! cleanup and close down ! \n");
#ifndef ART_BUILD
#ifndef SOC_LINUX
       dkPerlCleanup();
#endif
#endif
		envCleanup(TRUE);
		exit(0);
}
示例#27
0
/**************************************************************************
* uiWriteToLog - write a string to the log file
*
* A user interface command which writes a string to the log file
*
* RETURNS: 1 if sucessful, 0 if not
*/
A_UINT16 uiWriteToLog
(
	char *string
)
{
	if(logFile == NULL) {
		uiPrintf("Error, logfile not valid, unable to write to file\n");
		return 0;
	}

	/* write string to file */
	fprintf(logFile, string);
	return 1;
}
示例#28
0
static int16 getResponse(int16 cnId)
{
	char response[RESPONSESIZE];
	int16 nInQueue;
	int16 rc;
	clock_t to = clock() + TIMEOUT * CLK_TCK;	/* time to quit at */

	/* poll for input */
	while ( (nInQueue = CNbyte_count(cnId)) <= 0 ) {
		if (clock() > to) {
			uiPrintf(uiH, uiPrERR, "get timed out");
			return -1;
		}
		uiYield(uiH, YIELDMS);
	} 

	rc = CNget_block(cnId, response, min(nInQueue, RESPONSESIZE) );
	if (rc != min(nInQueue, RESPONSESIZE)) {
		uiPrintf(uiH, uiPrERR, "get failed");
		return -1;
	}

	return response[0];
}	/* getResponse */
示例#29
0
struct _Socket *SocketListen ( unsigned int port )
{
    struct _Socket *pOSSock; 
    
    pOSSock = (struct _Socket *) malloc(sizeof(*pOSSock));
    if (!pOSSock) {
            uiPrintf("ERROR::osSockListen: malloc failed for pOSSock \n");
            return NULL; 
    }

    pOSSock->port_num = port;
    pOSSock->sockDisconnect = 0;
    pOSSock->sockClose = 0;

    pOSSock->sockfd = socketListen(pOSSock);
    if (pOSSock->sockfd == -1) {
        uiPrintf("ERROR::Socket create failed \n");
        free(pOSSock);
        return NULL;
    }
    pOSSock->nbuffer=0;
    
    return pOSSock;
}
示例#30
0
文件: linux_hw.c 项目: KHATEEBNSIT/AP
void close_device(MDK_WLAN_DEV_INFO *pdevInfo) {
    A_UINT32 iIndex;

        //printf("Closing handle = %x \n",pdevInfo->hDevice);
 //   uiPrintf("close_device::regrange=%x:reg vir addr=%x\n", pdevInfo->pdkInfo->regMapRange, pdevInfo->pdkInfo->regVirAddr);
  //  uiPrintf("close_device::memsize=%x:mem vir addr=%x\n", pdevInfo->pdkInfo->memSize, pdevInfo->pdkInfo->memVirAddr);
        
		 //printf("hD=%d:minVer=%d\n", pdevInfo->hDevice, driverVer.minorVersion);
      if (pdevInfo->hDevice>0)  {
         if (driverVer.minorVersion >= 2) {
            for(iIndex=0; iIndex<pdevInfo->pdkInfo->numBars; iIndex++) {
	          if (munmap((void *)pdevInfo->pdkInfo->aregVirAddr[iIndex], pdevInfo->pdkInfo->aregRange[iIndex]) == -1)
                 uiPrintf("Error: munmap to address %x:range=%x: failed with error %s\n", pdevInfo->pdkInfo->aregVirAddr[iIndex],  pdevInfo->pdkInfo->aregRange[iIndex], strerror(errno));
            }
         }
         else {
	       if (munmap((void *)pdevInfo->pdkInfo->regVirAddr, pdevInfo->pdkInfo->regMapRange) == -1)
              uiPrintf("Error: munmap to address %x:range=%x: failed with error %s\n", pdevInfo->pdkInfo->regVirAddr,  pdevInfo->pdkInfo->regMapRange, strerror(errno));
         }
	     if (munmap((void *)pdevInfo->pdkInfo->memVirAddr, pdevInfo->pdkInfo->memSize) == -1)
              uiPrintf("Error: munmap to address %x:range=%x: failed with error %s\n", pdevInfo->pdkInfo->memVirAddr,  pdevInfo->pdkInfo->memSize, strerror(errno));
         close(pdevInfo->hDevice);
      }
}