From 3f56a42fff75bffc73255295ea5f4992fbd59ba0 Mon Sep 17 00:00:00 2001 From: "Daniel K. O. (dkosmari)" Date: Mon, 30 Sep 2024 17:08:52 -0300 Subject: [PATCH] - Use asm labels instead of inline functions to call the mangled identifier. - Allow both the typo and the correct names to be used in `NetConfInterface`. --HG-- branch : nn-ac-extras --- include/nn/ac/ac_cpp.h | 414 +++++++++++++----------------------- include/nsysnet/netconfig.h | 5 +- 2 files changed, 149 insertions(+), 270 deletions(-) diff --git a/include/nn/ac/ac_cpp.h b/include/nn/ac/ac_cpp.h index 951859a60..0513a8cf5 100644 --- a/include/nn/ac/ac_cpp.h +++ b/include/nn/ac/ac_cpp.h @@ -28,7 +28,7 @@ namespace ac using ConfigIdNum = uint32_t; /** - * The configuration for a given network profile. + * The configuration for a given network profile (from 1 to 6). * \sa NetConfCfg */ using Config = NetConfCfg; @@ -41,128 +41,38 @@ enum Status { STATUS_PROCESSING = 1, }; -/** -* C++ linkage for the autoconnect API, see \link nn::ac \endlink for use. - * Cafe provides mangled symbols for C++ APIs, so nn::ac is actually static - * inline calls to the mangled symbols under nn::ac::detail. - */ -namespace detail -{ -extern "C" -{ - -nn::Result BeginLocalConnection__Q2_2nn2acFb(bool unknown); -void ClearConfig__Q2_2nn2acFP16netconf_profile_(Config *cfg); -nn::Result Close__Q2_2nn2acFv(); -nn::Result CloseAll__Q2_2nn2acFv(); -nn::Result Connect__Q2_2nn2acFPC16netconf_profile_(const Config *cfg); -nn::Result Connect__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); -nn::Result Connect__Q2_2nn2acFv(); -nn::Result ConnectAsync__Q2_2nn2acFPC16netconf_profile_(const Config *cfg); -nn::Result ConnectAsync__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); -nn::Result ConnectAsync__Q2_2nn2acFv(); -nn::Result ConnectWithRetry__Q2_2nn2acFv(); -nn::Result DeleteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); -nn::Result EndLocalConnection__Q2_2nn2acFv(); -void Finalize__Q2_2nn2acFv(); -nn::Result GetAssignedAddress__Q2_2nn2acFPUl(uint32_t *ip); -nn::Result GetAssignedAlternativeDns__Q2_2nn2acFPUl(uint32_t *ip); -nn::Result GetAssignedGateway__Q2_2nn2acFPUl(uint32_t *ip); -nn::Result GetAssignedPreferedDns__Q2_2nn2acFPUl(uint32_t *ip); -nn::Result GetAssignedSubnet__Q2_2nn2acFPUl(uint32_t *ip); -nn::Result GetCloseStatus__Q2_2nn2acFPQ3_2nn2ac6Status(Status *status); -nn::Result GetCompatId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(ConfigIdNum *id); -nn::Result GetConnectResult__Q2_2nn2acFPQ2_2nn6Result(nn::Result *result); -nn::Result GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status(Status *status); -nn::Result GetLastErrorCode__Q2_2nn2acFPUi(ErrorCode *error); -nn::Result GetRunningConfig__Q2_2nn2acFP16netconf_profile_(Config *cfg); -nn::Result GetStartupId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(ConfigIdNum *id); -nn::Result Initialize__Q2_2nn2acFv(); -nn::Result IsAnyKeepingConnect__Q2_2nn2acFPb(bool keeping); -nn::Result IsApplicationConnected__Q2_2nn2acFPb(bool *connected); -nn::Result IsAutoConnectionFatallyFailed__Q2_2nn2acFQ2_2nn6Result(nn::Result *failed); -nn::Result IsConfigExisting__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPb(ConfigIdNum id, bool *existing); -nn::Result IsKeepingConnect__Q2_2nn2acFPb(bool *keeping); -nn::Result IsReadyToConnect__Q2_2nn2acFPb(bool *ready); -nn::Result ReadConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumP16netconf_profile_(ConfigIdNum id, Config *cfg); -nn::Result SetCompatId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); -nn::Result SetStartupId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); -nn::Result WriteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPC16netconf_profile_(ConfigIdNum id, const Config *cfg); - -} // extern "C" -} // namespace detail -/** - * Initialise the Auto Connect library. Call this function before any other nn::ac - * functions. - * - * \return - * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink - * and \link nn::Result::IsFailure \endlink. - * - * \sa - * - \link Finalize \endlink - */ -static inline nn::Result -Initialize() -{ - return detail::Initialize__Q2_2nn2acFv(); -} +nn::Result +BeginLocalConnection(bool unknown) + asm("BeginLocalConnection__Q2_2nn2acFb"); -/** - * Cleanup the Auto Connect library. Do not call any nn::ac functions (other - * than \link Initialize \endlink) after calling this function. - * - * \sa - * - \link Initialize \endlink - */ -static inline void -Finalize() -{ - detail::Finalize__Q2_2nn2acFv(); -} +void +ClearConfig(Config *cfg) + asm("ClearConfig__Q2_2nn2acFP16netconf_profile_"); -/** - * Gets the default connection configuration id. This is the default as marked - * in System Settings. - * - * \param id - * A pointer to an \link ConfigIdNum \endlink to write the config ID to. Must - * not be a \c nullptr. - * - * \return - * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink - * and \link nn::Result::IsFailure \endlink. - */ -static inline nn::Result -GetStartupId(ConfigIdNum *id) -{ - return detail::GetStartupId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(id); -} +nn::Result +Close() + asm("Close__Q2_2nn2acFv"); -static inline nn::Result -SetStartupId(ConfigIdNum id) -{ - return detail::SetStartupId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(id); -} +nn::Result +CloseAll() + asm("CloseAll__Q2_2nn2acFv"); -static inline nn::Result -GetCompatId(ConfigIdNum *id) -{ - return detail::GetCompatId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(id); -} +nn::Result +Connect(const Config *cfg) + asm("Connect__Q2_2nn2acFPC16netconf_profile_"); -static inline nn::Result -SetCompatId(ConfigIdNum id) -{ - return detail::SetCompatId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(id); -} +nn::Result +Connect(ConfigIdNum id) + asm("Connect__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum"); -static inline nn::Result +nn::Result Connect() -{ - return detail::Connect__Q2_2nn2acFv(); -} + asm("Connect__Q2_2nn2acFv"); + +nn::Result +ConnectAsync(const Config *cfg) + asm("ConnectAsync__Q2_2nn2acFPC16netconf_profile_"); /** * Connects to a network, using the configuration represented by the given @@ -175,101 +85,36 @@ Connect() * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink * and \link nn::Result::IsFailure \endlink. */ -static inline nn::Result -Connect(ConfigIdNum id) -{ - return detail::Connect__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(id); -} - -static inline nn::Result -Connect(const Config *cfg) -{ - return detail::Connect__Q2_2nn2acFPC16netconf_profile_(cfg); -} - -static inline nn::Result -ConnectAsync() -{ - return detail::ConnectAsync__Q2_2nn2acFv(); -} - -static inline nn::Result +nn::Result ConnectAsync(ConfigIdNum id) -{ - return detail::ConnectAsync__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(id); -} + asm("ConnectAsync__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum"); -static inline nn::Result -ConnectAsync(const Config *cfg) -{ - return detail::ConnectAsync__Q2_2nn2acFPC16netconf_profile_(cfg); -} +nn::Result +ConnectAsync() + asm("ConnectAsync__Q2_2nn2acFv"); -static inline nn::Result +nn::Result ConnectWithRetry() -{ - return detail::ConnectWithRetry__Q2_2nn2acFv(); -} - -static inline nn::Result -GetConnectStatus(Status *status) -{ - return detail::GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status(status); -} - -static inline nn::Result -GetConnectResult(nn::Result *result) -{ - return detail::GetConnectResult__Q2_2nn2acFPQ2_2nn6Result(result); -} - -static inline nn::Result -Close() -{ - return detail::Close__Q2_2nn2acFv(); -} - -static inline nn::Result -GetCloseStatus(Status *status) -{ - return detail::GetCloseStatus__Q2_2nn2acFPQ3_2nn2ac6Status(status); -} - -static inline nn::Result -CloseAll() -{ - return detail::CloseAll__Q2_2nn2acFv(); -} - -static inline nn::Result -IsAnyKeepingConnect(bool *keeping) -{ - return detail::IsAnyKeepingConnect__Q2_2nn2acFPb(keeping); -} - -static inline nn::Result -IsKeepingConnect(bool *keeping) -{ - return detail::IsKeepingConnect__Q2_2nn2acFPb(keeping); -} + asm("ConnectWithRetry__Q2_2nn2acFv"); -static inline nn::Result -IsReadyToConnect(bool *ready) -{ - return detail::IsReadyToConnect__Q2_2nn2acFPb(ready); -} +nn::Result +DeleteConfig(ConfigIdNum id) + asm("DeleteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum"); -static inline nn::Result -IsApplicationConnected(bool *connected) -{ - return detail::IsApplicationConnected__Q2_2nn2acFPb(connected); -} +nn::Result +EndLocalConnection() + asm("EndLocalConnection__Q2_2nn2acFv"); -static inline nn::Result -IsAutoConnectionFatallyFailed(nn::Result *failed) -{ - return detail::IsAutoConnectionFatallyFailed__Q2_2nn2acFQ2_2nn6Result(failed); -} +/** + * Cleans up the Auto Connect library. Do not call any nn::ac functions (other + * than \link Initialize \endlink) after calling this function. + * + * \sa + * - \link Initialize \endlink + */ +void +Finalize() + asm("Finalize__Q2_2nn2acFv"); /** * Gets the IP address assosciated with the currently active connection. @@ -283,89 +128,120 @@ IsAutoConnectionFatallyFailed(nn::Result *failed) * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink * and \link nn::Result::IsFailure \endlink. */ -static inline nn::Result +nn::Result GetAssignedAddress(uint32_t *ip) -{ - return detail::GetAssignedAddress__Q2_2nn2acFPUl(ip); -} + asm("GetAssignedAddress__Q2_2nn2acFPUl"); -static inline nn::Result +nn::Result +GetAssignedAlternativeDns(uint32_t *ip) + asm("GetAssignedAlternativeDns__Q2_2nn2acFPUl"); + +nn::Result GetAssignedGateway(uint32_t *ip) -{ - return detail::GetAssignedGateway__Q2_2nn2acFPUl(ip); -} + asm("GetAssignedGateway__Q2_2nn2acFPUl"); -static inline nn::Result +nn::Result +GetAssignedPreferedDns(uint32_t *ip) + asm("GetAssignedPreferedDns__Q2_2nn2acFPUl"); + +nn::Result GetAssignedSubnet(uint32_t *ip) -{ - return detail::GetAssignedSubnet__Q2_2nn2acFPUl(ip); -} + asm("GetAssignedSubnet__Q2_2nn2acFPUl"); -static inline nn::Result -GetAssignedPreferedDns(uint32_t *ip) -{ - return detail::GetAssignedPreferedDns__Q2_2nn2acFPUl(ip); -} +nn::Result +GetCloseStatus(Status *status) + asm("GetCloseStatus__Q2_2nn2acFPQ3_2nn2ac6Status"); -static inline nn::Result -GetAssignedAlternativeDns(uint32_t *ip) -{ - return detail::GetAssignedAlternativeDns__Q2_2nn2acFPUl(ip); -} +nn::Result +GetCompatId(ConfigIdNum *id) + asm("GetCompatId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum"); -static inline nn::Result -IsConfigExisting(ConfigIdNum id, bool *existing) -{ - return detail::IsConfigExisting__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPb(id, existing); -} +nn::Result +GetConnectResult(nn::Result *result) + asm("GetConnectResult__Q2_2nn2acFPQ2_2nn6Result"); -static inline void -ClearConfig(Config *cfg) -{ - detail::ClearConfig__Q2_2nn2acFP16netconf_profile_(cfg); -} +nn::Result +GetConnectStatus(Status *status) + asm("GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status"); + +nn::Result +GetLastErrorCode(ErrorCode *error) + asm("GetLastErrorCode__Q2_2nn2acFPUi"); -static inline nn::Result +nn::Result GetRunningConfig(Config *cfg) -{ - return detail::GetRunningConfig__Q2_2nn2acFP16netconf_profile_(cfg); -} + asm("GetRunningConfig__Q2_2nn2acFP16netconf_profile_"); -static inline nn::Result -ReadConfig(ConfigIdNum id, Config *cfg) -{ - return detail::ReadConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumP16netconf_profile_(id, cfg); -} +/** + * Gets the default connection configuration id. This is the default as marked + * in System Settings. + * + * \param id + * A pointer to an \link ConfigIdNum \endlink to write the config ID to. Must + * not be a \c nullptr. + * + * \return + * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink + * and \link nn::Result::IsFailure \endlink. + */ +nn::Result +GetStartupId(ConfigIdNum *id) + asm("GetStartupId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum"); -static inline nn::Result -WriteConfig(ConfigIdNum id, const Config *cfg) -{ - return detail::WriteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPC16netconf_profile_(id, cfg); -} +/** + * Initializes the Auto Connect library. Call this function before any other nn::ac + * functions. + * + * \return + * A \link nn::Result Result\endlink - see \link nn::Result::IsSuccess \endlink + * and \link nn::Result::IsFailure \endlink. + * + * \sa + * - \link Finalize \endlink + */ +nn::Result +Initialize() + asm("Initialize__Q2_2nn2acFv"); -static inline nn::Result -DeleteConfig(ConfigIdNum id) -{ - return detail::DeleteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(id); -} +nn::Result +IsAnyKeepingConnect(bool keeping) + asm("IsAnyKeepingConnect__Q2_2nn2acFPb"); -static inline nn::Result -GetLastErrorCode(ErrorCode *error) -{ - return detail::GetLastErrorCode__Q2_2nn2acFPUi(error); -} +nn::Result +IsApplicationConnected(bool *connected) + asm("IsApplicationConnected__Q2_2nn2acFPb"); -static inline nn::Result -BeginLocalConnection(bool unknown) -{ - return detail::BeginLocalConnection__Q2_2nn2acFb(unknown); -} +nn::Result +IsAutoConnectionFatallyFailed(nn::Result *failed) + asm("IsAutoConnectionFatallyFailed__Q2_2nn2acFQ2_2nn6Result"); -static inline nn::Result -EndLocalConnection() -{ - return detail::EndLocalConnection__Q2_2nn2acFv(); -} +nn::Result +IsConfigExisting(ConfigIdNum id, bool *existing) + asm("IsConfigExisting__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPb"); + +nn::Result +IsKeepingConnect(bool *keeping) + asm("IsKeepingConnect__Q2_2nn2acFPb"); + +nn::Result +IsReadyToConnect(bool *ready) + asm("IsReadyToConnect__Q2_2nn2acFPb"); + +nn::Result +ReadConfig(ConfigIdNum id, Config *cfg) + asm("ReadConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumP16netconf_profile_"); + +nn::Result +SetCompatId(ConfigIdNum id) + asm("SetCompatId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum"); + +nn::Result +SetStartupId(ConfigIdNum id) + asm("SetStartupId__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum"); + +nn::Result +WriteConfig(ConfigIdNum id, const Config *cfg) + asm("WriteConfig__Q2_2nn2acFQ3_2nn2ac11ConfigIdNumPC16netconf_profile_"); } // namespace ac } // namespace nn diff --git a/include/nsysnet/netconfig.h b/include/nsysnet/netconfig.h index b29d6df8f..27e008c4e 100644 --- a/include/nsysnet/netconfig.h +++ b/include/nsysnet/netconfig.h @@ -198,7 +198,10 @@ WUT_CHECK_SIZE(NetConfOpt, 0x2c1); struct WUT_PACKED NetConfInterface { uint16_t if_index; - uint16_t if_state; + union { + uint16_t if_state; + uint16_t if_sate; + }; uint32_t if_mtu; NetConfIPv4Info ipv4Info; };