version of nsdl to work with lwm2m, updated RD parameters and location option handling
Dependents: ArchPro_LWM2M_LED_Client Weather_Station_LWM2M mbedEndpointNetwork
Fork of nanoservice_client_1_12 by
sn_coap_header_check.c@10:b5ecd6660d71, 2015-04-13 (annotated)
- Committer:
- michaeljkoster
- Date:
- Mon Apr 13 22:13:40 2015 +0000
- Revision:
- 10:b5ecd6660d71
- Parent:
- 0:aafd54b05111
Add error return from sn_nsdl_register_endpoint() in sn_nsdl.c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zdshelby | 0:aafd54b05111 | 1 | /** |
zdshelby | 0:aafd54b05111 | 2 | * \file sn_coap_header_check.c |
zdshelby | 0:aafd54b05111 | 3 | * |
zdshelby | 0:aafd54b05111 | 4 | * \brief CoAP Header validity checker |
zdshelby | 0:aafd54b05111 | 5 | * |
zdshelby | 0:aafd54b05111 | 6 | * Functionality: Checks validity of CoAP Header |
zdshelby | 0:aafd54b05111 | 7 | * |
zdshelby | 0:aafd54b05111 | 8 | * Created on: Aug 22, 2011 |
zdshelby | 0:aafd54b05111 | 9 | * Author: tero |
zdshelby | 0:aafd54b05111 | 10 | * |
zdshelby | 0:aafd54b05111 | 11 | * \note Supports draft-ietf-core-coap-18 |
zdshelby | 0:aafd54b05111 | 12 | */ |
zdshelby | 0:aafd54b05111 | 13 | |
zdshelby | 0:aafd54b05111 | 14 | /* * * * INCLUDE FILES * * * */ |
zdshelby | 0:aafd54b05111 | 15 | #include "nsdl_types.h" |
zdshelby | 0:aafd54b05111 | 16 | #include "sn_nsdl.h" |
zdshelby | 0:aafd54b05111 | 17 | #include "sn_coap_header.h" |
zdshelby | 0:aafd54b05111 | 18 | #include "sn_coap_protocol.h" |
zdshelby | 0:aafd54b05111 | 19 | #include "sn_coap_header_internal.h" |
zdshelby | 0:aafd54b05111 | 20 | #include "sn_coap_protocol_internal.h" |
zdshelby | 0:aafd54b05111 | 21 | |
zdshelby | 0:aafd54b05111 | 22 | /** |
zdshelby | 0:aafd54b05111 | 23 | * \fn int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_version_e coap_version) |
zdshelby | 0:aafd54b05111 | 24 | * |
zdshelby | 0:aafd54b05111 | 25 | * \brief Checks validity of given Header |
zdshelby | 0:aafd54b05111 | 26 | * |
zdshelby | 0:aafd54b05111 | 27 | * \param *src_coap_msg_ptr is source for building Packet data |
zdshelby | 0:aafd54b05111 | 28 | * \param coap_version is version of used CoAP specification |
zdshelby | 0:aafd54b05111 | 29 | * |
zdshelby | 0:aafd54b05111 | 30 | * \return Return value is status of validity check. In ok cases 0 and in |
zdshelby | 0:aafd54b05111 | 31 | * failure cases -1 |
zdshelby | 0:aafd54b05111 | 32 | */ |
zdshelby | 0:aafd54b05111 | 33 | int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_version_e coap_version) |
zdshelby | 0:aafd54b05111 | 34 | { |
zdshelby | 0:aafd54b05111 | 35 | /* * Check validity of CoAP Version * */ |
zdshelby | 0:aafd54b05111 | 36 | if (coap_version != COAP_VERSION_1) |
zdshelby | 0:aafd54b05111 | 37 | { |
zdshelby | 0:aafd54b05111 | 38 | return -1; |
zdshelby | 0:aafd54b05111 | 39 | } |
zdshelby | 0:aafd54b05111 | 40 | |
zdshelby | 0:aafd54b05111 | 41 | /* * Check validity of Message type * */ |
zdshelby | 0:aafd54b05111 | 42 | switch (src_coap_msg_ptr->msg_type) |
zdshelby | 0:aafd54b05111 | 43 | { |
zdshelby | 0:aafd54b05111 | 44 | case COAP_MSG_TYPE_CONFIRMABLE: |
zdshelby | 0:aafd54b05111 | 45 | case COAP_MSG_TYPE_NON_CONFIRMABLE: |
zdshelby | 0:aafd54b05111 | 46 | case COAP_MSG_TYPE_ACKNOWLEDGEMENT: |
zdshelby | 0:aafd54b05111 | 47 | case COAP_MSG_TYPE_RESET: |
zdshelby | 0:aafd54b05111 | 48 | break; /* Ok cases */ |
zdshelby | 0:aafd54b05111 | 49 | default: |
zdshelby | 0:aafd54b05111 | 50 | return -1; /* Failed case */ |
zdshelby | 0:aafd54b05111 | 51 | } |
zdshelby | 0:aafd54b05111 | 52 | |
zdshelby | 0:aafd54b05111 | 53 | /* * Check validity of Message code * */ |
zdshelby | 0:aafd54b05111 | 54 | switch (src_coap_msg_ptr->msg_code) |
zdshelby | 0:aafd54b05111 | 55 | { |
zdshelby | 0:aafd54b05111 | 56 | case COAP_MSG_CODE_EMPTY: |
zdshelby | 0:aafd54b05111 | 57 | case COAP_MSG_CODE_REQUEST_GET: |
zdshelby | 0:aafd54b05111 | 58 | case COAP_MSG_CODE_REQUEST_POST: |
zdshelby | 0:aafd54b05111 | 59 | case COAP_MSG_CODE_REQUEST_PUT: |
zdshelby | 0:aafd54b05111 | 60 | case COAP_MSG_CODE_REQUEST_DELETE: |
zdshelby | 0:aafd54b05111 | 61 | case COAP_MSG_CODE_RESPONSE_CREATED: |
zdshelby | 0:aafd54b05111 | 62 | case COAP_MSG_CODE_RESPONSE_DELETED: |
zdshelby | 0:aafd54b05111 | 63 | case COAP_MSG_CODE_RESPONSE_VALID: |
zdshelby | 0:aafd54b05111 | 64 | case COAP_MSG_CODE_RESPONSE_CHANGED: |
zdshelby | 0:aafd54b05111 | 65 | case COAP_MSG_CODE_RESPONSE_CONTENT: |
zdshelby | 0:aafd54b05111 | 66 | case COAP_MSG_CODE_RESPONSE_BAD_REQUEST: |
zdshelby | 0:aafd54b05111 | 67 | case COAP_MSG_CODE_RESPONSE_UNAUTHORIZED: |
zdshelby | 0:aafd54b05111 | 68 | case COAP_MSG_CODE_RESPONSE_BAD_OPTION: |
zdshelby | 0:aafd54b05111 | 69 | case COAP_MSG_CODE_RESPONSE_FORBIDDEN: |
zdshelby | 0:aafd54b05111 | 70 | case COAP_MSG_CODE_RESPONSE_NOT_FOUND: |
zdshelby | 0:aafd54b05111 | 71 | case COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED: |
zdshelby | 0:aafd54b05111 | 72 | case COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_INCOMPLETE: |
zdshelby | 0:aafd54b05111 | 73 | case COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE: |
zdshelby | 0:aafd54b05111 | 74 | case COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT: |
zdshelby | 0:aafd54b05111 | 75 | case COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR: |
zdshelby | 0:aafd54b05111 | 76 | case COAP_MSG_CODE_RESPONSE_NOT_IMPLEMENTED: |
zdshelby | 0:aafd54b05111 | 77 | case COAP_MSG_CODE_RESPONSE_BAD_GATEWAY: |
zdshelby | 0:aafd54b05111 | 78 | case COAP_MSG_CODE_RESPONSE_SERVICE_UNAVAILABLE: |
zdshelby | 0:aafd54b05111 | 79 | case COAP_MSG_CODE_RESPONSE_GATEWAY_TIMEOUT: |
zdshelby | 0:aafd54b05111 | 80 | case COAP_MSG_CODE_RESPONSE_PROXYING_NOT_SUPPORTED: |
zdshelby | 0:aafd54b05111 | 81 | break; /* Ok cases */ |
zdshelby | 0:aafd54b05111 | 82 | default: |
zdshelby | 0:aafd54b05111 | 83 | return -1; /* Failed case */ |
zdshelby | 0:aafd54b05111 | 84 | } |
zdshelby | 0:aafd54b05111 | 85 | |
zdshelby | 0:aafd54b05111 | 86 | /* Success */ |
zdshelby | 0:aafd54b05111 | 87 | return 0; |
zdshelby | 0:aafd54b05111 | 88 | } |
zdshelby | 0:aafd54b05111 | 89 |