kernels/linux-2.4.0/net/irda/irnet/irnet_irda.c
/*------------------------------------------------------------------*/
/*
 * Connect to the other side :
 *	o convert device name to an address
 *	o find the socket number (dlsap)
 *	o Establish the connection
 */
Connect to the other side :
o convert device name to an address
o find the socket number (dlsap)
o Establish the connection
Connect to the other side : o convert device name to an address o find the socket number ( dlsap ) o Establish the connection
int
irda_irnet_connect(irnet_socket *	self)
{
  int		err;
  DENTER(IRDA_SOCK_TRACE, "(self=0x%X)\n", (unsigned int) self);
  if(self->tsap != NULL)
    DRETURN(-EBUSY, IRDA_SOCK_INFO, "Already connecting...\n");
  if((irnet_server.running) && (self->q.q_next == NULL))
    {
      unsigned long		flags;
      spin_lock_irqsave(&irnet_server.spinlock, flags);
      hashbin_insert(irnet_server.list, (irda_queue_t *) self, 0, self->rname);
      spin_unlock_irqrestore(&irnet_server.spinlock, flags);
      DEBUG(IRDA_SOCK_INFO, "Inserted ``%s'' in hashbin...\n", self->rname);
    }
  if((self->raddr == DEV_ADDR_ANY) && (self->rname[0] == '\0'))
    {
      if((err = irnet_discover_daddr_and_lsap_sel(self)) != 0) 
	DRETURN(err, IRDA_SOCK_INFO, "auto-connect failed!\n");
    }
  else
    {
      if(self->raddr == DEV_ADDR_ANY)
	{
	  if((err = irnet_dname_to_daddr(self)) != 0)
	    DRETURN(err, IRDA_SOCK_INFO, "name-connect failed!\n");
	}
      else
	self->daddr = self->raddr;
      if((err = irnet_find_lsap_sel(self)) != 0)
	DRETURN(err, IRDA_SOCK_INFO, "connect failed!\n");
    }
  DEBUG(IRDA_SOCK_INFO, "daddr = %08x, lsap = %d, starting IrTTP connection\n",
	self->daddr, self->dtsap_sel);
  err = irnet_open_tsap(self);
  DABORT(err != 0, err, IRDA_SOCK_ERROR, "connect aborted!\n");
  err = irttp_connect_request(self->tsap, self->dtsap_sel, 
			      self->saddr, self->daddr, NULL, 
			      self->max_sdu_size_rx, NULL);
  DABORT(err != 0, err, IRDA_SOCK_ERROR, "connect aborted!\n");
  DEXIT(IRDA_SOCK_TRACE, "\n");
  return(0);
}
int irda_irnet_connect ( irnet_socket * self ) { int err ; DENTER ( IRDA_SOCK_TRACE , " \n " , ( unsigned int ) self ) ; if ( self -> tsap != NULL ) DRETURN ( - EBUSY , IRDA_SOCK_INFO , " \n " ) ; if ( ( irnet_server . running ) && ( self -> q . q_next == NULL ) ) { unsigned long flags ; spin_lock_irqsave ( & irnet_server . spinlock , flags ) ; hashbin_insert ( irnet_server . list , ( irda_queue_t * ) self , 0 , self -> rname ) ; spin_unlock_irqrestore ( & irnet_server . spinlock , flags ) ; DEBUG ( IRDA_SOCK_INFO , " \n " , self -> rname ) ; } if ( ( self -> raddr == DEV_ADDR_ANY ) && ( self -> rname [ 0 ] == ' \0 ' ) ) { if ( ( err = irnet_discover_daddr_and_lsap_sel ( self ) ) != 0 ) DRETURN ( err , IRDA_SOCK_INFO , " \n " ) ; } else { if ( self -> raddr == DEV_ADDR_ANY ) { if ( ( err = irnet_dname_to_daddr ( self ) ) != 0 ) DRETURN ( err , IRDA_SOCK_INFO , " \n " ) ; } else self -> daddr = self -> raddr ; if ( ( err = irnet_find_lsap_sel ( self ) ) != 0 ) DRETURN ( err , IRDA_SOCK_INFO , " \n " ) ; } DEBUG ( IRDA_SOCK_INFO , " \n " , self -> daddr , self -> dtsap_sel ) ; err = irnet_open_tsap ( self ) ; DABORT ( err != 0 , err , IRDA_SOCK_ERROR , " \n " ) ; err = irttp_connect_request ( self -> tsap , self -> dtsap_sel , self -> saddr , self -> daddr , NULL , self -> max_sdu_size_rx , NULL ) ; DABORT ( err != 0 , err , IRDA_SOCK_ERROR , " \n " ) ; DEXIT ( IRDA_SOCK_TRACE , " \n " ) ; return ( 0 ) ; }
Connect to the other side :
      o convert device name to an address
      o find the socket number (dlsap)
      o Establish the connection
Connect to the other side : o convert device name to an address o find the socket number ( dlsap ) o Establish the connection
/* Check if we have opened a local TSAP :
   * If we have already opened a TSAP, it means that either we are already
   * connected or in the process of doing so... */ /* Insert ourselves in the hashbin so that the IrNET server can find us.
   * Notes : 4th arg is string of 32 char max and must be null terminated
   *	     When 4th arg is used (string), 3rd arg isn't (int)
   *	     Can't re-insert (MUST remove first) so check for that... */ /* If we don't have anything (no address, no name) */ /* Try to find a suitable address */ /* If we have only the name (no address), try to get an address */ /* Use the requested destination address */ /* Query remote LM-IAS to find LSAP selector */ /* Open a local TSAP (an IrTTP instance) */ /* Connect to remote device */