Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / lwip / repo / lwip / src / apps / snmp / snmpv3_dummy.c
1 /**
2  * @file
3  * Dummy SNMPv3 functions.
4  */
5
6 /*
7  * Copyright (c) 2016 Elias Oenal.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  *    this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  *    this list of conditions and the following disclaimer in the documentation
17  *    and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * Author: Elias Oenal <lwip@eliasoenal.com>
33  *         Dirk Ziegelmeier <dirk@ziegelmeier.net>
34  */
35
36 #include "lwip/apps/snmpv3.h"
37 #include "snmpv3_priv.h"
38 #include <string.h>
39 #include "lwip/err.h"
40
41 #if LWIP_SNMP && LWIP_SNMP_V3
42
43 /**
44  *  @param username is a pointer to a string.
45  * @param auth_algo is a pointer to u8_t. The implementation has to set this if user was found.
46  * @param auth_key is a pointer to a pointer to a string. Implementation has to set this if user was found.
47  * @param priv_algo is a pointer to u8_t. The implementation has to set this if user was found.
48  * @param priv_key is a pointer to a pointer to a string. Implementation has to set this if user was found.
49  */
50 err_t
51 snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key)
52 {
53   const char* engine_id;
54   u8_t engine_id_len;
55   
56   if(strlen(username) == 0) {
57     return ERR_OK;
58   }
59   
60   if(memcmp(username, "lwip", 4) != 0) {
61     return ERR_VAL;
62   }
63   
64   snmpv3_get_engine_id(&engine_id, &engine_id_len);
65   
66   if(auth_key != NULL) {
67     snmpv3_password_to_key_sha((const u8_t*)"maplesyrup", 10,
68       (const u8_t*)engine_id, engine_id_len,
69       auth_key);
70     *auth_algo = SNMP_V3_AUTH_ALGO_SHA;
71   }
72   if(priv_key != NULL) {
73     snmpv3_password_to_key_sha((const u8_t*)"maplesyrup", 10,
74       (const u8_t*)engine_id, engine_id_len,
75       priv_key);
76     *priv_algo = SNMP_V3_PRIV_ALGO_DES;
77   }
78   return ERR_OK;
79 }
80
81 /**
82  * Get engine ID from persistence
83  * @param id
84  * @param len
85  */
86 void
87 snmpv3_get_engine_id(const char **id, u8_t *len)
88 {
89   *id = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02";
90   *len = 12;
91 }
92
93 /**
94  * Store engine ID in persistence
95  * @param id
96  * @param len
97  */
98 err_t
99 snmpv3_set_engine_id(const char *id, u8_t len)
100 {
101   LWIP_UNUSED_ARG(id);
102   LWIP_UNUSED_ARG(len);
103   return ERR_OK;
104 }
105
106 /**
107  * Get engine boots from persistence. Must be increased on each boot.
108  * @return 
109  */
110 u32_t
111 snmpv3_get_engine_boots(void)
112 {
113   return 0;
114 }
115
116 /**
117  * Store engine boots in persistence
118  * @param boots
119  */
120 void 
121 snmpv3_set_engine_boots(u32_t boots)
122 {
123   LWIP_UNUSED_ARG(boots);
124 }
125
126 /**
127  * RFC3414 2.2.2.
128  * Once the timer reaches 2147483647 it gets reset to zero and the
129  * engine boot ups get incremented.
130  */
131 u32_t
132 snmpv3_get_engine_time(void)
133 {
134   return 0;
135 }
136
137 /**
138  * Reset current engine time to 0
139  */
140 void
141 snmpv3_reset_engine_time(void)
142 {
143 }
144
145 #endif /* LWIP_SNMP && LWIP_SNMP_V3 */