SRP:搜尋結果網頁
這個模組包含控管 SRP 用戶端行為的函式。
摘要
這個模組包含服務註冊通訊協定的功能。
這個模組包含 SRP 用戶端緩衝區和服務集區的函式。
此模組中的函式只有在啟用 OPENNON_CONFIG_SRP_CLIENT_BUFFERS_ENABLE 的情況下才能使用。
Typedefs |
|
---|---|
otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext)
|
typedefvoid(*
這個函式指標類型會定義 SRP 用戶端在自動啟動或停止時用來通知使用者的回呼。 |
otSrpClientBuffersServiceEntry
|
typedef 這個結構代表 SRP 用戶端服務集區項目。 |
otSrpClientCallback)(otError aError, const otSrpClientHostInfo *aHostInfo, const otSrpClientService *aServices, const otSrpClientService *aRemovedServices, void *aContext)
|
typedefvoid(*
這個函式指標類型用於定義 SRP 用戶端用來通知使用者變更/事件/錯誤的回呼。 |
otSrpClientHostInfo
|
typedefstruct otSrpClientHostInfo
這個結構代表 SRP 用戶端主機資訊。 |
otSrpClientService
|
typedefstruct otSrpClientService
這個結構代表 SRP 用戶端服務。 |
otSrpServerAddressMode
|
typedef 這項列舉代表 SRP 伺服器使用的地址模式, |
otSrpServerHost
|
typedefstruct otSrpServerHost
這種不透明的類型代表 SRP 服務主機。 |
otSrpServerLeaseConfig
|
typedefstruct otSrpServerLeaseConfig
這個結構包括 SRP 伺服器 LEASE 和 KEY-LEASE 設定。 |
otSrpServerLeaseInfo
|
typedefstruct otSrpServerLeaseInfo
這個結構包括主機/服務的 SRP 伺服器租借資訊。 |
otSrpServerResponseCounters
|
typedefstruct otSrpServerResponseCounters
此結構包含 SRP 伺服器回應的統計資料。 |
otSrpServerService
|
typedefstruct otSrpServerService
這種不透明類型代表 SRP 服務。 |
otSrpServerServiceFlags
|
typedefuint8_t
您可以在服務旗標類型中,指定要在 SRP 服務清單中搜尋 (或疊代) 哪些服務。 |
otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId, const otSrpServerHost *aHost, uint32_t aTimeout, void *aContext)
|
typedefvoid(*
這個函式會處理 SRP 服務更新。 |
otSrpServerServiceUpdateId
|
typedefuint32_t
SRP 伺服器上的 SRP 服務更新交易 ID。 |
otSrpServerTtlConfig
|
typedefstruct otSrpServerTtlConfig
這個結構包括 SRP 伺服器存留時間設定。 |
Functions |
|
---|---|
otSrpClientAddService(otInstance *aInstance, otSrpClientService *aService)
|
這項函式會新增要向伺服器註冊的服務。
|
otSrpClientBuffersAllocateService(otInstance *aInstance)
|
這個函式會從集區分配新的服務項目。
|
otSrpClientBuffersFreeAllServices(otInstance *aInstance)
|
void
這個函式會釋出先前分配的所有服務項目。
|
otSrpClientBuffersFreeService(otInstance *aInstance, otSrpClientBuffersServiceEntry *aService)
|
void
這個函式會釋出先前分配的服務項目。
|
otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength)
|
這個函式會接收做為 SRP 用戶端主機位址清單的 IPv6 位址項目陣列。
|
otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize)
|
char *
這個函式會取得用於 SRP 用戶端主機名稱的字串緩衝區。
|
otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
char *
這個函式會從服務項目取得服務執行個體名稱的字串緩衝區。
|
otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
char *
這個函式會從服務項目取得服務名稱的字串緩衝區。
|
otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
uint8_t *
這個函式會從服務項目取得 TXT 記錄的緩衝區。
|
otSrpClientBuffersGetSubTypeLabelsArray(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength)
|
const char **
這個函式會從服務項目取得服務子類型標籤的陣列。
|
otSrpClientClearHostAndServices(otInstance *aInstance)
|
void
這項功能會清除所有主機資訊和所有服務。
|
otSrpClientClearService(otInstance *aInstance, otSrpClientService *aService)
|
這個函式會清除服務,立即從服務清單中移除服務。
|
otSrpClientDisableAutoStartMode(otInstance *aInstance)
|
void
這個函式會停用自動啟動模式。
|
otSrpClientEnableAutoHostAddress(otInstance *aInstance)
|
這項功能會啟用自動主機位址模式。
|
otSrpClientEnableAutoStartMode(otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext)
|
void
這個函式會啟用自動啟動模式。
|
otSrpClientGetDomainName(otInstance *aInstance)
|
const char *
這項函式會取得 SRP 用戶端使用的網域名稱。
|
otSrpClientGetHostInfo(otInstance *aInstance)
|
const otSrpClientHostInfo *
這個函式會取得主機資訊。
|
otSrpClientGetKeyLeaseInterval(otInstance *aInstance)
|
uint32_t
這個函式會取得 SRP 更新要求中使用的預設金鑰租借間隔。
|
otSrpClientGetLeaseInterval(otInstance *aInstance)
|
uint32_t
這個函式會取得在 SRP 更新要求中使用的預設租賃間隔。
|
otSrpClientGetServerAddress(otInstance *aInstance)
|
const otSockAddr *
這個函式會取得 SRP 用戶端使用的 SRP 伺服器通訊端位址 (IPv6 位址和通訊埠號碼)。
|
otSrpClientGetServices(otInstance *aInstance)
|
const otSrpClientService *
這個函式會取得用戶端管理的服務清單。
|
otSrpClientGetTtl(otInstance *aInstance)
|
uint32_t
這個函式會取得 SRP 更新要求中的每個記錄的存留時間值。
|
otSrpClientIsAutoStartModeEnabled(otInstance *aInstance)
|
bool
這個函式表示自動啟動模式 (已啟用或已停用) 的目前狀態。
|
otSrpClientIsRunning(otInstance *aInstance)
|
bool
這個函式會指出 SRP 用戶端是否正在執行。
|
otSrpClientIsServiceKeyRecordEnabled(otInstance *aInstance)
|
bool
這種方法表示「服務金鑰記錄包含」模式為啟用或停用。
|
otSrpClientItemStateToString(otSrpClientItemState aItemState)
|
const char *
這個函式會將
otSrpClientItemState 轉換為字串。 |
otSrpClientRemoveHostAndServices(otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer)
|
這項函式會開始移除主機資訊和所有服務。
|
otSrpClientRemoveService(otInstance *aInstance, otSrpClientService *aService)
|
這項函式要求向伺服器取消註冊服務。
|
otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback, void *aContext)
|
void
這個函式會設定回呼,以通知呼叫者 SRP 用戶端的事件/變更。
|
otSrpClientSetDomainName(otInstance *aInstance, const char *aName)
|
這個函式會設定 SRP 用戶端要使用的網域名稱。
|
otSrpClientSetHostAddresses(otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses)
|
這個函式會設定/更新主機 IPv6 位址清單。
|
otSrpClientSetHostName(otInstance *aInstance, const char *aName)
|
這個函式會設定主機名稱標籤。
|
otSrpClientSetKeyLeaseInterval(otInstance *aInstance, uint32_t aInterval)
|
void
這個函式會設定 SRP 更新要求中使用的預設金鑰租借間隔。
|
otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval)
|
void
這個函式會設定 SRP 更新要求中使用的預設租賃間隔。
|
otSrpClientSetServiceKeyRecordEnabled(otInstance *aInstance, bool aEnabled)
|
void
這項功能可以啟用/停用「服務金鑰記錄納入」模式。
|
otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl)
|
void
這個函式會設定 SRP 更新要求中的每個記錄的存留時間值。
|
otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAddr)
|
這個函式會啟動 SRP 用戶端作業。
|
otSrpClientStop(otInstance *aInstance)
|
void
這個函式會停止 SRP 用戶端作業。
|
otSrpServerGetAddressMode(otInstance *aInstance)
|
這個函式會傳回 SRP 伺服器使用的地址模式。
|
otSrpServerGetAnycastModeSequenceNumber(otInstance *aInstance)
|
uint8_t
這個函式會傳回與 Anycast 位址模式搭配使用的序號。
|
otSrpServerGetDomain(otInstance *aInstance)
|
const char *
這個函式會傳回獲得授權的 SRP 伺服器網域。
|
otSrpServerGetLeaseConfig(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig)
|
void
這個函式會傳回 SRP 伺服器 LEASE 及 KEY-LEASE 設定。
|
otSrpServerGetNextHost(otInstance *aInstance, const otSrpServerHost *aHost)
|
const otSrpServerHost *
這個函式會傳回 SRP 伺服器上的下一個已註冊主機。
|
otSrpServerGetPort(otInstance *aInstance)
|
uint16_t
這個函式會傳回 SRP 伺服器監聽的通訊埠。
|
otSrpServerGetResponseCounters(otInstance *aInstance)
|
const otSrpServerResponseCounters *
這個函式會傳回 SRP 伺服器的回應計數器。
|
otSrpServerGetState(otInstance *aInstance)
|
這個函式會傳回 SRP 伺服器的狀態。
|
otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig)
|
void
這個函式會傳回 SRP 伺服器存留時間設定。
|
otSrpServerHandleServiceUpdateResult(otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError)
|
void
這個函式會將 SRP 更新套用至 SRP 伺服器的結果,
|
otSrpServerHostFindNextService(const otSrpServerHost *aHost, const otSrpServerService *aPrevService, otSrpServerServiceFlags aFlags, const char *aServiceName, const char *aInstanceName)
|
const otSrpServerService *
此函式會在主機中尋找下一個相符的服務。
|
otSrpServerHostGetAddresses(const otSrpServerHost *aHost, uint8_t *aAddressesNum)
|
const otIp6Address *
這個函式會傳回指定主機的位址。
|
otSrpServerHostGetFullName(const otSrpServerHost *aHost)
|
const char *
這個函式會傳回主機的全名。
|
otSrpServerHostGetLeaseInfo(const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo)
|
void
這個函式會傳回指定主機的 LEASE 和 KEY-LEASE 資訊。
|
otSrpServerHostGetNextService(const otSrpServerHost *aHost, const otSrpServerService *aService)
|
const otSrpServerService *
此函式會傳回指定主機的下一個服務 (不包括任何子類型服務)。
|
otSrpServerHostIsDeleted(const otSrpServerHost *aHost)
|
bool
這個函式會判斷 SRP 服務主機是否已刪除。
|
otSrpServerIsAutoEnableMode(otInstance *aInstance)
|
bool
這個函式可說明啟用或停用自動模式。
|
otSrpServerServiceGetFullName(const otSrpServerService *aService)
|
const char *
這個函式會傳回服務的完整服務執行個體名稱。
|
otSrpServerServiceGetHost(const otSrpServerService *aService)
|
const otSrpServerHost *
這個函式會傳回服務執行個體所在的主機。
|
otSrpServerServiceGetInstanceName(const otSrpServerService *aService)
|
const char *
這個函式會傳回服務的完整服務執行個體名稱。
|
otSrpServerServiceGetLeaseInfo(const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo)
|
void
這個函式會傳回指定服務的 LEASE 和 KEY-LEASE 資訊。
|
otSrpServerServiceGetPort(const otSrpServerService *aService)
|
uint16_t
這個函式會傳回服務執行個體的通訊埠。
|
otSrpServerServiceGetPriority(const otSrpServerService *aService)
|
uint16_t
這個函式會傳回服務執行個體的優先順序。
|
otSrpServerServiceGetServiceName(const otSrpServerService *aService)
|
const char *
這個函式會傳回服務的完整服務名稱。
|
otSrpServerServiceGetServiceSubTypeLabel(const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize)
|
這個函式會從服務名稱取得子類型標籤。
|
otSrpServerServiceGetTtl(const otSrpServerService *aService)
|
uint32_t
這個函式會傳回服務執行個體的存留時間。
|
otSrpServerServiceGetTxtData(const otSrpServerService *aService, uint16_t *aDataLength)
|
const uint8_t *
這個函式會傳回服務執行個體的 TXT 記錄資料。
|
otSrpServerServiceGetWeight(const otSrpServerService *aService)
|
uint16_t
這個函式會傳回服務執行個體的權重。
|
otSrpServerServiceIsDeleted(const otSrpServerService *aService)
|
bool
此函式會指出 SRP 服務是否已刪除。
|
otSrpServerServiceIsSubType(const otSrpServerService *aService)
|
bool
這個函式會指出 SRP 服務是否為子類型。
|
otSrpServerSetAddressMode(otInstance *aInstance, otSrpServerAddressMode aMode)
|
這個函式會設定供 SRP 伺服器使用的地址模式,
|
otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t aSequenceNumber)
|
這個函式會設定搭配 Anycast 地址模式使用的序號。
|
otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled)
|
void
這項功能會在 SRP 伺服器上啟用/停用自動啟用模式。
|
otSrpServerSetDomain(otInstance *aInstance, const char *aDomain)
|
這個函式會在 SRP 伺服器上設定網域。
|
otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled)
|
void
這項功能可以啟用/停用 SRP 伺服器。
|
otSrpServerSetLeaseConfig(otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig)
|
這個函式會設定 SRP 伺服器 LEASE 與 KEY-LEASE 設定。
|
otSrpServerSetServiceUpdateHandler(otInstance *aInstance, otSrpServerServiceUpdateHandler aServiceHandler, void *aContext)
|
void
這個函式會在 SRP 伺服器上設定 SRP 服務更新處理常式。
|
otSrpServerSetTtlConfig(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig)
|
這個函式會設定 SRP 伺服器存留時間設定。
|
結構 |
|
---|---|
otSrpClientBuffersServiceEntry |
這個結構代表 SRP 用戶端服務集區項目。 |
otSrpClientHostInfo |
這個結構代表 SRP 用戶端主機資訊。 |
otSrpClientService |
這個結構代表 SRP 用戶端服務。 |
otSrpServerLeaseConfig |
這個結構包括 SRP 伺服器 LEASE 和 KEY-LEASE 設定。 |
otSrpServerLeaseInfo |
這個結構包括主機/服務的 SRP 伺服器租借資訊。 |
otSrpServerResponseCounters |
此結構包含 SRP 伺服器回應的統計資料。 |
otSrpServerTtlConfig |
這個結構包括 SRP 伺服器存留時間設定。 |
列舉
匿名列舉
anonymous enum
屬性 | |
---|---|
OT_SRP_SERVER_SERVICE_FLAG_ACTIVE
|
內含使用中 (未刪除) 的服務。 |
OT_SRP_SERVER_SERVICE_FLAG_BASE_TYPE
|
納入基本服務 (而非子類型)。 |
OT_SRP_SERVER_SERVICE_FLAG_DELETED
|
納入已刪除的服務。 |
OT_SRP_SERVER_SERVICE_FLAG_SUB_TYPE
|
納入子類型服務。 |
匿名列舉
anonymous enum
屬性 | |
---|---|
OT_SRP_SERVER_FLAGS_ANY_SERVICE
|
此常數定義接受任何服務 (base/sub-type、active/deleted) 的 |
OT_SRP_SERVER_FLAGS_ANY_TYPE_ACTIVE_SERVICE
|
此常數定義接受任何有效服務 (未刪除) 的 |
OT_SRP_SERVER_FLAGS_ANY_TYPE_DELETED_SERVICE
|
此常數定義了接受任何已刪除服務的 |
OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY
|
這個常數會定義僅接受基本服務的 |
OT_SRP_SERVER_FLAGS_SUB_TYPE_SERVICE_ONLY
|
這個常數定義了只接受子類型的服務的 |
otSrpClientItemState
otSrpClientItemState
這個列舉項目會指定 SRP 用戶端項目 (服務或主機資訊) 狀態。
屬性 | |
---|---|
OT_SRP_CLIENT_ITEM_STATE_ADDING
|
正在新增/註冊商品。 |
OT_SRP_CLIENT_ITEM_STATE_REFRESHING
|
正在重新整理項目。 |
OT_SRP_CLIENT_ITEM_STATE_REGISTERED
|
此伺服器已向伺服器註冊。 |
OT_SRP_CLIENT_ITEM_STATE_REMOVED
|
項目已移除。 |
OT_SRP_CLIENT_ITEM_STATE_REMOVING
|
正在移除項目。 |
OT_SRP_CLIENT_ITEM_STATE_TO_ADD
|
要新增/註冊的項目。 |
OT_SRP_CLIENT_ITEM_STATE_TO_REFRESH
|
要重新整理的項目 (重新註冊即可續訂)。 |
OT_SRP_CLIENT_ITEM_STATE_TO_REMOVE
|
要移除的項目。 |
otSrpServerAddressMode
otSrpServerAddressMode
這項列舉代表 SRP 伺服器使用的地址模式,
位址模式會指定 SRP 伺服器如何決定位址和通訊埠號碼,以及如何在 Thread 網路資料中發布這項資訊。
屬性 | |
---|---|
OT_SRP_SERVER_ADDRESS_MODE_ANYCAST
|
Anycast 地址模式。 |
OT_SRP_SERVER_ADDRESS_MODE_UNICAST
|
單集位址模式。 |
OTSrpServerState
otSrpServerState
這項列舉代表 SRP 伺服器的狀態。
屬性 | |
---|---|
OT_SRP_SERVER_STATE_DISABLED
|
SRP 伺服器已停用。 |
OT_SRP_SERVER_STATE_RUNNING
|
SRP 伺服器已啟用並執行。 |
OT_SRP_SERVER_STATE_STOPPED
|
SRP 伺服器已啟用,但已停止。 |
Typedefs
otSrpClientAutoStartCallback
void(* otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext)
這個函式指標類型會定義 SRP 用戶端在自動啟動或停止時用來通知使用者的回呼。
只有在已啟用自動啟動功能 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
時,才能使用此功能。
當你啟用自動啟動模式,且 SRP 用戶端會自動啟動或停止時,系統會叫用這個回呼。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientBuffersServiceEntry
struct otSrpClientBuffersServiceEntry otSrpClientBuffersServiceEntry
這個結構代表 SRP 用戶端服務集區項目。
otSrpClientCallback
void(* otSrpClientCallback)(otError aError, const otSrpClientHostInfo *aHostInfo, const otSrpClientService *aServices, const otSrpClientService *aRemovedServices, void *aContext)
這個函式指標類型用於定義 SRP 用戶端用來通知使用者變更/事件/錯誤的回呼。
成功透過 SRP 伺服器註冊更新 (例如新增/移除主機資訊資訊和/或部分服務) 時,或是發生失敗或錯誤 (例如伺服器拒絕更新要求或用戶端逾時回應等) 時,就會叫用這個回呼。
如果成功重新註冊更新,aError
參數將會 OT_ERROR_NONE
,並且會將主機資訊和完整的服務清單做為回呼的輸入參數。請注意,主機資訊和服務均會在相關資料結構的對應 mState
成員變數中追蹤自己的狀態 (這個狀態表示主機-資訊/服務是否已註冊,還是仍新增/移除等)。
在回呼中,已移除的服務清單會以自己的連結清單 aRemovedServices
的形式傳送。請注意,在叫用回呼時,SRP 用戶端 (OpenThread 實作) 會透過 aRemovedServices
中列出的已移除服務執行個體完成,且不再追蹤/儲存這些執行個體 (例如,如果從回呼中呼叫 otSrpClientGetServices()
,則已移除的服務不會顯示在傳回的清單中)。在回呼中提供個別已移除的服務,有助使用者瞭解目前已移除的項目,並允許使用者重新領取/重複使用執行個體。
如果伺服器拒絕 SRP 更新要求,DNS 回應代碼 (RFC 2136) 就會對應至下列錯誤:
- (0) NOERROR 成功 (沒有錯誤條件) -> OT_ERROR_NONE
- (1) FORMERR 伺服器因格式錯誤而無法解讀 -> OT_ERROR_PARSE
- (2) SERVFAIL 伺服器發生內部錯誤,- OT_ERROR_FAILED
- (3) 應該有的 NXDOMAIN 名稱不存在 -> OT_ERROR_NOT_FOUND
- (4) NOTIMP 伺服器不支援查詢類型 (OpCode) -> OT_ERROR_NOT_IMPLEMENTED
- (5) REFused 伺服器因政策/安全性原因而遭拒 -> OT_ERROR_SECURITY
- (6) YXDOMAIN 部分名稱不應存在,確實存在 -> OT_ERROR_DUPLICATED
- (7) YXRRSET 部分不應有的 RRset 確實存在 ->> OT_ERROR_DUPLICATED
- (8) NXRRSET 一些應有存在的 RRset,不存在 ->> OT_ERROR_NOT_FOUND
- (9) NOTAUTH 服務並未取得可用區 -> 授權,OT_ERROR_SECURITY
- (10) NOTZONE A 不在可用區中 ->;OT_ERROR_PARSE
- (20) BADNAME 名稱無效 -> OT_ERROR_PARSE
- (21) BADALG 演算法不佳 -> OT_ERROR_SECURITY
- (22) BADTRUN 無效截斷 -> OT_ERROR_PARSE
- 其他回應代碼 -> OT_ERROR_FAILED
以下錯誤也可能發生:
- OT_ERROR_QUESTION_TIMEOUT:等待伺服器回應逾時 (用戶端會繼續重試)。
- OT_ERROR_INVALID_ARGS:提供的服務結構無效 (例如服務名稱不佳或
otDnsTxtEntry
)。 - OT_ERROR_NO_BUFS:額度不足,無法準備或傳送更新訊息。
請注意,在失敗的情況下,用戶端會繼續執行作業,也就是說,會等待一段時間,然後 (S) 將 SRP 更新訊息傳送至伺服器。重試等待間隔是從最小值開始,且隨著每次失敗的成長因子而遞增,直到達到最大值為止 (詳情請參閱設定參數 OPENTHREAD_CONFIG_SRP_CLIENT_MIN_RETRY_WAIT_INTERVAL
和相關參數)。
詳細資料 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
otSrpClientService
struct otSrpClientService otSrpClientService
這個結構代表 SRP 用戶端服務。
這個結構的執行個體 (從 otSrpClientAddService()
或 otSrpClientRemoveService()
傳遞至 OpenThread) 之後,「必須」保持名稱且保持不變。
mState
、mData
、mNext
欄位只會由 OT Core 使用/管理。在 otSrpClientAddService()
或 otSrpClientRemoveService()
或其他函式中傳遞 otSrpClientService
執行個體時,系統會忽略其值。呼叫端不需要設定這些欄位。
mLease
和 mKeyLease
欄位會指定此服務的所需租賃間隔和金鑰保留間隔。零值表示間隔未指定,然後使用此服務的預設租賃間隔或otSrpClientGetLeaseInterval()
和otSrpClientGetKeyLeaseInterval()
。如果金鑰租賃間隔 (不論明確設定或從預設確定) 少於服務的租借間隔,SRP 用戶端也會重複使用金鑰租賃間隔的值做為金鑰租借間隔。舉例來說,如果服務 mLease
已明確設為 2 天,而 mKeyLease
設為零,而預設的金鑰租借功能設為 1 天,則在註冊這項服務時,這項服務的要求金鑰保留時間也會設為 2 天。
otSrpServerAddressMode
enum otSrpServerAddressMode otSrpServerAddressMode
這項列舉代表 SRP 伺服器使用的地址模式,
位址模式會指定 SRP 伺服器如何決定位址和通訊埠號碼,以及如何在 Thread 網路資料中發布這項資訊。
otSrpServerLeaseConfig
struct otSrpServerLeaseConfig otSrpServerLeaseConfig
這個結構包括 SRP 伺服器 LEASE 和 KEY-LEASE 設定。
otSrpServerResponse 計數器
struct otSrpServerResponseCounters otSrpServerResponseCounters
此結構包含 SRP 伺服器回應的統計資料。
otSrpServerServiceFlags
uint8_t otSrpServerServiceFlags
您可以在服務旗標類型中,指定要在 SRP 服務清單中搜尋 (或疊代) 哪些服務。
這是位元標記的組合。特定的位元旗標在列舉 OT_SRP_SERVER_FLAG_*
中定義。
otSrpServerServiceUpdateHandler
void(* otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId, const otSrpServerHost *aHost, uint32_t aTimeout, void *aContext)
這個函式會處理 SRP 服務更新。
SRP 伺服器會呼叫此函式來通知正在更新 SRP 主機,而且可能會更新 SRP 服務。請務必等待 SRP 更新完成後,再由處理常式呼叫 otSrpServerHandlingServiceUpdateResult 或 aTimeout
逾時,以傳回結果。
SRP 服務觀測器應在收到更新事件後立即呼叫 otSrpServerHandlingServiceUpdateResult,並提供錯誤代碼 OT_ERROR_NONE。
通用的處理常式可以在 SRP 主機/服務上執行驗證,如果驗證失敗,則拒絕 SRP 更新。舉例來說,廣告 Proxy 應透過支援多播功能的連結來代管 (或移除) 主機和服務,且會在失敗時傳回特定錯誤代碼。
詳細資料 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
otSrpServerSetServiceUpdateHandler
otSrpServerHandleServiceUpdateResult
otSrpServerServiceUpdateId
uint32_t otSrpServerServiceUpdateId
SRP 伺服器上的 SRP 服務更新交易 ID。
Functions
otSrpClientAddService
otError otSrpClientAddService( otInstance *aInstance, otSrpClientService *aService )
這項函式會新增要向伺服器註冊的服務。
成功呼叫這個函式後,系統會呼叫 otSrpClientCallback
以向 SRP 伺服器回報服務新增/註冊狀態。
aService
指向的 otSrpClientService
執行個體「必須」保持不變,且從這個函式傳回後保持不變 (包含 OT_ERROR_NONE
)。OpenThread 會將指標儲存至服務執行個體。
OpenThread 不再追蹤otSrpClientService
執行個體,且只有在以下情況才能收回:
- 系統會透過移除
otSrpClientRemoveService()
的方式明確移除這個方法,或是藉由呼叫otSrpClientRemoveHostAndServices() and only after the
otSrpCallCallback` 來與其他服務移除,表示服務已移除。或者,您也可以 - 呼叫
otSrpClientClearHostAndServices()
會立即移除主機和所有相關服務。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpClientBuffersAllocateService
otSrpClientBuffersServiceEntry * otSrpClientBuffersAllocateService( otInstance *aInstance )
這個函式會從集區分配新的服務項目。
傳回的服務項目執行個體將初始化,如下所示:
mService.mName
將指向分配的字串緩衝區,且您可以使用函式otSrpClientBuffersGetServiceEntryServiceNameString()
擷取。mService.mInstanceName
將指向分配的字串緩衝區,且您可以使用函式otSrpClientBuffersGetServiceEntryInstanceNameString()
擷取。mService.mSubTypeLabels
指向從otSrpClientBuffersGetSubTypeLabelsArray()
傳回的陣列。mService.mTxtEntries
將指向mTxtEntry
。mService.mNumTxtEntries
將設為 1。- 其他
mService
欄位 (通訊埠、優先順序、權重) 會設為 0。 mTxtEntry.mKey
設為 NULL (系統會將值視為已編碼)。mTxtEntry.mValue
將指向分配的緩衝區,可使用函式otSrpClientBuffersGetServiceEntryTxtBuffer()
擷取。- 「
mTxtEntry.mValueLength
」已設為零。 - 所有相關資料/字串緩衝區和陣列都會清除至零。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向新分配的服務項目,如果集區中沒有更多項目,則指向 NULL。
|
otSrpClientBuffersFreeAllServices
void otSrpClientBuffersFreeAllServices( otInstance *aInstance )
這個函式會釋出先前分配的所有服務項目。
詳細資料 | |||
---|---|---|---|
參數 |
|
otSrpClientBuffersFreeService
void otSrpClientBuffersFreeService( otInstance *aInstance, otSrpClientBuffersServiceEntry *aService )
這個函式會釋出先前分配的服務項目。
aService
先前「必須」使用 otSrpClientBuffersAllocateService()
分配,尚未釋出。否則,這個函式的行為未定義。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientBuffersGetHostAddressArray
otIp6Address * otSrpClientBuffersGetHostAddressesArray( otInstance *aInstance, uint8_t *aArrayLength )
這個函式會接收做為 SRP 用戶端主機位址清單的 IPv6 位址項目陣列。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向
otIp6Address 項目陣列的指標 (在 aArrayLength 中傳回項目數量)。 |
otSrpClientBuffersGetHostNameString
char * otSrpClientBuffersGetHostNameString( otInstance *aInstance, uint16_t *aSize )
這個函式會取得用於 SRP 用戶端主機名稱的字串緩衝區。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向 SRP 用戶端主機名稱的字元緩衝區。
|
otSrpClientBuffersGetServiceEntryInstanceNameString
char * otSrpClientBuffersGetServiceEntryInstanceNameString( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
這個函式會從服務項目取得服務執行個體名稱的字串緩衝區。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
字串緩衝區的指標。
|
otSrpClientBuffersGetServiceEntryServiceNameString
char * otSrpClientBuffersGetServiceEntryServiceNameString( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
這個函式會從服務項目取得服務名稱的字串緩衝區。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
字串緩衝區的指標。
|
otSrpClientBuffersGetServiceEntryTxtBuffer
uint8_t * otSrpClientBuffersGetServiceEntryTxtBuffer( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize )
這個函式會從服務項目取得 TXT 記錄的緩衝區。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
緩衝區的指標。
|
otSrpClientBuffersGetSubTypeLabelsArray
const char ** otSrpClientBuffersGetSubTypeLabelsArray( otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength )
這個函式會從服務項目取得服務子類型標籤的陣列。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向陣列的指標。
|
otSrpClientClearHostAndServices
void otSrpClientClearHostAndServices( otInstance *aInstance )
這項功能會清除所有主機資訊和所有服務。
有別於 otSrpClientRemoveHostAndServices()
將更新訊息傳送至伺服器來移除所有資訊,這個函式會立即清除所有資訊,且不必與伺服器互動。
詳細資料 | |||
---|---|---|---|
參數 |
|
otSrpClearClearService
otError otSrpClientClearService( otInstance *aInstance, otSrpClientService *aService )
這個函式會清除服務,立即從服務清單中移除服務。
和 otSrpClientRemoveService()
不同之處在於,伺服器將更新訊息傳送至伺服器來移除服務,而函式會在用戶端的服務清單中清除服務,而不會與伺服器互動。成功呼叫這個函式時,系統不會呼叫 otSrpClientCallback
,而呼叫端會立即收回 aService
項目並重複使用。
此函式可以與 otSrpClientAddService()
的後續呼叫搭配使用 (可能會重複使用相同的 aService
項目使用相同的服務與執行個體名稱),以更新現有服務中的部分參數。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpClientDisableAutoStartMode
void otSrpClientDisableAutoStartMode( otInstance *aInstance )
這個函式會停用自動啟動模式。
您必須啟用自動啟動功能 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
,才能使用此功能。
停用自動啟動模式並不會使用戶端已在運作,但會停止監控執行緒執行緒資料,確認所選的 SRP 伺服器仍存在中。
請注意,呼叫 otSrpClientStop()
也會停用自動啟動模式。
詳細資料 | |||
---|---|---|---|
參數 |
|
otSrpClientEnableAutoHostAddress
otError otSrpClientEnableAutoHostAddress( otInstance *aInstance )
這項功能會啟用自動主機位址模式。
啟用主機 IPv6 位址時,SRP 用戶端會使用 Thread netif 上的所有單點位址自動設定 (不包括所有連結本機與網格本機位址)。如果沒有任何有效的地址,系統就會新增網格本機 EID 位址。執行緒 netif.
您可以選擇在自動啟動 SRP 用戶端作業期間或運作期間啟用自動主機位址模式,但主機資訊遭到移除時 (用戶端正在處理對 otSrpClientRemoveHostAndServices()
呼叫的移除要求,且主機資訊仍處於 STATE_TO_REMOVE
或 STATE_REMOVING
狀態)。
啟用自動主機位址模式後,只要呼叫 otSrpClientSetHostAddresses()
明確設定主機位址,即可停用此功能。
詳細資料 | |||||
---|---|---|---|---|---|
傳回值 |
|
otSrpClientEnableAutoStartMode
void otSrpClientEnableAutoStartMode( otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext )
這個函式會啟用自動啟動模式。
您必須啟用自動啟動功能 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
,才能使用此功能。
設定選項 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE
會指定預設的自動啟動模式 (在 OT 堆疊啟動時為啟用或停用)。
啟用「自動啟動」功能後,SRP 用戶端就會監控「執行緒網路」資料來探索 SRP 伺服器,並選取偏好的伺服器,並在偵測到 SRP 伺服器時自動啟動和停止用戶端。
「網路資料項目」有三個類別,表示它們存在 SRP。這些規則具有以下順序:
1) 偏好的服務項目,其中伺服器位址已納入服務資料中。如有多個選項,建議採用數字最小的 IPv6 位址。
2) 任何 Anycast 項目,都有一個序列號碼。RFC-1982 中,從序號判斷該數字序列所含的序號較大,因此視為較近期且建議使用。如果定義為明確序列,則使用序號的數字最大的序號 (亦即,序列數字大於所有其他序號)。如果沒有明確定義,則建議使用數值最大的序號。
3) 伺服器位址資料 (包含在伺服器資料中的單向項目)。如有多個選項,建議採用數字最小的 IPv6 位址。
「網路資料」項目出現變更時,用戶端會確認「網路資料」中仍有目前所選的伺服器,且仍為偏好的伺服器。否則,用戶端會切換至新的偏好伺服器,如果沒有,則會停止。
在這種情況下,只有明確的 otSrpClientStop()
呼叫會停止用戶端。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otSrpClientGetDomainName
const char * otSrpClientGetDomainName( otInstance *aInstance )
這項函式會取得 SRP 用戶端使用的網域名稱。
必須啟用 OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
,才能使用這個函式。
如未設定網域名稱,系統會使用「default.service.arpa」
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
網域名稱字串。
|
otSrpClientGetHostInfo
const otSrpClientHostInfo * otSrpClientGetHostInfo( otInstance *aInstance )
這個函式會取得主機資訊。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向主機資訊結構的指標。
|
otSrpClientGetKeyLeaseInterval
uint32_t otSrpClientGetKeyLeaseInterval( otInstance *aInstance )
這個函式會取得 SRP 更新要求中使用的預設金鑰租借間隔。
預設間隔僅適用於 mKeyLease
設為 0 的 otSrpClientService
執行個體。
請注意,這是 SRP 用戶端要求的租期。伺服器可能會選擇接受不同的租賃間隔。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
金鑰租借間隔 (以秒為單位)。
|
otSrpClientGetLeaseInterval
uint32_t otSrpClientGetLeaseInterval( otInstance *aInstance )
這個函式會取得在 SRP 更新要求中使用的預設租賃間隔。
預設間隔僅適用於 mLease
設為 0 的 otSrpClientService
執行個體。
請注意,這是 SRP 用戶端要求的租期。伺服器可能會選擇接受不同的租賃間隔。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
租賃間隔 (以秒為單位)。
|
otSrpClientGetServerAddress
const otSockAddr * otSrpClientGetServerAddress( otInstance *aInstance )
這個函式會取得 SRP 用戶端使用的 SRP 伺服器通訊端位址 (IPv6 位址和通訊埠號碼)。
如果用戶端並未執行,位址則未指定 (全部為零),通訊埠編號為 0。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向 SRP 伺服器通訊端位址的網址 (一律為非 NULL)。
|
otSrpClientGetServices
const otSrpClientService * otSrpClientGetServices( otInstance *aInstance )
這個函式會取得用戶端管理的服務清單。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向所有服務的連結清單標題,如果清單空白,則會指向 NULL。
|
otSrpClientGetTtl
uint32_t otSrpClientGetTtl( otInstance *aInstance )
這個函式會取得 SRP 更新要求中的每個記錄的存留時間值。
請注意,這是 SRP 用戶端要求的存留時間。伺服器可能會選擇接受其他存留時間。
根據預設,存留時間將等於租賃間隔。透過 otSrpClientSetTtl()
傳送 0 或大於租賃間隔的值也會使 TTL 等於租期。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
存留時間 (以秒為單位)。
|
otSrpClientIsAutoStartModeEnabled
bool otSrpClientIsAutoStartModeEnabled( otInstance *aInstance )
這個函式表示自動啟動模式 (已啟用或已停用) 的目前狀態。
您必須啟用自動啟動功能 OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE
,才能使用此功能。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如已啟用自動開始模式,則傳回 TRUE,否則為 FALSE。
|
otSrpClientIsRunning
bool otSrpClientIsRunning( otInstance *aInstance )
這個函式會指出 SRP 用戶端是否正在執行。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如果 SRP 用戶端正在執行,則為 TRUE,否則傳回 FALSE。
|
otSrpClientIsServiceKeyRecordEnabled
bool otSrpClientIsServiceKeyRecordEnabled( otInstance *aInstance )
這種方法表示「服務金鑰記錄包含」模式為啟用或停用。
啟用「OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
」設定後,才能使用這個函式。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如果已啟用「服務金鑰記錄納入」模式,則傳回 TRUE,否則為 FALSE。
|
otSrpClientItemStateToString
const char * otSrpClientItemStateToString( otSrpClientItemState aItemState )
這個函式會將 otSrpClientItemState
轉換為字串。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
代表
aItemState 的字串。 |
otSrpClientRemoveHostAndServices
otError otSrpClientRemoveHostAndServices( otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer )
這項函式會開始移除主機資訊和所有服務。
從這個函式傳回後,系統會呼叫 otSrpClientCallback
以向 SRP 伺服器回報移除要求的狀態。
如果主機資訊將從伺服器中永久移除,則應將 aRemoveKeyLease
設為 true
,藉此移除與伺服器上的主機相關聯的金鑰租借資訊。否則,系統會保留金鑰租借記錄,確保伺服器在用戶端再次提供及註冊服務時保留保留的主機名稱。
主機資訊尚未向伺服器註冊時,aSendUnregToServer
會決定行為。如果將 aSendUnregToServer
設為 false
(此為預設值/預期值),SRP 用戶端會立即移除主機資訊和服務,且不會將更新訊息傳送至伺服器 (如果尚未註冊伺服器,則無需更新伺服器)。如果將 aSendUnregToServer
設為 true
,SRP 用戶端就會傳送更新訊息至伺服器,請注意,如果已註冊主機資訊,aSendUnregToServer
的值就沒有影響,SRP 用戶端一律會向伺服器傳送更新訊息,要求移除所有資訊。
在裝置重設/重新啟動的情況下,aSendUnregToServer
非常實用。呼叫端可能會移除先前與伺服器註冊的任何服務。在這種情況下,呼叫端可以 otSrpClientSetHostName()
,然後以 aSendUnregToServer
要求 otSrpClientRemoveHostAndServices()
做為 true
。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpClientRemoveService
otError otSrpClientRemoveService( otInstance *aInstance, otSrpClientService *aService )
這項函式要求向伺服器取消註冊服務。
成功呼叫此函式後,系統會呼叫 otSrpClientCallback
以向 SRP 伺服器回報移除要求的狀態。
aService
指向的 otSrpClientService
執行個體「必須」在 OT_ERROR_NONE
函式傳回後保持不變,且保持不變。OpenThread 會在服務移除期間保留服務執行個體。呼叫 otSrpClientCallback
後,才會從 SRP 用戶端服務清單中移除服務執行個體,且可以釋出/重複使用。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpClientSetCallback
void otSrpClientSetCallback( otInstance *aInstance, otSrpClientCallback aCallback, void *aContext )
這個函式會設定回呼,以通知呼叫者 SRP 用戶端的事件/變更。
SRP 用戶端允許註冊單一回呼。因此,對這個函式的連續呼叫會覆寫任何先前設定的回呼函式。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otSrpClientSetDomainName
otError otSrpClientSetDomainName( otInstance *aInstance, const char *aName )
這個函式會設定 SRP 用戶端要使用的網域名稱。
必須啟用 OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE
,才能使用這個函式。
如未設定,系統會使用 'default.service.arpa"。
aName
指向的名稱字串緩衝區必須保留下來,在傳回這個函式後保持不變。OpenThread 會保留指標的字串。
不論是在用戶端啟動前或開始之後,都是在伺服器註冊主機資訊前設定的網域名稱 (主機資訊應位於 STATE_TO_ADD
或 STATE_TO_REMOVE
)。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpClientSetHostAddress
otError otSrpClientSetHostAddresses( otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses )
這個函式會設定/更新主機 IPv6 位址清單。
使用者可以在 SRP 用戶端開始或運作期間設定/變更主機 IPv6 位址,例如新增/移除或變更先前註冊的主機位址,但主機資訊遭到移除時 (用戶端忙於處理先前向 otSrpClientRemoveHostAndServices()
發出的移除要求,以及主機資訊仍處於 STATE_TO_REMOVE
或 STATE_REMOVING
狀態)。
aIp6Addresses
指向的主機 IPv6 位址陣列「必須」保持不變,並在傳回這個函式後 (使用 OT_ERROR_NONE
) 保持不變。OpenThread 會將指標儲存至陣列。
成功呼叫這個函式後,系統會呼叫 otSrpClientCallback
以向 SRP 伺服器回報地址註冊狀態。
如果先前曾呼叫成功呼叫 otSrpClientEnableAutoHostAddress()
,就會呼叫自動主機位址模式。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpClientSetHostName
otError otSrpClientSetHostName( otInstance *aInstance, const char *aName )
這個函式會設定主機名稱標籤。
成功呼叫這個函式後,系統會呼叫 otSrpClientCallback
以向 SRP 伺服器回報主機資訊註冊狀態。
aName
指向的名稱字串緩衝區必須保留下來,在傳回這個函式後保持不變。OpenThread 會保留指標的字串。
您可以設定在用戶端開始前或啟動伺服器前,要先設定主機名稱 (主機資訊應為 STATE_TO_ADD
或 STATE_REMOVED
)。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpClientSetKeyLeaseInterval
void otSrpClientSetKeyLeaseInterval( otInstance *aInstance, uint32_t aInterval )
這個函式會設定 SRP 更新要求中使用的預設金鑰租借間隔。
預設間隔僅適用於 mKeyLease
設為 0 的 otSrpClientService
執行個體。
變更租借間隔時間不會影響已登錄的服務/主機資訊的接受間隔時間。這只會影響日後的 SRP 更新訊息,也就是新增服務和/或更新現有服務。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientSetLeaseInterval
void otSrpClientSetLeaseInterval( otInstance *aInstance, uint32_t aInterval )
這個函式會設定 SRP 更新要求中使用的預設租賃間隔。
預設間隔僅適用於 mLease
設為 0 的 otSrpClientService
執行個體。
變更租借間隔時間不會影響已登錄的服務/主機資訊的接受間隔時間。這只會影響日後的 SRP 更新訊息,也就是新增服務和/或現有服務的重新整理。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientSetServiceKeyRecordEnabled
void otSrpClientSetServiceKeyRecordEnabled( otInstance *aInstance, bool aEnabled )
這項功能可以啟用/停用「服務金鑰記錄納入」模式。
啟用這項設定後,SRP 用戶端就會在傳送的 SRP 更新訊息中,加入「服務說明」指示的「KEY 記錄」。
啟用「OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
」設定後,才能使用這個函式。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientSetTtl
void otSrpClientSetTtl( otInstance *aInstance, uint32_t aTtl )
這個函式會設定 SRP 更新要求中的每個記錄的存留時間值。
變更存留時間不會影響已註冊服務/主機資訊的存留時間。這只會影響日後的 SRP 更新訊息 (也就是新增服務和/或重新整理現有服務)。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpClientStart
otError otSrpClientStart( otInstance *aInstance, const otSockAddr *aServerSockAddr )
這個函式會啟動 SRP 用戶端作業。
滿足下列所有條件後,SRP 用戶端會準備並傳送「SRP Update」訊息並傳送給 SRP 伺服器:
- SRP 用戶端已啟動 - 呼叫
otSrpClientStart()
。 - 已設定主機名稱 - 會呼叫
otSrpClientSetHostName()
。 - 至少設定了一個主機 IPv6 位址,並呼叫
otSrpClientSetHostName()
。 - 已新增至少一個服務 - 呼叫
otSrpClientAddService()
。
呼叫這些函式的順序為何。符合所有條件時,SRP 用戶端會等待一小段時間,再準備「SRP Update」訊息並傳送給伺服器。這段延遲時間可讓使用者在傳送第一筆 SRP 更新訊息之前,新增多項服務和/或 IPv6 位址 (確保所有 SRP 更新都傳送包含所有資訊)。OPENTHREAD_CONFIG_SRP_CLIENT_UPDATE_TX_DELAY
設定會指定延遲時間間隔。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpClientStop
void otSrpClientStop( otInstance *aInstance )
這個函式會停止 SRP 用戶端作業。
這個函式會停止與 SRP 伺服器進一步互動。請注意,這項操作不會移除或清除主機資訊和/或服務清單。此標記會表示用戶端啟動 (重新啟動) 後,將再次新增/移除的服務。
詳細資料 | |||
---|---|---|---|
參數 |
|
otSrpServerGetAddressMode
otSrpServerAddressMode otSrpServerGetAddressMode( otInstance *aInstance )
這個函式會傳回 SRP 伺服器使用的地址模式。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
SRP 伺服器的位址模式。
|
otSrpServerGetAnycastModeSequenceNumber
uint8_t otSrpServerGetAnycastModeSequenceNumber( otInstance *aInstance )
這個函式會傳回與 Anycast 位址模式搭配使用的序號。
序列號碼包含在「DNS/SRP 服務 Anycast 地址」中,而列於網路資料中的項目。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
Anycast 序號。
|
otSrpServerGetDomain
const char * otSrpServerGetDomain( otInstance *aInstance )
這個函式會傳回獲得授權的 SRP 伺服器網域。
如果未設定 SetDomain,則系統會傳回 "default.service.arpa."。即使網域未設定,一律會附加結尾的圓點。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向已串連網域字串的指標。
|
otSrpServerGetLeaseConfig
void otSrpServerGetLeaseConfig( otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig )
這個函式會傳回 SRP 伺服器 LEASE 及 KEY-LEASE 設定。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerGetNextHost
const otSrpServerHost * otSrpServerGetNextHost( otInstance *aInstance, const otSrpServerHost *aHost )
這個函式會傳回 SRP 伺服器上的下一個已註冊主機。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向已註冊主機的指標。如果找不到更多主機,則為 NULL。
|
otSrpServerGetPort
uint16_t otSrpServerGetPort( otInstance *aInstance )
這個函式會傳回 SRP 伺服器監聽的通訊埠。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
SRP 伺服器的通訊埠。如果伺服器並未執行,則會傳回 0。
|
otSrpServerGetResponseCounters
const otSrpServerResponseCounters * otSrpServerGetResponseCounters( otInstance *aInstance )
這個函式會傳回 SRP 伺服器的回應計數器。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向 SRP 伺服器回應計數器的指標。
|
otSrpServerGetState
otSrpServerState otSrpServerGetState( otInstance *aInstance )
這個函式會傳回 SRP 伺服器的狀態。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
SRP 伺服器的目前狀態。
|
otSrpServerGetTtlConfig
void otSrpServerGetTtlConfig( otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig )
這個函式會傳回 SRP 伺服器存留時間設定。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerHandleServiceUpdateResult
void otSrpServerHandleServiceUpdateResult( otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError )
這個函式會將 SRP 更新套用至 SRP 伺服器的結果,
Service Update 處理常式應呼叫此函式,以傳回 SRP 更新處理的結果。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otSrpServerHostFindNextService
const otSrpServerService * otSrpServerHostFindNextService( const otSrpServerHost *aHost, const otSrpServerService *aPrevService, otSrpServerServiceFlags aFlags, const char *aServiceName, const char *aInstanceName )
此函式會在主機中尋找下一個相符的服務。
旗標和服務與執行個體名稱的組合,可讓您疊代完整的服務清單及/或符合特定條件的子集,或尋找特定服務。
如何疊代主機的所有服務:service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_ANY_SERVICE, NULL, NULL);
僅針對基礎服務進行疊代 (排除子類型):service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY, NULL, NULL);
如要疊代特定執行個體名稱 instanceName
的子類型,service = otSrpServerHostFindNextService(host, service, OT_SRP_SERVER_FLAGS_SUB_TYPE_SERVICE_ONLY, NULL, instanceName);
如要尋找服務名稱為「serviceName
」以及服務執行個體名稱「instanceName
」的特定服務,例如 service = otSrpServerHostFindNextService(host, NULL, OT_SRP_SERVER_FLAGS_ANY_SERVICE, serviceName, instanceName);
如要尋找具有指定服務執行個體名稱 instanceName
的基本類型服務,service = otSrpServerHostFindNextService(host, NULL, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY, NULL, instanceName);
詳細資料 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||
傳回 |
指向下一個相符的服務的指標,如果找不到相符的服務,則會傳回 NULL。
|
otSrpServerHostGetAddress
const otIp6Address * otSrpServerHostGetAddresses( const otSrpServerHost *aHost, uint8_t *aAddressesNum )
這個函式會傳回指定主機的位址。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向 IPv6 位址陣列的指標。
|
otSrpServerHostGetFullName
const char * otSrpServerHostGetFullName( const otSrpServerHost *aHost )
這個函式會傳回主機的全名。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向空值主機名稱字串的字串。
|
otSrpServerHostGetLeaseInfo
void otSrpServerHostGetLeaseInfo( const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo )
這個函式會傳回指定主機的 LEASE 和 KEY-LEASE 資訊。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerHostGetNextService
const otSrpServerService * otSrpServerHostGetNextService( const otSrpServerHost *aHost, const otSrpServerService *aService )
此函式會傳回指定主機的下一個服務 (不包括任何子類型服務)。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向下一個服務的指標,如果沒有其他服務,則指向 NULL。
|
otSrpServerHostIs 已刪除
bool otSrpServerHostIsDeleted( const otSrpServerHost *aHost )
這個函式會判斷 SRP 服務主機是否已刪除。
您可以刪除 SRP 服務主機,但保留名稱供日後使用。在此情況下,主機執行個體不會從 SRP 伺服器/登錄檔中移除。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如果主機已刪除,則傳回 TRUE;如果未刪除,則傳回 FALSE。
|
otSrpServerIsAutoEnableMode
bool otSrpServerIsAutoEnableMode( otInstance *aInstance )
這個函式可說明啟用或停用自動模式。
這個函式需要 OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
個功能。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpServerServiceGetFullName
const char * otSrpServerServiceGetFullName( const otSrpServerService *aService )
這個函式會傳回服務的完整服務執行個體名稱。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向空值服務執行個體名稱字串的指標。
|
otSrpServerServiceGetHost
const otSrpServerHost * otSrpServerServiceGetHost( const otSrpServerService *aService )
這個函式會傳回服務執行個體所在的主機。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向主機執行個體的指標。
|
otSrpServerServiceGetInstanceName
const char * otSrpServerServiceGetInstanceName( const otSrpServerService *aService )
這個函式會傳回服務的完整服務執行個體名稱。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向空值服務執行個體名稱字串的指標。
|
otSrpServerServiceGetLeaseInfo
void otSrpServerServiceGetLeaseInfo( const otSrpServerService *aService, otSrpServerLeaseInfo *aLeaseInfo )
這個函式會傳回指定服務的 LEASE 和 KEY-LEASE 資訊。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerServiceGetPort
uint16_t otSrpServerServiceGetPort( const otSrpServerService *aService )
這個函式會傳回服務執行個體的通訊埠。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
服務的通訊埠。
|
otSrpServerServiceGet 優先順序
uint16_t otSrpServerServiceGetPriority( const otSrpServerService *aService )
這個函式會傳回服務執行個體的優先順序。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
服務的優先順序。
|
otSrpServerServiceGetServiceName
const char * otSrpServerServiceGetServiceName( const otSrpServerService *aService )
這個函式會傳回服務的完整服務名稱。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向空值服務名稱字串的指標。
|
otSrpServerServiceGetServiceSubTypeLabel
otError otSrpServerServiceGetServiceSubTypeLabel( const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize )
這個函式會從服務名稱取得子類型標籤。
aService
是子類型 (例如服務的 otSrpServerServiceIsSubType()
會傳回 TRUE。如果不是子類型,此函式會傳回 OT_ERROR_INVALID_ARGS
。
子類型服務的完整服務名稱遵循「
複製到 aLabel
緩衝區。
即使傳回失敗,aLabel
可確保在傳回後一律為空值結尾。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otSrpServerServiceGetTtl
uint32_t otSrpServerServiceGetTtl( const otSrpServerService *aService )
這個函式會傳回服務執行個體的存留時間。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
服務執行個體的存留時間。
|
otSrpServerServiceGetTxtData
const uint8_t * otSrpServerServiceGetTxtData( const otSrpServerService *aService, uint16_t *aDataLength )
這個函式會傳回服務執行個體的 TXT 記錄資料。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向 TXT 記錄資料的緩衝區指標 (TXT 資料長度會傳回
aDataLength )。 |
otSrpServerServiceGetWeight
uint16_t otSrpServerServiceGetWeight( const otSrpServerService *aService )
這個函式會傳回服務執行個體的權重。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
服務的權重。
|
otSrpServerServiceIs 已刪除
bool otSrpServerServiceIsDeleted( const otSrpServerService *aService )
此函式會指出 SRP 服務是否已刪除。
您可以刪除 SRP 服務,並保留服務名稱以供日後使用。在這種情況下,服務執行個體不會從 SRP 伺服器/登錄檔中移除。我們無法保證在主機遭到刪除後刪除所有服務。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如果服務已刪除,則傳回 TRUE;如果服務不存在,則傳回 FALSE。
|
otSrpServerServiceIsSubType
bool otSrpServerServiceIsSubType( const otSrpServerService *aService )
這個函式會指出 SRP 服務是否為子類型。
詳細資料 | |||
---|---|---|---|
參數 |
|
||
傳回 |
如果服務是子類型,則傳回 TRUE;如果不是子類型,則傳回 FALSE。
|
otSrpServerSetAddressMode
otError otSrpServerSetAddressMode( otInstance *aInstance, otSrpServerAddressMode aMode )
這個函式會設定供 SRP 伺服器使用的地址模式。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpServerSetAnycastModeSequenceNumber
otError otSrpServerSetAnycastModeSequenceNumber( otInstance *aInstance, uint8_t aSequenceNumber )
這個函式會設定搭配 Anycast 地址模式使用的序號。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpServerSetAutoEnableMode
void otSrpServerSetAutoEnableMode( otInstance *aInstance, bool aEnabled )
這項功能會在 SRP 伺服器上啟用/停用自動啟用模式。
這個函式需要 OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
個功能。
啟用此模式後,邊界轉送管理員會控制是否啟用或停用 SRP 伺服器。如果邊界轉送功能啟用/啟動時,系統會自動啟用 SRP 伺服器,並先完成初始前置字串和路徑設定 (需先確定 OMR 和連結連結前置字元,且基礎架構的廣播廣告訊息會發布至基礎架構,並發布至 Thread 網路資料中)。如果 BR 停止 (例如基礎架構基礎架構停止運作或 BR 卸離),SRP 伺服器就會自動停用。
只要透過 aEnabled
設為 false
的 otSrpServerSetAutoEnableMode()
呼叫或是透過呼叫 otSrpServerSetEnabled()
函式明確啟用或停用 SRP 伺服器,即可停用此模式。使用 otSrpServerSetAutoEnableMode(false)
停用自動啟用模式並不會變更 SRP 伺服器目前的狀態 (例如已啟用該模式)。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerSetDomain
otError otSrpServerSetDomain( otInstance *aInstance, const char *aDomain )
這個函式會在 SRP 伺服器上設定網域。
結尾的點會附加到 aDomain
(如果尚未加入)。您必須啟用 SRP 伺服器,才能呼叫此函式。
詳細資料 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otSrpServerSetEnabled
void otSrpServerSetEnabled( otInstance *aInstance, bool aEnabled )
這項功能可以啟用/停用 SRP 伺服器。
在邊界路由器上,建議你改用 otSrpServerSetAutoEnableMode()
。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
otSrpServerSetLeaseConfig
otError otSrpServerSetLeaseConfig( otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig )
這個函式會設定 SRP 伺服器 LEASE 與 KEY-LEASE 設定。
當用戶端要求非零的 LEASE 時間時,授予的值會限制為 [aMinLease, aMaxLease];非零 KEY-LEASE 的授予範圍為 [aMinKeyLease, aMaxKeyLease]。如為 LEASE 或 KEY-LEASE 時間,則系統會授予零。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otSrpServerSetServiceUpdateHandler
void otSrpServerSetServiceUpdateHandler( otInstance *aInstance, otSrpServerServiceUpdateHandler aServiceHandler, void *aContext )
這個函式會在 SRP 伺服器上設定 SRP 服務更新處理常式。
詳細資料 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otSrpServerSetTtlConfig
otError otSrpServerSetTtlConfig( otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig )
這個函式會設定 SRP 伺服器存留時間設定。
無論存留時間下限和上限為何,授予的存留時間一律不得大於透過 otSrpServerSetLeaseConfig()
設定的最高租借間隔。
詳細資料 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
資源
OpenThread API 參考資料主題出自原始碼,可於 GitHub 取得。如需更多資訊,或想參閱我們的說明文件,請參閱資源。