Parcourir la source

clients accept getendpointsresponse

Julius Pfrommer il y a 11 ans
Parent
commit
da3748ccff
2 fichiers modifiés avec 22 ajouts et 6 suppressions
  1. 11 1
      src/ua_services_discovery.c
  2. 11 5
      src/ua_transport_binary_secure.c

+ 11 - 1
src/ua_services_discovery.c

@@ -11,8 +11,18 @@ UA_Int32 Service_GetEndpoints(SL_Channel *channel, const UA_GetEndpointsRequest*
 	UA_String_copy((UA_String*)&(channel->localAsymAlgSettings.securityPolicyUri),&(response->endpoints[0]->securityPolicyUri));
 	//FIXME hard-coded code
 	response->endpoints[0]->securityMode = UA_MESSAGESECURITYMODE_NONE;
+	UA_String_copycstring("http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary", &response->endpoints[0]->transportProfileUri);
 
-	UA_String_copy(&(channel->tlConnection->localEndpointUrl),&(response->endpoints[0]->endpointUrl));
+	response->endpoints[0]->userIdentityTokensSize = 1;
+	UA_Array_new((void**) &response->endpoints[0]->userIdentityTokens, response->endpoints[0]->userIdentityTokensSize, UA_USERTOKENPOLICY);
+	UA_UserTokenPolicy *token = response->endpoints[0]->userIdentityTokens[0];
+	UA_String_copycstring("my-anonymous-policy", &token->policyId); // defined per server
+	token->tokenType = UA_USERTOKENTYPE_ANONYMOUS;
+	token->issuerEndpointUrl = (UA_String) {-1, UA_NULL};
+	token->issuedTokenType = (UA_String) {-1, UA_NULL};
+	token->securityPolicyUri = (UA_String) {-1, UA_NULL};
+
+	UA_String_copy(&request->endpointUrl,&response->endpoints[0]->endpointUrl);
 	UA_String_copycstring("http://open62541.info/product/release",&(response->endpoints[0]->server.productUri));
 	// FIXME: This information should be provided by the application, preferably in the address space
 	UA_String_copycstring("http://open62541.info/applications/4711",&(response->endpoints[0]->server.applicationUri));

+ 11 - 5
src/ua_transport_binary_secure.c

@@ -23,10 +23,16 @@ static UA_Int32 SL_Send(SL_Channel* channel, const UA_ByteString * responseMessa
 
 	const UA_ByteString *response_gather[2]; // securechannel_header, seq_header, security_encryption_header, message_length (eventually + padding + size_signature);
 	UA_alloc((void **)&response_gather[0], sizeof(UA_ByteString));
-	UA_ByteString_newMembers((UA_ByteString *)response_gather[0], SIZE_SECURECHANNEL_HEADER + SIZE_SEQHEADER_HEADER +
-							 (isAsym ? UA_AsymmetricAlgorithmSecurityHeader_calcSize(&(channel->localAsymAlgSettings)) :
-							  UA_AsymmetricAlgorithmSecurityHeader_calcSize(&(channel->localAsymAlgSettings))) +
-							 UA_NodeId_calcSize(&resp_nodeid));
+	if(isAsym) {
+		UA_ByteString_newMembers((UA_ByteString *)response_gather[0], SIZE_SECURECHANNEL_HEADER + SIZE_SEQHEADER_HEADER +
+								 UA_AsymmetricAlgorithmSecurityHeader_calcSize(&channel->localAsymAlgSettings) +
+								 UA_NodeId_calcSize(&resp_nodeid));
+	}
+	else {
+		UA_ByteString_newMembers((UA_ByteString *)response_gather[0], 8 + 16 + // normal header + 4*32bit secure channel information
+								 UA_NodeId_calcSize(&resp_nodeid));
+	}
+		
 	
 	// sizePadding = 0;
 	// sizeSignature = 0;
@@ -90,7 +96,7 @@ static void init_response_header(UA_RequestHeader const * p, UA_ResponseHeader *
 	UA_##TYPE##Request p; \
 	UA_##TYPE##Response r; \
 	UA_##TYPE##Request_decodeBinary(msg, pos, &p); \
-	init_response_header((UA_RequestHeader*)&p, (UA_ResponseHeader*)&r); \
+	init_response_header(&p.requestHeader, &r.responseHeader); \
 	DBG_VERBOSE(printf("Invoke Service: %s\n", #TYPE)); \
 	Service_##TYPE(channel, &p, &r); \
 	DBG_VERBOSE(printf("Finished Service: %s\n", #TYPE)); \