+bool send_store_addr_to_fd(JCR *jcr, STORE *store,
+ char *store_address, uint32_t store_port)
+{
+ int tls_need = BNET_TLS_NONE;
+
+ /* TLS Requirement */
+ if (store->tls_enable) {
+ if (store->tls_require) {
+ tls_need = BNET_TLS_REQUIRED;
+ } else {
+ tls_need = BNET_TLS_OK;
+ }
+ }
+
+ /*
+ * Send Storage address to the FD
+ */
+ jcr->file_bsock->fsend(storaddr, store_address, store_port, tls_need);
+ if (!response(jcr, jcr->file_bsock, OKstore, "Storage", DISPLAY_ERROR)) {
+ return false;
+ }
+ return true;
+}
+
+bool send_client_addr_to_sd(JCR *jcr)
+{
+ int tls_need = BNET_TLS_NONE;
+ BSOCK *sd = jcr->store_bsock;
+
+ /* TLS Requirement for the client */
+ if (jcr->client->tls_enable) {
+ if (jcr->client->tls_require) {
+ tls_need = BNET_TLS_REQUIRED;
+ } else {
+ tls_need = BNET_TLS_OK;
+ }
+ }
+ /*
+ * Send Client address to the SD
+ */
+ sd->fsend(clientaddr, jcr->client->address(), jcr->client->FDport, tls_need);
+ if (!response(jcr, sd, OKclient, "Client", DISPLAY_ERROR)) {
+ return false;
+ }
+ return true;
+}
+
+/*
+ * Allow to specify the address used by the Client to
+ * connect to the storage daemon in the Client resource
+ * or in the Storage resource.
+ */
+char *get_storage_address(CLIENT *client, STORE *store)
+{
+ char *store_address;
+
+ if (client && client->fd_storage_address) {
+ Dmsg0(10, "Using Client resource FD Storage Address to contact the Storage\n");
+ store_address = client->fd_storage_address;
+
+ } else if (store->fd_storage_address) {
+ Dmsg0(10, "Using Storage resource FD Storage Address to contact the Storage\n");
+ store_address = store->fd_storage_address;
+
+ } else {
+ Dmsg0(10, "Using default Storage address\n");
+ store_address = store->address;
+ }
+ return store_address;
+}
+
+bool run_storage_and_start_message_thread(JCR *jcr, BSOCK *sd)
+{
+ /*
+ * Start the job prior to starting the message thread below
+ * to avoid two threads from using the BSOCK structure at
+ * the same time.
+ */
+ if (!sd->fsend("run")) {
+ return false;
+ }