Move /asn1 to /epan/dissectors
[metze/wireshark/wip.git] / epan / dissectors / asn1 / snmp / packet-snmp-template.h
1 /* packet-snmp.h
2  * Routines for snmp packet dissection
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef PACKET_SNMP_H
24 #define PACKET_SNMP_H
25
26 typedef struct _snmp_usm_key {
27         guint8* data;
28         guint len;
29 } snmp_usm_key_t;
30
31 typedef struct _snmp_ue_assoc_t snmp_ue_assoc_t;
32 typedef struct _snmp_usm_params_t snmp_usm_params_t;
33
34 typedef gboolean (*snmp_usm_authenticator_t)(snmp_usm_params_t*, guint8** calc_auth, guint* calc_auth_len, gchar const** error);
35 typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, gchar const** error);
36 typedef void (*snmp_usm_password_to_key_t)(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key);
37
38 typedef struct _snmp_usm_auth_model_t {
39         snmp_usm_password_to_key_t pass2key;
40         snmp_usm_authenticator_t authenticate;
41         guint key_size;
42 } snmp_usm_auth_model_t;
43
44 typedef struct _snmp_user_t {
45         snmp_usm_key_t userName;
46
47         snmp_usm_auth_model_t* authModel;
48         snmp_usm_key_t authPassword;
49         snmp_usm_key_t authKey;
50
51         snmp_usm_decoder_t privProtocol;
52         snmp_usm_key_t privPassword;
53         snmp_usm_key_t privKey;
54 } snmp_user_t;
55
56 typedef struct {
57         guint8* data;
58         guint len;
59 } snmp_engine_id_t;
60
61 struct _snmp_ue_assoc_t {
62         snmp_user_t user;
63         snmp_engine_id_t engine;
64         guint   auth_model;
65         guint   priv_proto;
66         struct _snmp_ue_assoc_t* next;
67 };
68
69 struct _snmp_usm_params_t {
70         gboolean authenticated;
71         gboolean encrypted;
72         guint start_offset;
73         guint auth_offset;
74
75         guint32 boots;
76         guint32 snmp_time;
77         tvbuff_t* engine_tvb;
78         tvbuff_t* user_tvb;
79         proto_item* auth_item;
80         tvbuff_t* auth_tvb;
81         tvbuff_t* priv_tvb;
82         tvbuff_t* msg_tvb;
83         snmp_ue_assoc_t* user_assoc;
84
85         gboolean authOK;
86 };
87
88 /*
89  * Guts of the SNMP dissector - exported for use by protocols such as
90  * ILMI.
91  */
92 extern guint dissect_snmp_pdu(tvbuff_t *, int, packet_info *, proto_tree *tree,
93     int, gint, gboolean);
94 extern int dissect_snmp_engineid(proto_tree *, packet_info *, tvbuff_t *, int, int);
95
96 /*#include "packet-snmp-exp.h"*/
97
98 #endif  /* PACKET_SNMP_H */