1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/*
* Copyright (C) 2006-2007 by CERN
* All rights reserved
*/
#ifndef lint
static char sccsid[] = "@(#)$RCSfile: srmv2_discovreq.c,v $ $Revision: 1.3 $ $Date: 2008/01/10 08:28:00 $ CERN Jean-Philippe Baud";
#endif /* not lint */
#include <sys/types.h>
#include "Cnetdb.h"
#include "dpm.h"
#include "dpm_server.h"
#include "patchlevel.h"
#include "srm_server.h"
#include "srmv2H.h"
extern int nb_supported_protocols;
extern char **supported_protocols;
static int na_key = -1;
int
ns1__srmGetTransferProtocols (struct soap *soap, struct ns1__srmGetTransferProtocolsRequest *req, struct ns1__srmGetTransferProtocolsResponse_ *rep)
{
char clientdn[256];
const char *clienthost;
char func[21];
int i;
struct ns1__srmGetTransferProtocolsResponse *repp;
struct srm_srv_thread_info *thip = soap->user;
strcpy (func, "GetTransferProtocols");
get_client_dn (soap, clientdn, sizeof(clientdn));
clienthost = Cgetnetaddress (-1, &soap->peer, soap->peerlen, &na_key, NULL, NULL, 0, 0);
if (!clienthost) clienthost = "(unknown)";
srmlogit (func, "request by %s from %s\n", clientdn, clienthost);
if (! req) {
soap_sender_fault (soap, "NULL request", NULL);
RETURN (SOAP_FAULT);
}
/* Allocate the reply structure */
if ((repp = soap_malloc (soap, sizeof(struct ns1__srmGetTransferProtocolsResponse))) == NULL ||
(repp->returnStatus = soap_malloc (soap, sizeof(struct ns1__TReturnStatus))) == NULL ||
(repp->protocolInfo = soap_malloc (soap, sizeof(struct ns1__ArrayOfTSupportedTransferProtocol))) == NULL ||
(repp->protocolInfo->protocolArray =
soap_malloc (soap, nb_supported_protocols * sizeof(struct ns1__TSupportedTransferProtocol *))) == NULL) {
RETURN (SOAP_EOM);
}
repp->returnStatus->explanation = NULL;
repp->protocolInfo->__sizeprotocolArray = nb_supported_protocols;
rep->srmGetTransferProtocolsResponse = repp;
for (i = 0; i < nb_supported_protocols; i++) {
if ((repp->protocolInfo->protocolArray[i] =
soap_malloc (soap, sizeof(struct ns1__TSupportedTransferProtocol))) == NULL ||
(repp->protocolInfo->protocolArray[i]->transferProtocol =
soap_strdup (soap, supported_protocols[i])) == NULL)
RETURN (SOAP_EOM);
repp->protocolInfo->protocolArray[i]->attributes = NULL;
}
repp->returnStatus->statusCode = SRM_USCORESUCCESS;
RETURN (SOAP_OK);
}
int
ns1__srmPing (struct soap *soap, struct ns1__srmPingRequest *req, struct ns1__srmPingResponse_ *rep)
{
char clientdn[256];
const char *clienthost;
char func[16];
char info[256];
struct ns1__srmPingResponse *repp;
struct srm_srv_thread_info *thip = soap->user;
strcpy (func, "Ping");
get_client_dn (soap, clientdn, sizeof(clientdn));
clienthost = Cgetnetaddress (-1, &soap->peer, soap->peerlen, &na_key, NULL, NULL, 0, 0);
if (!clienthost) clienthost = "(unknown)";
srmlogit (func, "request by %s from %s\n", clientdn, clienthost);
if (! req) {
soap_sender_fault (soap, "NULL request", NULL);
RETURN (SOAP_FAULT);
}
/* Allocate the reply structure */
if ((repp = soap_malloc (soap, sizeof(struct ns1__srmPingResponse))) == NULL ||
(repp->versionInfo = soap_strdup (soap, "v2.2")) == NULL) {
RETURN (SOAP_EOM);
}
if ((repp->otherInfo = soap_malloc (soap, sizeof(struct ns1__ArrayOfTExtraInfo))) == NULL ||
(repp->otherInfo->extraInfoArray =
soap_malloc (soap, 2 * sizeof(struct ns1__TExtraInfo *))) == NULL)
repp->otherInfo = NULL;
else {
repp->otherInfo->__sizeextraInfoArray = 2;
sprintf (info, "%s-%d", BASEVERSION, PATCHLEVEL);
if ((repp->otherInfo->extraInfoArray[0] =
soap_malloc (soap, sizeof(struct ns1__TExtraInfo))) == NULL ||
(repp->otherInfo->extraInfoArray[0]->key =
soap_strdup (soap, "backend_type")) == NULL ||
(repp->otherInfo->extraInfoArray[0]->value =
soap_strdup (soap, "DPM")) == NULL ||
(repp->otherInfo->extraInfoArray[1] =
soap_malloc (soap, sizeof(struct ns1__TExtraInfo))) == NULL ||
(repp->otherInfo->extraInfoArray[1]->key =
soap_strdup (soap, "backend_version")) == NULL ||
(repp->otherInfo->extraInfoArray[1]->value =
soap_strdup (soap, info)) == NULL)
repp->otherInfo = NULL;
}
rep->srmPingResponse = repp;
RETURN (SOAP_OK);
}
|