lib/libatm/ioctl_subr.c
int
do_info_ioctl(struct atminfreq *req, int buf_len)
{
	int	rc, s;
	caddr_t	buf;

	/*
	 * Open a socket for the IOCTL
	 */
	s = socket(AF_ATM, SOCK_DGRAM, 0);
	if (s < 0) {
		return(-1);
	}

	/*
	 * Get memory for returned information
	 */
mem_retry:
	buf = (caddr_t)UM_ALLOC(buf_len);
	if (buf == NULL) {
		errno = ENOMEM;
		return(-1);
	}

	/*
	 * Set the buffer address and length in the request
	 */
	req->air_buf_addr = buf;
	req->air_buf_len = buf_len;

	/*
	 * Issue the IOCTL
	 */
	rc = ioctl(s, AIOCINFO, (caddr_t)req);
	if (rc) {
		UM_FREE(buf);
		if (errno == ENOSPC) {
			buf_len = buf_len * 2;
			goto mem_retry;
		}
		return(-1);
	}
	(void)close(s);
	/*
	 * Set a pointer to the returned info in the request
	 * and return its length
	 */
	req->air_buf_addr = buf;
	return(req->air_buf_len);
}
/*
 * Issue an informational IOCTL
 * 
 * The user fills out the opcode and any subtype information.  This
 * routine will allocate a buffer and issue the IOCTL.  If the request
 * fails because the buffer wasn't big enough, this routine will double
 * the buffer size and retry the request repeatedly.  The buffer must
 * be freed by the caller.
 * 
 * Arguments:
 *	req	pointer to an ATM information request IOCTL structure
 *	buf_len	length of buffer to be allocated
 *
 * Returns:
 *	-1	error encountered (reason in errno)
 *	int 	length of the returned VCC information
 *
 */
Issue an informational IOCTL

The user fills out the opcode and any subtype information.  This
routine will allocate a buffer and issue the IOCTL.  If the request
fails because the buffer wasn't big enough, this routine will double
the buffer size and retry the request repeatedly.  The buffer must
be freed by the caller.

req     pointer to an ATM information request IOCTL structure
buf_len length of buffer to be allocated

-1      error encountered (reason in errno)
int     length of the returned VCC information
Issue an informational IOCTL The user fills out the opcode and any subtype information . This routine will allocate a buffer and issue the IOCTL . If the request fails because the buffer wasn ' t big enough this routine will double the buffer size and retry the request repeatedly . The buffer must be freed by the caller . req pointer to an ATM information request IOCTL structure buf_len length of buffer to be allocated - 1 error encountered ( reason in errno ) int length of the returned VCC information
int
do_info_ioctl(struct atminfreq *req, int buf_len)
{
	int	rc, s;
	caddr_t	buf;
	s = socket(AF_ATM, SOCK_DGRAM, 0);
	if (s < 0) {
		return(-1);
	}
mem_retry:
	buf = (caddr_t)UM_ALLOC(buf_len);
	if (buf == NULL) {
		errno = ENOMEM;
		return(-1);
	}
	req->air_buf_addr = buf;
	req->air_buf_len = buf_len;
	rc = ioctl(s, AIOCINFO, (caddr_t)req);
	if (rc) {
		UM_FREE(buf);
		if (errno == ENOSPC) {
			buf_len = buf_len * 2;
			goto mem_retry;
		}
		return(-1);
	}
	(void)close(s);
	req->air_buf_addr = buf;
	return(req->air_buf_len);
}
int do_info_ioctl ( struct atminfreq * req , int buf_len ) { int rc , s ; caddr_t buf ; s = socket ( AF_ATM , SOCK_DGRAM , 0 ) ; if ( s < 0 ) { return ( -1 ) ; } mem_retry : buf = ( caddr_t ) UM_ALLOC ( buf_len ) ; if ( buf == NULL ) { errno = ENOMEM ; return ( -1 ) ; } req -> air_buf_addr = buf ; req -> air_buf_len = buf_len ; rc = ioctl ( s , AIOCINFO , ( caddr_t ) req ) ; if ( rc ) { UM_FREE ( buf ) ; if ( errno == ENOSPC ) { buf_len = buf_len * 2 ; goto mem_retry ; } return ( -1 ) ; } ( void ) close ( s ) ; req -> air_buf_addr = buf ; return ( req -> air_buf_len ) ; }
Issue an informational IOCTL
Issue an informational IOCTL
/*
	 * Open a socket for the IOCTL
	 */ /*
	 * Get memory for returned information
	 */ /*
	 * Set the buffer address and length in the request
	 */ /*
	 * Issue the IOCTL
	 */ /*
	 * Set a pointer to the returned info in the request
	 * and return its length
	 */