Browse Source

simplify generated enums, use generated enums instead of custom ones

Julius Pfrommer 10 years ago
parent
commit
fcdfe58e97

+ 4 - 3
src/server/ua_securechannel_manager.c

@@ -66,15 +66,16 @@ UA_StatusCode UA_SecureChannelManager_open(UA_SecureChannelManager           *cm
         cm->maxChannelLifetime : request->requestedLifetime;
 
     switch(request->securityMode) {
-    case UA_SECURITYMODE_INVALID:
+    case UA_MESSAGESECURITYMODE_INVALID:
         printf("UA_SecureChannel_processOpenRequest - client demands invalid \n");
         break;
 
-    case UA_SECURITYMODE_NONE:
+    case UA_MESSAGESECURITYMODE_NONE:
         UA_ByteString_copy(&request->clientNonce, &entry->channel.clientNonce);
         break;
 
-    case UA_SECURITYMODE_SIGNANDENCRYPT:
+    case UA_MESSAGESECURITYMODE_SIGN:
+    case UA_MESSAGESECURITYMODE_SIGNANDENCRYPT:
         printf("UA_SecureChannel_processOpenRequest - client demands signed & encrypted \n");
         //TODO check if senderCertificate and ReceiverCertificateThumbprint are present
         break;

+ 1 - 1
src/server/ua_services_securechannel.c

@@ -5,7 +5,7 @@ void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
                                const UA_OpenSecureChannelRequest *request,
                                UA_OpenSecureChannelResponse *response) {
     // todo: if(request->clientProtocolVersion != protocolVersion)
-    if(request->requestType == UA_SECURITYTOKEN_ISSUE)
+    if(request->requestType == UA_SECURITYTOKENREQUESTTYPE_ISSUE)
         UA_SecureChannelManager_open(server->secureChannelManager, connection, request, response);
     else
         UA_SecureChannelManager_renew(server->secureChannelManager, connection, request, response);

+ 0 - 11
src/ua_transport.h

@@ -4,17 +4,6 @@
 #include "ua_types.h"
 #include "ua_types_encoding_binary.h"
 
-typedef enum SecurityTokenRequestType {
-    UA_SECURITYTOKEN_ISSUE = 0,
-    UA_SECURITYTOKEN_RENEW = 1
-} SecurityTokenRequestType;
-
-typedef enum {
-    UA_SECURITYMODE_INVALID        = 0,
-    UA_SECURITYMODE_NONE           = 1,
-    UA_SECURITYMODE_SIGNANDENCRYPT = 2
-} SecurityMode;
-
 /* MessageType */
 typedef UA_Int32 UA_MessageType;
 enum UA_MessageType {

+ 6 - 5
tools/generate_builtin.py

@@ -81,16 +81,17 @@ def createEnumerated(element):
     valuemap = OrderedDict()
     name = "UA_" + element.get("Name")
     fixed_size.add(name)
+    printh("") # newline
     for child in element:
         if child.tag == "{http://opcfoundation.org/BinarySchema/}Documentation":
             printh("/** @brief " + child.text + " */")
         if child.tag == "{http://opcfoundation.org/BinarySchema/}EnumeratedValue":
             valuemap[name + "_" + child.get("Name")] = child.get("Value")
     valuemap = OrderedDict(sorted(valuemap.iteritems(), key=lambda (k,v): int(v)))
-    printh("typedef UA_Int32 " + name + ";")
-    printh("enum " + name + "_enum { \n\t" +
+    # printh("typedef UA_Int32 " + name + ";")
+    printh("typedef enum " + name + " { \n\t" +
            ",\n\t".join(map(lambda (key, value) : key.upper() + " = " + value, valuemap.iteritems())) +
-           "\n};")
+           "\n} " + name + ";")
     printh("UA_TYPE_PROTOTYPES (" + name + ")")
     printh("UA_TYPE_BINARY_ENCODING(" + name + ")")
     printc("UA_TYPE_AS(" + name + ", UA_Int32)")
@@ -103,6 +104,7 @@ UA_TYPE_METHOD_DECODEXML_NOTIMPL(%(name)s\n)''')
 
 def createOpaque(element):
     name = "UA_" + element.get("Name")
+    printh("") # newline
     for child in element:
         if child.tag == "{http://opcfoundation.org/BinarySchema/}Documentation":
             printh("/** @brief " + child.text + " */")
@@ -128,6 +130,7 @@ def createStructured(element):
 
     # 2) Store members in membermap (name->type).
     membermap = OrderedDict()
+    printh("") # newline
     for child in element:
         if child.tag == "{http://opcfoundation.org/BinarySchema/}Documentation":
             printh("/** @brief " + child.text + " */")
@@ -152,7 +155,6 @@ def createStructured(element):
     else:
         printh("typedef void* %(name)s;")
         
-
     # 3) function prototypes
     printh("UA_TYPE_PROTOTYPES(" + name + ")")
     printh("UA_TYPE_BINARY_ENCODING(" + name + ")")
@@ -301,7 +303,6 @@ if args.with_xml:
 if args.additional_includes:
     for incl in args.additional_includes.split(","):
         printh("#include \"" + incl + "\"")
-printh("") # newline
 
 printc('''/**
  * @file '''+sys.argv[2]+'''.c