WizziLab / modem_ref_v5_3_217

Dependents:   modem_ref_helper_for_v5_3_217

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers alp_helpers.h Source File

alp_helpers.h

Go to the documentation of this file.
00001 /// @copyright
00002 /// ========================================================================={{{
00003 /// Copyright (c) 2012-2013 WizziLab                                           /
00004 /// All rights reserved                                                        /
00005 ///                                                                            /
00006 /// IMPORTANT: This Software may not be modified, copied or distributed unless /
00007 /// embedded on a WizziLab product. Other than for the foregoing purpose, this /
00008 /// Software and/or its documentation may not be used, reproduced, copied,     /
00009 /// prepared derivative works of, modified, performed, distributed, displayed  /
00010 /// or sold for any purpose. For the sole purpose of embedding this Software   /
00011 /// on a WizziLab product, copy, modification and distribution of this         /
00012 /// Software is granted provided that the following conditions are respected:  /
00013 ///                                                                            /
00014 /// *  Redistributions of source code must retain the above copyright notice,  /
00015 ///    this list of conditions and the following disclaimer                    /
00016 ///                                                                            /
00017 /// *  Redistributions in binary form must reproduce the above copyright       /
00018 ///    notice, this list of conditions and the following disclaimer in the     /
00019 ///    documentation and/or other materials provided with the distribution.    /
00020 ///                                                                            /
00021 /// *  The name of WizziLab can not be used to endorse or promote products     /
00022 ///    derived from this software without specific prior written permission.   /
00023 ///                                                                            /
00024 /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS        /
00025 /// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED  /
00026 /// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR /
00027 /// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR          /
00028 /// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,      /
00029 /// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,        /
00030 /// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,            /
00031 /// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY     /
00032 /// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    /
00033 /// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS         /
00034 /// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.               /
00035 /// WIZZILAB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,       /
00036 /// ENHANCEMENTS OR MODIFICATIONS.                                             /
00037 ///                                                                            /
00038 /// Should you have any questions regarding your right to use this Software,   /
00039 /// contact WizziLab at www.wizzilab.com.                                      /
00040 ///                                                                            /
00041 /// =========================================================================}}}
00042 /// @endcopyright
00043 
00044 //  =======================================================================
00045 /// @file           alp_helpers.h
00046 /// @defgroup       ALP
00047 /// @brief          ALP helpers functions
00048 //  =======================================================================
00049 
00050 #ifndef __ALP_HELPERS_H__
00051 #define __ALP_HELPERS_H__
00052 
00053 #include "hal_types.h"
00054 //======================================================================
00055 //======================================================================
00056 //  ALP Helpers
00057 //======================================================================
00058 //======================================================================
00059 typedef struct {
00060     u8*             data;   // data
00061     int             type;
00062     union
00063     {
00064         struct {
00065             u32             length;
00066             u32             offset;
00067             u8              fid;
00068         } f_data;
00069         struct {
00070             u32             length;
00071             u32             offset;
00072             u8              fid;
00073         } f_prop;
00074         struct {
00075             s8              code;
00076             u8              id; // Action ID
00077         } status;
00078         struct {
00079             u8              itf;
00080             s8              err;
00081         } istatus;
00082         struct {
00083             u32             length;
00084             u8              type;
00085         } itf;
00086         struct {
00087             u8              id;
00088             u8              eop;
00089             u8              err;
00090         } tag;
00091         struct {
00092             u32             per;
00093             u8              type;
00094             u8              ifid;
00095         } urc;
00096     } meta;
00097 } alp_parsed_chunk_t;
00098 
00099 //======================================================================
00100 // alp_size
00101 //----------------------------------------------------------------------
00102 /// @brief Return payload length of most ALP operations
00103 /// @param op       : ALP Action amongst alp_opcodes_t
00104 /// @param offset   : Associated Offset if relevant
00105 /// @param size     : Associated Size if relevant
00106 /// @retval payload size in bytes
00107 //======================================================================
00108 public uint alp_size(u8 op, u32 offset, u32 length);
00109 
00110 //======================================================================
00111 // alp_encode_length
00112 //----------------------------------------------------------------------
00113 /// @brief Encodes an ALP length/offset field
00114 /// @param p        : pointer to the payload buffer
00115 /// @param len      : value to be encoded
00116 /// @retval resulting payload size in bytes
00117 //======================================================================
00118 public u8 alp_encode_length(u8* p, u32 len);
00119 
00120 //======================================================================
00121 // alp_encode_length
00122 //----------------------------------------------------------------------
00123 /// @brief Decodes an ALP length/offset field
00124 /// @param p        : pointer to the pointer to payload buffer
00125 /// @param actp     : pointer to ALP's Action Protocol Substitution flag
00126 ///                   Result amongst alp_actp_substitution_mode_t
00127 /// @retval decoded value
00128 //======================================================================
00129 public u32 alp_decode_length(u8** p, u8* actp);
00130 
00131 //======================================================================
00132 // alp_parse_chunk
00133 //----------------------------------------------------------------------
00134 /// @brief Parses an ALP response payload to a more generic
00135 ///        alp_parsed_chunk_t structure.
00136 /// @param payload  : pointer to the pointer to payload buffer
00137 /// @param resp     : pointer to alp_parsed_chunk_t structure
00138 /// @retval number of parsed bytes
00139 //======================================================================
00140 public int alp_parse_chunk(u8** payload, alp_parsed_chunk_t* resp);
00141 
00142 
00143 
00144 #endif // __ALP_HELPERS_H__