src/stored/dircmd.c
static bool client_cmd(JCR *jcr)
{
   int client_port;                 /* client port */
   int enable_ssl;                 /* enable ssl */
   BSOCK *dir = jcr->dir_bsock;
   BSOCK *cl = new_bsock();        /* client bsock */

   Dmsg1(100, "ClientCmd: %s", dir->msg);
   jcr->sd_calls_client = true;
   if (sscanf(dir->msg, "client address=%s port=%d ssl=%d", &jcr->client_addr, &client_port,
              &enable_ssl) != 3) {
      pm_strcpy(jcr->errmsg, dir->msg);
      Jmsg(jcr, M_FATAL, 0, _("[SF0101] Bad client command: %s"), jcr->errmsg);
      Dmsg1(050, "Bad client command: %s", jcr->errmsg);
      goto bail_out;
   }

   Dmsg3(110, "Connect to client: %s:%d ssl=%d\n", jcr->client_addr, client_port,
         enable_ssl);
   /* Open command communications with Client */
   /* Try to connect for 1 hour at 10 second intervals */
   if (!cl->connect(jcr, 10, (int)me->ClientConnectTimeout, me->heartbeat_interval,
                _("Client daemon"), jcr->client_addr, NULL, client_port, 1)) {
      /* destroy() OK because cl is local */
      cl->destroy();
      Jmsg(jcr, M_FATAL, 0, _("[SF0102] Failed to connect to Client daemon: %s:%d\n"),
          jcr->client_addr, client_port);
      Dmsg2(100, "Failed to connect to Client daemon: %s:%d\n",
          jcr->client_addr, client_port);
      goto bail_out;
   }
   Dmsg0(110, "SD connection OK to Client.\n");

   jcr->file_bsock = cl;
   jcr->file_bsock->set_jcr(jcr);
   if (!send_hello_client(jcr, jcr->Job)) {
      goto bail_out;
   }

   /* Send OK to Director */
   return dir->fsend(OKclient);

bail_out:
   jcr->setJobStatus(JS_ErrorTerminated);
   dir->fsend("3902 Bad %s cmd\n", "client");
   return 0;
}
/*
 * Get address of client from Director
 *   This initiates SD Calls Client.
 *   We attempt to connect to the client (an FD or SD) and
 *   authenticate it.
 */
Get address of client from Director
This initiates SD Calls Client.
We attempt to connect to the client (an FD or SD) and
authenticate it.
Get address of client from Director This initiates SD Calls Client . We attempt to connect to the client ( an FD or SD ) and authenticate it .
static bool client_cmd(JCR *jcr)
{
   int client_port;                 
   int enable_ssl;                 
   BSOCK *dir = jcr->dir_bsock;
   BSOCK *cl = new_bsock();        
   Dmsg1(100, "ClientCmd: %s", dir->msg);
   jcr->sd_calls_client = true;
   if (sscanf(dir->msg, "client address=%s port=%d ssl=%d", &jcr->client_addr, &client_port,
              &enable_ssl) != 3) {
      pm_strcpy(jcr->errmsg, dir->msg);
      Jmsg(jcr, M_FATAL, 0, _("[SF0101] Bad client command: %s"), jcr->errmsg);
      Dmsg1(050, "Bad client command: %s", jcr->errmsg);
      goto bail_out;
   }
   Dmsg3(110, "Connect to client: %s:%d ssl=%d\n", jcr->client_addr, client_port,
         enable_ssl);
   if (!cl->connect(jcr, 10, (int)me->ClientConnectTimeout, me->heartbeat_interval,
                _("Client daemon"), jcr->client_addr, NULL, client_port, 1)) {
      cl->destroy();
      Jmsg(jcr, M_FATAL, 0, _("[SF0102] Failed to connect to Client daemon: %s:%d\n"),
          jcr->client_addr, client_port);
      Dmsg2(100, "Failed to connect to Client daemon: %s:%d\n",
          jcr->client_addr, client_port);
      goto bail_out;
   }
   Dmsg0(110, "SD connection OK to Client.\n");
   jcr->file_bsock = cl;
   jcr->file_bsock->set_jcr(jcr);
   if (!send_hello_client(jcr, jcr->Job)) {
      goto bail_out;
   }
   return dir->fsend(OKclient);
bail_out:
   jcr->setJobStatus(JS_ErrorTerminated);
   dir->fsend("3902 Bad %s cmd\n", "client");
   return 0;
}
static bool client_cmd ( JCR * jcr ) { int client_port ; int enable_ssl ; BSOCK * dir = jcr -> dir_bsock ; BSOCK * cl = new_bsock ( ) ; Dmsg1 ( 100 , " " , dir -> msg ) ; jcr -> sd_calls_client = true ; if ( sscanf ( dir -> msg , " " , & jcr -> client_addr , & client_port , & enable_ssl ) != 3 ) { pm_strcpy ( jcr -> errmsg , dir -> msg ) ; Jmsg ( jcr , M_FATAL , 0 , _ ( " " ) , jcr -> errmsg ) ; Dmsg1 ( 050 , " " , jcr -> errmsg ) ; goto bail_out ; } Dmsg3 ( 110 , " \n " , jcr -> client_addr , client_port , enable_ssl ) ; if ( ! cl -> connect ( jcr , 10 , ( int ) me -> ClientConnectTimeout , me -> heartbeat_interval , _ ( " " ) , jcr -> client_addr , NULL , client_port , 1 ) ) { cl -> destroy ( ) ; Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) , jcr -> client_addr , client_port ) ; Dmsg2 ( 100 , " \n " , jcr -> client_addr , client_port ) ; goto bail_out ; } Dmsg0 ( 110 , " \n " ) ; jcr -> file_bsock = cl ; jcr -> file_bsock -> set_jcr ( jcr ) ; if ( ! send_hello_client ( jcr , jcr -> Job ) ) { goto bail_out ; } return dir -> fsend ( OKclient ) ; bail_out : jcr -> setJobStatus ( JS_ErrorTerminated ) ; dir -> fsend ( " \n " , " " ) ; return 0 ; }
Get address of client from Director
   This initiates SD Calls Client.
Get address of client from Director This initiates SD Calls Client .
/* client port */ /* enable ssl */ /* client bsock */ /* Open command communications with Client */ /* Try to connect for 1 hour at 10 second intervals */ /* destroy() OK because cl is local */ /* Send OK to Director */