kernels/linux-2.4.0/net/irda/irnet/irnet_irda.c
/*------------------------------------------------------------------*/
/*
 * Function irnet_find_lsap_sel (self)
 *
 *    Try to lookup LSAP selector in remote LM-IAS
 *
 * Basically, we start a IAP query, and then go to sleep. When the query
 * return, irnet_getvalue_confirm will wake us up, and we can examine the
 * result of the query...
 * Note that in some case, the query fail even before we go to sleep,
 * creating some races...
 */
Function irnet_find_lsap_sel (self)
Try to lookup LSAP selector in remote LM-IAS

Basically, we start a IAP query, and then go to sleep. When the query
return, irnet_getvalue_confirm will wake us up, and we can examine the
result of the query
Note that in some case, the query fail even before we go to sleep,
creating some races
Function irnet_find_lsap_sel ( self ) Try to lookup LSAP selector in remote LM - IAS Basically we start a IAP query and then go to sleep . When the query return irnet_getvalue_confirm will wake us up and we can examine the result of the query Note that in some case the query fail even before we go to sleep creating some races
static int
irnet_find_lsap_sel(irnet_socket *	self)
{
  DENTER(IRDA_SR_TRACE, "(self=0x%X)\n", (unsigned int) self);
  DABORT(self->iriap, -EBUSY, IRDA_SR_ERROR, "busy with a previous query.\n");
  self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
			   irnet_getvalue_confirm);
  self->errno = -EHOSTUNREACH;
  iriap_getvaluebyclass_request(self->iriap, self->saddr, self->daddr,
				IRNET_SERVICE_NAME, IRNET_IAS_VALUE);
  if(self->iriap != NULL)
    interruptible_sleep_on(&self->query_wait);
  if(self->errno)
    {
      DEBUG(IRDA_SR_INFO, "IAS query failed! (%d)\n", self->errno);
      if((self->errno == IAS_CLASS_UNKNOWN) ||
	 (self->errno == IAS_ATTRIB_UNKNOWN))
	return (-EADDRNOTAVAIL);
      else
	return (-EHOSTUNREACH);
    }
  switch(self->ias_result->type)
    {
    case IAS_INTEGER:
      DEBUG(IRDA_SR_INFO, "result=%d\n", self->ias_result->t.integer);
      if(self->ias_result->t.integer != -1)
	self->dtsap_sel = self->ias_result->t.integer;
      else 
	self->dtsap_sel = 0;
      break;
    default:
      self->dtsap_sel = 0;
      DERROR(IRDA_SR_ERROR, "bad type ! (0x%X)\n", self->ias_result->type);
      break;
    }
  if(self->ias_result)
    irias_delete_value(self->ias_result);
  DEXIT(IRDA_SR_TRACE, "\n");
  if(self->dtsap_sel)
    return 0;
  return -EADDRNOTAVAIL;
}
static int irnet_find_lsap_sel ( irnet_socket * self ) { DENTER ( IRDA_SR_TRACE , " \n " , ( unsigned int ) self ) ; DABORT ( self -> iriap , - EBUSY , IRDA_SR_ERROR , " \n " ) ; self -> iriap = iriap_open ( LSAP_ANY , IAS_CLIENT , self , irnet_getvalue_confirm ) ; self -> errno = - EHOSTUNREACH ; iriap_getvaluebyclass_request ( self -> iriap , self -> saddr , self -> daddr , IRNET_SERVICE_NAME , IRNET_IAS_VALUE ) ; if ( self -> iriap != NULL ) interruptible_sleep_on ( & self -> query_wait ) ; if ( self -> errno ) { DEBUG ( IRDA_SR_INFO , " \n " , self -> errno ) ; if ( ( self -> errno == IAS_CLASS_UNKNOWN ) || ( self -> errno == IAS_ATTRIB_UNKNOWN ) ) return ( - EADDRNOTAVAIL ) ; else return ( - EHOSTUNREACH ) ; } switch ( self -> ias_result -> type ) { case IAS_INTEGER : DEBUG ( IRDA_SR_INFO , " \n " , self -> ias_result -> t . integer ) ; if ( self -> ias_result -> t . integer != -1 ) self -> dtsap_sel = self -> ias_result -> t . integer ; else self -> dtsap_sel = 0 ; break ; default : self -> dtsap_sel = 0 ; DERROR ( IRDA_SR_ERROR , " \n " , self -> ias_result -> type ) ; break ; } if ( self -> ias_result ) irias_delete_value ( self -> ias_result ) ; DEXIT ( IRDA_SR_TRACE , " \n " ) ; if ( self -> dtsap_sel ) return 0 ; return - EADDRNOTAVAIL ; }
Function irnet_find_lsap_sel (self)
    Try to lookup LSAP selector in remote LM-IAS
Function irnet_find_lsap_sel ( self ) Try to lookup LSAP selector in remote LM - IAS
/* This should not happen */ /* Create an IAP instance, will be closed in irnet_getvalue_confirm() */ /* Treat unexpected signals as disconnect */ /* Query remote LM-IAS */ /* Wait for answer (if not already failed) */ /* Check what happened */ /* Requested object/attribute doesn't exist */ /* Get the remote TSAP selector */ /* Cleanup */