~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to include/net-snmp/library/snmp_secmod.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-13 12:06:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040913120621-g952ntonlleihcvm
Tags: upstream-5.1.1
ImportĀ upstreamĀ versionĀ 5.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SNMPSECMOD_H
 
2
#define SNMPSECMOD_H
 
3
 
 
4
#ifdef __cplusplus
 
5
extern          "C" {
 
6
#endif
 
7
 
 
8
struct snmp_secmod_def;
 
9
 
 
10
/*
 
11
 * parameter information passed to security model routines
 
12
 */
 
13
struct snmp_secmod_outgoing_params {
 
14
    int             msgProcModel;
 
15
    u_char         *globalData;
 
16
    size_t          globalDataLen;
 
17
    int             maxMsgSize;
 
18
    int             secModel;
 
19
    u_char         *secEngineID;
 
20
    size_t          secEngineIDLen;
 
21
    char           *secName;
 
22
    size_t          secNameLen;
 
23
    int             secLevel;
 
24
    u_char         *scopedPdu;
 
25
    size_t          scopedPduLen;
 
26
    void           *secStateRef;
 
27
    u_char         *secParams;
 
28
    size_t         *secParamsLen;
 
29
    u_char        **wholeMsg;
 
30
    size_t         *wholeMsgLen;
 
31
    size_t         *wholeMsgOffset;
 
32
    netsnmp_pdu    *pdu;        /* IN - the pdu getting encoded            */
 
33
    netsnmp_session *session;   /* IN - session sending the message        */
 
34
};
 
35
 
 
36
struct snmp_secmod_incoming_params {
 
37
    int             msgProcModel;       /* IN */
 
38
    size_t          maxMsgSize; /* IN     - Used to calc maxSizeResponse.  */
 
39
 
 
40
    u_char         *secParams;  /* IN     - BER encoded securityParameters. */
 
41
    int             secModel;   /* IN */
 
42
    int             secLevel;   /* IN     - AuthNoPriv; authPriv etc.      */
 
43
 
 
44
    u_char         *wholeMsg;   /* IN     - Original v3 message.           */
 
45
    size_t          wholeMsgLen;        /* IN     - Msg length.                    */
 
46
 
 
47
    u_char         *secEngineID;        /* OUT    - Pointer snmpEngineID.          */
 
48
    size_t         *secEngineIDLen;     /* IN/OUT - Len available; len returned.   */
 
49
    /*
 
50
     * NOTE: Memory provided by caller.      
 
51
     */
 
52
 
 
53
    char           *secName;    /* OUT    - Pointer to securityName.       */
 
54
    size_t         *secNameLen; /* IN/OUT - Len available; len returned.   */
 
55
 
 
56
    u_char        **scopedPdu;  /* OUT    - Pointer to plaintext scopedPdu. */
 
57
    size_t         *scopedPduLen;       /* IN/OUT - Len available; len returned.   */
 
58
 
 
59
    size_t         *maxSizeResponse;    /* OUT    - Max size of Response PDU.      */
 
60
    void          **secStateRef;        /* OUT    - Ref to security state.         */
 
61
    netsnmp_session *sess;      /* IN     - session which got the message  */
 
62
    netsnmp_pdu    *pdu;        /* IN     - the pdu getting parsed         */
 
63
    u_char          msg_flags;  /* IN     - v3 Message flags.              */
 
64
};
 
65
 
 
66
 
 
67
/*
 
68
 * function pointers:
 
69
 */
 
70
 
 
71
/*
 
72
 * free's a given security module's data; called at unregistration time 
 
73
 */
 
74
typedef int     (SecmodSessionCallback) (netsnmp_session *);
 
75
typedef int     (SecmodPduCallback) (netsnmp_pdu *);
 
76
typedef int     (Secmod2PduCallback) (netsnmp_pdu *, netsnmp_pdu *);
 
77
typedef int     (SecmodOutMsg) (struct snmp_secmod_outgoing_params *);
 
78
typedef int     (SecmodInMsg) (struct snmp_secmod_incoming_params *);
 
79
typedef void    (SecmodFreeState) (void *);
 
80
 
 
81
/*
 
82
 * definition of a security module
 
83
 */
 
84
 
 
85
/*
 
86
 * all of these callback functions except the encoding and decoding
 
87
 * routines are optional.  The rest of them are available if need.  
 
88
 */
 
89
struct snmp_secmod_def {
 
90
    /*
 
91
     * session maniplation functions 
 
92
     */
 
93
    SecmodSessionCallback *session_open;        /* called in snmp_sess_open()  */
 
94
    SecmodSessionCallback *session_close;       /* called in snmp_sess_close() */
 
95
 
 
96
    /*
 
97
     * pdu manipulation routines 
 
98
     */
 
99
    SecmodPduCallback *pdu_free;        /* called in free_pdu() */
 
100
    Secmod2PduCallback *pdu_clone;      /* called in snmp_clone_pdu() */
 
101
    SecmodPduCallback *pdu_timeout;     /* called when request timesout */
 
102
    SecmodFreeState *pdu_free_state_ref;        /* frees pdu->securityStateRef */
 
103
 
 
104
    /*
 
105
     * de/encoding routines: mandatory 
 
106
     */
 
107
    SecmodOutMsg   *encode_reverse;     /* encode packet back to front */
 
108
    SecmodOutMsg   *encode_forward;     /* encode packet forward */
 
109
    SecmodInMsg    *decode;     /* decode & validate incoming */
 
110
};
 
111
 
 
112
 
 
113
/*
 
114
 * internal list
 
115
 */
 
116
struct snmp_secmod_list {
 
117
    int             securityModel;
 
118
    struct snmp_secmod_def *secDef;
 
119
    struct snmp_secmod_list *next;
 
120
};
 
121
 
 
122
 
 
123
/*
 
124
 * register a security service 
 
125
 */
 
126
int             register_sec_mod(int, const char *,
 
127
                                 struct snmp_secmod_def *);
 
128
/*
 
129
 * find a security service definition 
 
130
 */
 
131
struct snmp_secmod_def *find_sec_mod(int);
 
132
/*
 
133
 * register a security service 
 
134
 */
 
135
int             unregister_sec_mod(int);        /* register a security service */
 
136
void            init_secmod(void);
 
137
 
 
138
/*
 
139
 * clears the sec_mod list
 
140
 */
 
141
void            clear_sec_mod(void);
 
142
 
 
143
#ifdef __cplusplus
 
144
}
 
145
#endif
 
146
#endif                          /* SNMPSECMOD_H */