Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
dhcp_service_api.h
00001 /* 00002 * Copyright (c) 2013-2015 ARM Limited. All rights reserved. 00003 * 00004 * SPDX-License-Identifier: LicenseRef-PBL 00005 * 00006 * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * https://www.mbed.com/licenses/PBL-1.0 00010 * 00011 * See the License for the specific language governing permissions and limitations under the License. 00012 * 00013 */ 00014 00015 #ifndef DHCP_SERVICE_API_H_ 00016 #define DHCP_SERVICE_API_H_ 00017 00018 #include <ns_types.h> 00019 /** 00020 * \file dhcp_service_api.h 00021 * \brief DHCP server connection interfaces 00022 * 00023 * \section dhcp-service DHCP Service Instance 00024 * - dhcp_service_init(), Initializes a DHCP service. 00025 * - dhcp_service_delete(), Removes the DHCP service. 00026 * 00027 * \section dhcp-msg DHCP Service Messages 00028 * - dhcp_service_send_req(), Sends out DHCP request messages. 00029 * - dhcp_service_send_resp(), Sends out DHCP response messages. 00030 * 00031 * \section dhcp-tim DHCP Service Timers (retry timers) 00032 * - dhcp_service_send_req(), Sends out DHCP request messages. 00033 * - dhcp_service_set_retry_timers(), Sets the retransmission parameters. 00034 * - dhcp_service_req_remove(), Stops retrying and retransmissions. 00035 * - dhcp_service_timer_tick(), Indicates if a timeout occurred. 00036 * 00037 */ 00038 00039 /** Defines Debug Trace String for DHCP service */ 00040 #define DHCP_SERVICE_API_TRACE_STR "DHcS" 00041 00042 /* 00043 * Return values for callbacks 00044 */ 00045 00046 /** Message belongs to someone else. */ 00047 #define RET_MSG_NOT_MINE 0 00048 /** Message is handled. */ 00049 #define RET_MSG_ACCEPTED 1 00050 /** Message is not the final one and needs to hold on a bit. */ 00051 #define RET_MSG_WAIT_ANOTHER -1 00052 /** Message is unexpected or corrupted. */ 00053 #define RET_MSG_CORRUPTED -2 00054 00055 /** \name DHCP options */ 00056 ///@{ 00057 #define TX_OPT_NONE 0x00 /**< No options. */ 00058 #define TX_OPT_USE_SHORT_ADDR 0x01 /**< Use short addresses. */ 00059 #define TX_OPT_MULTICAST_HOP_LIMIT_64 0x02 /**< Use multicast hop limit of 64. */ 00060 ///@} 00061 00062 /** 00063 * \brief DHCP Service receive callback. 00064 * 00065 * When the DHCP service receives a DHCP message it will go through a list of registered DHCP services instances 00066 * until some instance acknowledges that the message belongs to it. 00067 * \param instance_id An instance of registered server. 00068 * \param msg_tr_id The message transaction ID. 00069 * \param msg_ptr An allocated message pointer. Should not deallocate unless RET_MSG_ACCEPTED returned (then responsibility of client). 00070 * \param msg_len The length of the message. 00071 * 00072 * Return values 00073 * \return RET_MSG_ACCEPTED - Message is handled. 00074 * \return RET_MSG_CORRUPTED - Message is corrupted. 00075 * \return RET_MSG_NOT_MINE - Message belongs to someone else. 00076 */ 00077 00078 typedef int (dhcp_service_receive_req_cb)(uint16_t instance_id, uint32_t msg_tr_id, uint8_t msg_name, uint8_t *msg_ptr, uint16_t msg_len); 00079 00080 /** 00081 * \brief DHCP Service Message Response callback. 00082 * 00083 * When the DHCP service receives a response to a DHCP message, this callback receives it. 00084 * 00085 * \param instance_id An instance of a registered server. 00086 * \param ptr A pointer for the client object. 00087 * \param msg_ptr An allocated message pointer. Should not deallocate unless RET_MSG_ACCEPTED returned (then responsibility of client). 00088 * \param msg_len The length of the message. 00089 * 00090 * Return values 00091 * \return RET_MSG_ACCEPTED - Message is handled 00092 * \return RET_MSG_WAIT_ANOTHER - This message was not the last one for this transaction and a new reply is expected. 00093 */ 00094 00095 typedef int (dhcp_service_receive_resp_cb)(uint16_t instance_id, void *ptr, uint8_t msg_name, uint8_t *msg_ptr, uint16_t msg_len); 00096 00097 00098 /** 00099 * \brief Initialize the server instance. 00100 * 00101 * Creates and shares the socket for other DHCP services. 00102 * 00103 * \return Instance ID that is used to identify the service. 00104 */ 00105 00106 uint16_t dhcp_service_init(int8_t interface_id, dhcp_service_receive_req_cb *receive_req_cb); 00107 00108 /** 00109 * \brief Deletes a server instance. 00110 * 00111 * Removes all data related to this instance. 00112 * 00113 * \param instance The instance ID of the registered server. 00114 */ 00115 void dhcp_service_delete(uint16_t instance); 00116 00117 /** 00118 * \brief Sends a DHCP response message. 00119 * 00120 * \param msg_tr_id The message transaction ID. 00121 * \param options Options for this request. 00122 * \param msg_ptr An allocated message pointer. Should not deallocate unless RET_MSG_ACCEPTED returned (then responsibility of client). 00123 * \param msg_len The length of the message. 00124 * 00125 * \return 0, if everything went fine. 00126 * \return -1, if error occurred. 00127 */ 00128 int dhcp_service_send_resp(uint32_t msg_tr_id, uint8_t options, uint8_t *msg_ptr, uint16_t msg_len); 00129 00130 00131 /** 00132 * \brief Sends DHCP request message. 00133 * 00134 * Service takes care of retransmissions. 00135 * 00136 * \param instance_id The instance ID of the registered server. 00137 * \param options Options for this request. 00138 * \param ptr A void pointer to the client object. 00139 * \param addr The address of the server. 00140 * \param msg_ptr An allocated message pointer. This pointer is the responsibility of the service after this call. 00141 * \param msg_len The length of the message. 00142 * \param receive_resp_cb Callback pointer 00143 * 00144 * \return Transaction ID of the DHCP transaction 00145 * \return 0, if error occurred. 00146 */ 00147 uint32_t dhcp_service_send_req(uint16_t instance_id, uint8_t options, void *ptr, const uint8_t addr[static 16], uint8_t *msg_ptr, uint16_t msg_len, dhcp_service_receive_resp_cb *receive_resp_cb); 00148 00149 /** 00150 * \brief Setting retransmission parameters. 00151 * 00152 * Sets the retransmission parameters for this transaction. 00153 * 00154 * \param msg_tr_id The message transaction ID. 00155 * \param timeout_init An initial timeout value. 00156 * \param timeout_max The maximum timeout value when initial timeout is doubled with every retry. 00157 * \param retrans_max The maximum number of retries after which an error is received. 00158 * 00159 */ 00160 void dhcp_service_set_retry_timers(uint32_t msg_tr_id, uint16_t timeout_init, uint16_t timeout_max, uint8_t retrans_max); 00161 00162 /** 00163 * \brief Stops transactions for a message (retransmissions). 00164 * 00165 * Clears off sending retransmissions for a particular message transaction by finding it via its message transaction ID. 00166 * 00167 * \param msg_tr_id The message transaction ID. 00168 * 00169 */ 00170 void dhcp_service_req_remove(uint32_t msg_tr_id); 00171 00172 /** 00173 * \brief Timer tick function for retransmissions. 00174 * 00175 * Retransmission timer ticks should be increased with 100ms interval, if necessary. One tick is one millisecond. 00176 * 00177 */ 00178 bool dhcp_service_timer_tick(uint16_t ticks); 00179 00180 00181 #endif //DHCP_SERVICE_API_H_
Generated on Tue Jul 12 2022 12:28:29 by
