PageRenderTime 90ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/release/src/router/snmp/include/net-snmp/library/snmpusm.h

https://gitlab.com/envieidoc/advancedtomato2
C Header | 238 lines | 185 code | 32 blank | 21 comment | 0 complexity | 157f7c1c31183687b6cec18da045b5c9 MD5 | raw file
  1. /*
  2. * snmpusm.h
  3. *
  4. * Header file for USM support.
  5. */
  6. #ifndef SNMPUSM_H
  7. #define SNMPUSM_H
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #define WILDCARDSTRING "*"
  12. /*
  13. * General.
  14. */
  15. #define USM_MAX_ID_LENGTH 1024 /* In bytes. */
  16. #define USM_MAX_SALT_LENGTH 128 /* In BITS. */
  17. #define USM_DES_SALT_LENGTH 64 /* In BITS. */
  18. #define USM_AES_SALT_LENGTH 128 /* In BITS. */
  19. #define USM_MAX_KEYEDHASH_LENGTH 128 /* In BITS. */
  20. #define USM_TIME_WINDOW 150
  21. #define USM_MD5_AND_SHA_AUTH_LEN 12 /* bytes */
  22. #define USM_MAX_AUTHSIZE USM_MD5_AND_SHA_AUTH_LEN
  23. #define USM_SEC_MODEL_NUMBER 3
  24. /*
  25. * Structures.
  26. */
  27. struct usmStateReference {
  28. char *usr_name;
  29. size_t usr_name_length;
  30. u_char *usr_engine_id;
  31. size_t usr_engine_id_length;
  32. oid *usr_auth_protocol;
  33. size_t usr_auth_protocol_length;
  34. u_char *usr_auth_key;
  35. size_t usr_auth_key_length;
  36. oid *usr_priv_protocol;
  37. size_t usr_priv_protocol_length;
  38. u_char *usr_priv_key;
  39. size_t usr_priv_key_length;
  40. u_int usr_sec_level;
  41. };
  42. /*
  43. * struct usmUser: a structure to represent a given user in a list
  44. */
  45. /*
  46. * Note: Any changes made to this structure need to be reflected in
  47. * the following functions:
  48. */
  49. struct usmUser;
  50. struct usmUser {
  51. u_char *engineID;
  52. size_t engineIDLen;
  53. char *name;
  54. char *secName;
  55. oid *cloneFrom;
  56. size_t cloneFromLen;
  57. oid *authProtocol;
  58. size_t authProtocolLen;
  59. u_char *authKey;
  60. size_t authKeyLen;
  61. oid *privProtocol;
  62. size_t privProtocolLen;
  63. u_char *privKey;
  64. size_t privKeyLen;
  65. u_char *userPublicString;
  66. int userStatus;
  67. int userStorageType;
  68. struct usmUser *next;
  69. struct usmUser *prev;
  70. };
  71. /*
  72. * Prototypes.
  73. */
  74. struct usmStateReference *usm_malloc_usmStateReference(void);
  75. void usm_free_usmStateReference(void *old);
  76. int usm_set_usmStateReference_name(struct usmStateReference
  77. *ref, char *name,
  78. size_t name_len);
  79. int usm_set_usmStateReference_engine_id(struct
  80. usmStateReference
  81. *ref,
  82. u_char * engine_id,
  83. size_t
  84. engine_id_len);
  85. int usm_set_usmStateReference_auth_protocol(struct
  86. usmStateReference
  87. *ref,
  88. oid *
  89. auth_protocol,
  90. size_t
  91. auth_protocol_len);
  92. int usm_set_usmStateReference_auth_key(struct
  93. usmStateReference
  94. *ref,
  95. u_char * auth_key,
  96. size_t
  97. auth_key_len);
  98. int usm_set_usmStateReference_priv_protocol(struct
  99. usmStateReference
  100. *ref,
  101. oid *
  102. priv_protocol,
  103. size_t
  104. priv_protocol_len);
  105. int usm_set_usmStateReference_priv_key(struct
  106. usmStateReference
  107. *ref,
  108. u_char * priv_key,
  109. size_t
  110. priv_key_len);
  111. int usm_set_usmStateReference_sec_level(struct
  112. usmStateReference
  113. *ref,
  114. int sec_level);
  115. #ifdef SNMP_TESTING_CODE
  116. void emergency_print(u_char * field, u_int length);
  117. #endif
  118. int asn_predict_int_length(int type, long number,
  119. size_t len);
  120. int asn_predict_length(int type, u_char * ptr,
  121. size_t u_char_len);
  122. int usm_set_salt(u_char * iv,
  123. size_t * iv_length,
  124. u_char * priv_salt,
  125. size_t priv_salt_length,
  126. u_char * msgSalt);
  127. int usm_parse_security_parameters(u_char * secParams,
  128. size_t remaining,
  129. u_char * secEngineID,
  130. size_t * secEngineIDLen,
  131. u_int * boots_uint,
  132. u_int * time_uint,
  133. char *secName,
  134. size_t * secNameLen,
  135. u_char * signature,
  136. size_t *
  137. signature_length,
  138. u_char * salt,
  139. size_t * salt_length,
  140. u_char ** data_ptr);
  141. int usm_check_and_update_timeliness(u_char * secEngineID,
  142. size_t secEngineIDLen,
  143. u_int boots_uint,
  144. u_int time_uint,
  145. int *error);
  146. SecmodOutMsg usm_secmod_generate_out_msg;
  147. SecmodOutMsg usm_secmod_generate_out_msg;
  148. SecmodInMsg usm_secmod_process_in_msg;
  149. int usm_generate_out_msg(int, u_char *, size_t, int, int,
  150. u_char *, size_t, char *, size_t,
  151. int, u_char *, size_t, void *,
  152. u_char *, size_t *, u_char **,
  153. size_t *);
  154. int usm_rgenerate_out_msg(int, u_char *, size_t, int, int,
  155. u_char *, size_t, char *, size_t,
  156. int, u_char *, size_t, void *,
  157. u_char **, size_t *, size_t *);
  158. int usm_process_in_msg(int, size_t, u_char *, int, int,
  159. u_char *, size_t, u_char *,
  160. size_t *, char *, size_t *,
  161. u_char **, size_t *, size_t *,
  162. void **, netsnmp_session *, u_char);
  163. int usm_check_secLevel(int level, struct usmUser *user);
  164. struct usmUser *usm_get_userList(void);
  165. struct usmUser *usm_get_user(u_char * engineID, size_t engineIDLen,
  166. char *name);
  167. struct usmUser *usm_get_user_from_list(u_char * engineID,
  168. size_t engineIDLen, char *name,
  169. struct usmUser *userList,
  170. int use_default);
  171. struct usmUser *usm_add_user(struct usmUser *user);
  172. struct usmUser *usm_add_user_to_list(struct usmUser *user,
  173. struct usmUser *userList);
  174. struct usmUser *usm_free_user(struct usmUser *user);
  175. struct usmUser *usm_create_user(void);
  176. struct usmUser *usm_create_initial_user(const char *name,
  177. const oid * authProtocol,
  178. size_t authProtocolLen,
  179. const oid * privProtocol,
  180. size_t privProtocolLen);
  181. struct usmUser *usm_cloneFrom_user(struct usmUser *from,
  182. struct usmUser *to);
  183. struct usmUser *usm_remove_user(struct usmUser *user);
  184. struct usmUser *usm_remove_user_from_list(struct usmUser *user,
  185. struct usmUser **userList);
  186. char *get_objid(char *line, oid ** optr, size_t * len);
  187. void usm_save_users(const char *token, const char *type);
  188. void usm_save_users_from_list(struct usmUser *user,
  189. const char *token,
  190. const char *type);
  191. void usm_save_user(struct usmUser *user, const char *token,
  192. const char *type);
  193. SNMPCallback usm_store_users;
  194. struct usmUser *usm_read_user(char *line);
  195. void usm_parse_config_usmUser(const char *token,
  196. char *line);
  197. void usm_set_password(const char *token, char *line);
  198. void usm_set_user_password(struct usmUser *user,
  199. const char *token, char *line);
  200. void init_usm(void);
  201. int init_usm_post_config(int majorid, int minorid,
  202. void *serverarg, void *clientarg);
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif /* SNMPUSM_H */