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

« back to all changes in this revision

Viewing changes to local/mib2c.notify.conf

  • 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
## -*- c -*-
 
2
######################################################################
 
3
## Do the .h file
 
4
######################################################################
 
5
@open ${name}.h@
 
6
/*
 
7
 * Note: this file originally auto-generated by mib2c using
 
8
 *        $Id: mib2c.notify.conf,v 5.2 2003/06/26 09:27:41 dts12 Exp $
 
9
 */
 
10
#ifndef $name.uc_H
 
11
#define $name.uc_H
 
12
 
 
13
/* function declarations */
 
14
@foreach $i notifications@
 
15
int send_${i}_trap(void);
 
16
@end@
 
17
 
 
18
#endif /* $name.uc_H */
 
19
######################################################################
 
20
## Do the .c file
 
21
######################################################################
 
22
@open ${name}.c@
 
23
/*
 
24
 * Note: this file originally auto-generated by mib2c using
 
25
 *        $Id: mib2c.notify.conf,v 5.2 2003/06/26 09:27:41 dts12 Exp $
 
26
 */
 
27
 
 
28
#include <net-snmp/net-snmp-config.h>
 
29
#include <net-snmp/net-snmp-includes.h>
 
30
#include <net-snmp/agent/net-snmp-agent-includes.h>
 
31
#include "${name}.h"
 
32
 
 
33
static oid snmptrap_oid[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
 
34
 
 
35
@foreach $i notifications@
 
36
int
 
37
send_${i}_trap( void );
 
38
{
 
39
    netsnmp_variable_list  *var_list = NULL;
 
40
    oid ${i}_oid[] = { $i.commaoid };
 
41
    @foreach $v varbinds@
 
42
    @if $v.isscalar@
 
43
    oid ${v}_oid[] = { $v.commaoid, 0 };
 
44
    @end@
 
45
    @if !$v.isscalar@
 
46
    oid ${v}_oid[] = { $v.commaoid, /* insert index here */ };
 
47
    @end@
 
48
    @end@
 
49
 
 
50
    /*
 
51
     * Set the snmpTrapOid.0 value
 
52
     */
 
53
    snmp_varlist_add_variable(&var_list,
 
54
        snmptrap_oid, OID_LENGTH(snmptrap_oid),
 
55
        ASN_OBJECT_ID,
 
56
        ${i}_oid, sizeof(${i}_oid));
 
57
    
 
58
    @if count_varbinds($i) > 0@
 
59
    /*
 
60
     * Add any objects from the trap definition
 
61
     */
 
62
    @end@
 
63
    @foreach $v varbinds@
 
64
    snmp_varlist_add_variable(&var_list,
 
65
        ${v}_oid, OID_LENGTH(${v}_oid),
 
66
        $v.type,
 
67
        /* Set an appropriate value for $v */
 
68
        NULL, 0);
 
69
    @end@
 
70
 
 
71
    /*
 
72
     * Add any extra (optional) objects here
 
73
     */
 
74
 
 
75
    /*
 
76
     * Send the trap to the list of configured destinations
 
77
     *  and clean up
 
78
     */
 
79
    send_v2trap( var_list );
 
80
    snmp_free_varbind( var_list );
 
81
 
 
82
    return SNMP_ERR_NOERROR;
 
83
}
 
84
@end@