| 1 |
/* |
| 2 |
* Redistribution and use in source and binary forms, with or without modification, |
| 3 |
* are permitted provided that the following conditions are met: |
| 4 |
* |
| 5 |
* 1. Redistributions of source code must retain the above copyright notice, |
| 6 |
* this list of conditions and the following disclaimer. |
| 7 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
| 8 |
* this list of conditions and the following disclaimer in the documentation |
| 9 |
* and/or other materials provided with the distribution. |
| 10 |
* 3. The name of the author may not be used to endorse or promote products |
| 11 |
* derived from this software without specific prior written permission. |
| 12 |
* |
| 13 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 14 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 15 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
| 16 |
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 17 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 18 |
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 19 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 20 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 21 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
| 22 |
* OF SUCH DAMAGE. |
| 23 |
* |
| 24 |
* This file is part of the lwIP TCP/IP stack. |
| 25 |
* |
| 26 |
* Author: Dirk Ziegelmeier <[email protected]> |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
#include "lwip/netif.h" |
| 31 |
#include "lwip/apps/snmp.h" |
| 32 |
#include "lwip/apps/snmp_mib2.h" |
| 33 |
#include "lwip/apps/snmpv3.h" |
| 34 |
#include "lwip/apps/snmp_snmpv2_framework.h" |
| 35 |
#include "lwip/apps/snmp_snmpv2_usm.h" |
| 36 |
#include "examples/snmp/snmp_v3/snmpv3_dummy.h" |
| 37 |
#include "examples/snmp/snmp_private_mib/private_mib.h" |
| 38 |
#include "snmp_example.h" |
| 39 |
|
| 40 |
#if LWIP_SNMP |
| 41 |
static const struct snmp_mib *mibs[] = { |
| 42 |
&mib2, |
| 43 |
&mib_private |
| 44 |
#if LWIP_SNMP_V3 |
| 45 |
, &snmpframeworkmib |
| 46 |
, &snmpusmmib |
| 47 |
#endif |
| 48 |
}; |
| 49 |
#endif /* LWIP_SNMP */ |
| 50 |
|
| 51 |
void |
| 52 |
snmp_example_init(void) |
| 53 |
{ |
| 54 |
#if LWIP_SNMP |
| 55 |
s32_t req_nr; |
| 56 |
lwip_privmib_init(); |
| 57 |
#if SNMP_LWIP_MIB2 |
| 58 |
#if SNMP_USE_NETCONN |
| 59 |
snmp_threadsync_init(&snmp_mib2_lwip_locks, snmp_mib2_lwip_synchronizer); |
| 60 |
#endif /* SNMP_USE_NETCONN */ |
| 61 |
snmp_mib2_set_syscontact_readonly((const u8_t*)"root", NULL); |
| 62 |
snmp_mib2_set_syslocation_readonly((const u8_t*)"lwIP development PC", NULL); |
| 63 |
snmp_mib2_set_sysdescr((const u8_t*)"lwIP example", NULL); |
| 64 |
#endif /* SNMP_LWIP_MIB2 */ |
| 65 |
|
| 66 |
#if LWIP_SNMP_V3 |
| 67 |
snmpv3_dummy_init(); |
| 68 |
#endif |
| 69 |
|
| 70 |
snmp_set_mibs(mibs, LWIP_ARRAYSIZE(mibs)); |
| 71 |
snmp_init(); |
| 72 |
|
| 73 |
snmp_trap_dst_ip_set(0, &netif_default->gw); |
| 74 |
snmp_trap_dst_enable(0, 1); |
| 75 |
|
| 76 |
snmp_send_inform_generic(SNMP_GENTRAP_COLDSTART, NULL, &req_nr); |
| 77 |
snmp_send_trap_generic(SNMP_GENTRAP_COLDSTART); |
| 78 |
|
| 79 |
#endif /* LWIP_SNMP */ |
| 80 |
} |