aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h129
1 files changed, 66 insertions, 63 deletions
diff --git a/src/common.h b/src/common.h
index 63fa683..0196e06 100644
--- a/src/common.h
+++ b/src/common.h
@@ -29,19 +29,19 @@ typedef enum
AUTH_ANONYMOUS,
AUTH_USER,
AUTH_CERT
-} AuthMode;
+} auth_mode;
/**
* @brief Session-level authentication configuration (tagged union).
*
* AUTH_ANONYMOUS carries no payload. AUTH_USER carries borrowed pointers
- * to username/password strings (owned by the Config that was parsed).
+ * to username/password strings (owned by the config that was parsed).
* AUTH_CERT carries no payload — the application certificate is reused
* as the X509 identity token.
*/
typedef struct
{
- AuthMode mode;
+ auth_mode mode;
union
{
struct
@@ -50,28 +50,28 @@ typedef struct
const char *password;
} user;
};
-} AuthConfig;
+} auth_config;
/**
* @brief Transport-level security configuration.
*
* Groups the certificate, private key, trust list, security mode, and
- * security policy URI. All pointers are borrowed (owned by Config or
- * returned by loadTrustStore / resolveSecurityPolicyUri). The caller
- * must free trustPaths with freeTrustStore() when done.
+ * security policy URI. All pointers are borrowed (owned by config or
+ * returned by load_trust_store / resolve_security_policy_uri). The caller
+ * must free trust_paths with free_trust_store() when done.
*
- * securityMode and securityPolicyUri are only meaningful for client
+ * security_mode and security_policy_uri are only meaningful for client
* configs; server-side callers may leave them zeroed.
*/
typedef struct
{
- const char *certPath;
- const char *keyPath;
- char **trustPaths;
- size_t trustSize;
- UA_MessageSecurityMode securityMode;
- const char *securityPolicyUri;
-} SecurityConfig;
+ const char *cert_path;
+ const char *key_path;
+ char **trust_paths;
+ size_t trust_size;
+ UA_MessageSecurityMode security_mode;
+ const char *security_policy_uri;
+} security_config;
/* ========================================================================
* File Loading
@@ -83,30 +83,31 @@ typedef struct
* @param path File path to read.
* @return The file contents, or UA_BYTESTRING_NULL on error.
*/
-UA_ByteString loadFile (const char *const path);
+UA_ByteString load_file (const char *const path);
/**
* @brief Collects all *.der file paths from a trust store directory.
*
* Opens the directory, finds every file ending in ".der", and builds
- * heap-allocated full paths (dirPath/filename). The caller must free
- * the result with freeTrustStore().
+ * heap-allocated full paths (dir_path/filename). The caller must free
+ * the result with free_trust_store().
*
- * @param dirPath Path to the trust store directory.
- * @param outPaths Output: heap-allocated array of heap-allocated strings.
+ * @param dir_path Path to the trust store directory.
+ * @param out_paths Output: heap-allocated array of heap-allocated strings.
* Set to NULL when the directory is empty.
- * @param outSize Output: number of entries in outPaths.
+ * @param out_size Output: number of entries in out_paths.
* @return 0 on success, -1 on error (logged via UA_LOG_ERROR).
*/
-int loadTrustStore (const char *dirPath, char ***outPaths, size_t *outSize);
+int load_trust_store (const char *dir_path, char ***out_paths,
+ size_t *out_size);
/**
- * @brief Frees the array returned by loadTrustStore().
+ * @brief Frees the array returned by load_trust_store().
*
* @param paths The array of strings (may be NULL).
* @param size Number of entries.
*/
-void freeTrustStore (char **paths, size_t size);
+void free_trust_store (char **paths, size_t size);
/* ========================================================================
* Parsing Helpers
@@ -121,42 +122,43 @@ void freeTrustStore (char **paths, size_t size);
* @param name Log-level name string.
* @return The matching UA_LogLevel, or -1 if the name is not recognized.
*/
-int parseLogLevel (const char *name);
+int parse_log_level (const char *name);
/**
* @brief Parses the authMode key from a configuration file.
*
- * Populates an AuthConfig struct. When authMode is "anonymous", sets
+ * Populates an auth_config struct. When authMode is "anonymous", sets
* mode to AUTH_ANONYMOUS. When "user", sets mode to AUTH_USER and reads
* the username/password keys. When "cert", sets mode to AUTH_CERT.
* Logs errors internally.
*
* @param cfg Parsed configuration.
* @param program Program name (for error messages).
- * @param auth Output: populated AuthConfig.
+ * @param auth Output: populated auth_config.
* @return 0 on success, -1 on error.
*/
-int parseAuthConfig (const Config *cfg, const char *program, AuthConfig *auth);
+int parse_auth_config (const config *cfg, const char *program,
+ auth_config *auth);
/**
* @brief Parses security configuration from a config file.
*
* Reads certificate, privateKey, and trustStore keys. When all three
* are omitted, zeroes @p sec and returns 0 (unsecure). When any of the
- * three is present, all three are required. When @p needsModePolicy is
+ * three is present, all three are required. When @p needs_mode_policy is
* true, also reads and resolves securityMode and securityPolicy keys.
- * Calls loadTrustStore() internally; the caller must free
- * sec->trustPaths with freeTrustStore().
+ * Calls load_trust_store() internally; the caller must free
+ * sec->trust_paths with free_trust_store().
*
- * @param cfg Parsed configuration.
- * @param program Program name (for error messages).
- * @param needsModePolicy When true, require securityMode and
- * securityPolicy keys (client configs).
- * @param sec Output: populated SecurityConfig.
+ * @param cfg Parsed configuration.
+ * @param program Program name (for error messages).
+ * @param needs_mode_policy When true, require securityMode and
+ * securityPolicy keys (client configs).
+ * @param sec Output: populated security_config.
* @return 0 on success, -1 on error.
*/
-int parseSecurityConfig (const Config *cfg, const char *program,
- UA_Boolean needsModePolicy, SecurityConfig *sec);
+int parse_security_config (const config *cfg, const char *program,
+ UA_Boolean needs_mode_policy, security_config *sec);
/**
* @brief Parses a security mode name into the corresponding enum value.
@@ -167,7 +169,7 @@ int parseSecurityConfig (const Config *cfg, const char *program,
* @return The matching UA_MessageSecurityMode, or
* UA_MESSAGESECURITYMODE_INVALID if the name is not recognized.
*/
-UA_MessageSecurityMode parseSecurityMode (const char *name);
+UA_MessageSecurityMode parse_security_mode (const char *name);
/**
* @brief Maps a short security policy name to its full OPC UA URI.
@@ -175,10 +177,10 @@ UA_MessageSecurityMode parseSecurityMode (const char *name);
* Accepted names: "None", "Basic256Sha256", "Aes256_Sha256_RsaPss",
* "Aes128_Sha256_RsaOaep", "ECC_nistP256".
*
- * @param shortName Short policy name.
+ * @param short_name Short policy name.
* @return The full URI string, or NULL if the name is not recognized.
*/
-const char *resolveSecurityPolicyUri (const char *shortName);
+const char *resolve_security_policy_uri (const char *short_name);
/* ========================================================================
* Factory Functions
@@ -197,16 +199,16 @@ const char *resolveSecurityPolicyUri (const char *shortName);
* (discovery is ignored). The applicationUri is set in both cases.
*
* @param port Server port number.
- * @param applicationUri OPC UA application URI.
+ * @param application_uri OPC UA application URI.
* @param sec Security configuration, or NULL for unsecure.
* @param discovery When true and sec is non-NULL, add a None
* endpoint restricted to discovery services.
* @param retval Output parameter set to the status code on failure.
* @return A configured UA_Server, or NULL on error.
*/
-UA_Server *createServer (UA_UInt16 port, const char *applicationUri,
- const SecurityConfig *sec, UA_Boolean discovery,
- UA_StatusCode *retval);
+UA_Server *create_server (UA_UInt16 port, const char *application_uri,
+ const security_config *sec, UA_Boolean discovery,
+ UA_StatusCode *retval);
/**
* @brief Initializes a UA_ClientConfig without encryption.
@@ -218,13 +220,13 @@ UA_Server *createServer (UA_UInt16 port, const char *applicationUri,
* authentication. AUTH_CERT returns an error (requires encryption).
*
* @param cc Pointer to a zero-initialized UA_ClientConfig.
- * @param applicationUri OPC UA application URI.
+ * @param application_uri OPC UA application URI.
* @param auth Authentication config, or NULL for anonymous.
* @return UA_STATUSCODE_GOOD on success, error code otherwise.
*/
-UA_StatusCode createUnsecureClientConfig (UA_ClientConfig *cc,
- const char *applicationUri,
- const AuthConfig *auth);
+UA_StatusCode create_unsecure_client_config (UA_ClientConfig *cc,
+ const char *application_uri,
+ const auth_config *auth);
/**
* @brief Initializes a UA_ClientConfig with encryption.
@@ -237,32 +239,32 @@ UA_StatusCode createUnsecureClientConfig (UA_ClientConfig *cc,
* username/password authentication. Both are mutually exclusive.
*
* @param cc Pointer to a zero-initialized UA_ClientConfig.
- * @param applicationUri OPC UA application URI.
+ * @param application_uri OPC UA application URI.
* @param sec Security configuration (cert, key, trust, mode, policy).
* @param auth Authentication config, or NULL for anonymous.
* @return UA_STATUSCODE_GOOD on success, error code otherwise.
*/
-UA_StatusCode createSecureClientConfig (UA_ClientConfig *cc,
- const char *applicationUri,
- const SecurityConfig *sec,
- const AuthConfig *auth);
+UA_StatusCode create_secure_client_config (UA_ClientConfig *cc,
+ const char *application_uri,
+ const security_config *sec,
+ const auth_config *auth);
/**
- * @brief Configures server access control from an AuthConfig.
+ * @brief Configures server access control from an auth_config.
*
* UA_ServerConfig_setDefaultWithSecureSecurityPolicies installs
* certificate-only authentication by default. This function
* overrides that with the desired policy: anonymous, username/password,
* or X509 certificate. For AUTH_CERT the sessionPKI verifier set by
- * createServer is preserved, so UA_AccessControl_default automatically
+ * create_server is preserved, so UA_AccessControl_default automatically
* advertises the X509 certificate token policy.
*
- * @param config Server configuration to modify.
- * @param auth Authentication configuration.
+ * @param srv_config Server configuration to modify.
+ * @param auth Authentication configuration.
* @return UA_STATUSCODE_GOOD on success, error code otherwise.
*/
-UA_StatusCode configureAccessControl (UA_ServerConfig *config,
- const AuthConfig *auth);
+UA_StatusCode configure_access_control (UA_ServerConfig *srv_config,
+ const auth_config *auth);
/* ========================================================================
* Output Formatting
@@ -277,8 +279,9 @@ UA_StatusCode configureAccessControl (UA_ServerConfig *config,
* @param description The application description to print.
* @param index Display index (e.g. position in the FindServers result array).
*/
-void printApplicationDescription (const UA_ApplicationDescription *description,
- size_t index);
+void
+print_application_description (const UA_ApplicationDescription *description,
+ size_t index);
/**
* @brief Logs a UA_EndpointDescription in a compact one-line format.
@@ -289,6 +292,6 @@ void printApplicationDescription (const UA_ApplicationDescription *description,
* @param endpoint The endpoint description to print.
* @param index Display index (e.g. position in the GetEndpoints result array).
*/
-void printEndpoint (const UA_EndpointDescription *endpoint, size_t index);
+void print_endpoint (const UA_EndpointDescription *endpoint, size_t index);
#endif /* DISCOVERY_COMMON_H */