From a2ad29ddc3a863b4190ca33cdebd7253576b3daa Mon Sep 17 00:00:00 2001
From: Freddie Chopin <freddie.chopin@gmail.com>
Date: Thu, 27 Feb 2014 22:50:58 +0100
Subject: [PATCH 6/6] SNMP: const-correctness around snmp traps and enterprise
 ID

---
 src/core/snmp/asn1_enc.c     | 4 ++--
 src/core/snmp/mib2.c         | 2 +-
 src/core/snmp/msg_out.c      | 2 +-
 src/include/lwip/snmp.h      | 2 +-
 src/include/lwip/snmp_asn1.h | 4 ++--
 src/include/lwip/snmp_msg.h  | 4 ++--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/core/snmp/asn1_enc.c b/src/core/snmp/asn1_enc.c
index 64dfc5f..435b8ff 100644
--- a/src/core/snmp/asn1_enc.c
+++ b/src/core/snmp/asn1_enc.c
@@ -139,7 +139,7 @@ snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed)
  * @param octets_needed points to the return value
  */
 void
-snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed)
+snmp_asn1_enc_oid_cnt(u8_t ident_len, const s32_t *ident, u16_t *octets_needed)
 {
   s32_t sub_id;
   u8_t cnt;
@@ -435,7 +435,7 @@ snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value)
  * @return ERR_OK if successfull, ERR_ARG if we can't (or won't) encode
  */
 err_t
-snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident)
+snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, const s32_t *ident)
 {
   u16_t plen, base;
   u8_t *msg_ptr;
diff --git a/src/core/snmp/mib2.c b/src/core/snmp/mib2.c
index 0c9ba9f..d46bff3 100644
--- a/src/core/snmp/mib2.c
+++ b/src/core/snmp/mib2.c
@@ -2022,7 +2022,7 @@ void snmp_inc_snmpouttraps(void)
   snmpouttraps++;
 }
 
-void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid)
+void snmp_get_snmpgrpid_ptr(const struct snmp_obj_id **oid)
 {
   *oid = &snmpgrp_id;
 }
diff --git a/src/core/snmp/msg_out.c b/src/core/snmp/msg_out.c
index 7e868b6..6a34b85 100644
--- a/src/core/snmp/msg_out.c
+++ b/src/core/snmp/msg_out.c
@@ -212,7 +212,7 @@ snmp_send_response(struct snmp_msg_pstat *m_stat)
  * (sysObjectID) for specific traps.
  */
 err_t
-snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
+snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific_trap)
 {
   struct snmp_trap_dst *td;
   struct netif *dst_if;
diff --git a/src/include/lwip/snmp.h b/src/include/lwip/snmp.h
index 4924ae2..c69616f 100644
--- a/src/include/lwip/snmp.h
+++ b/src/include/lwip/snmp.h
@@ -225,7 +225,7 @@ void snmp_inc_snmpoutgetnexts(void);
 void snmp_inc_snmpoutsetrequests(void);
 void snmp_inc_snmpoutgetresponses(void);
 void snmp_inc_snmpouttraps(void);
-void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid);
+void snmp_get_snmpgrpid_ptr(const struct snmp_obj_id **oid);
 void snmp_set_snmpenableauthentraps(u8_t *value);
 void snmp_get_snmpenableauthentraps(u8_t *value);
 
diff --git a/src/include/lwip/snmp_asn1.h b/src/include/lwip/snmp_asn1.h
index 605fa3f..e9ce9ce 100644
--- a/src/include/lwip/snmp_asn1.h
+++ b/src/include/lwip/snmp_asn1.h
@@ -84,12 +84,12 @@ err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_
 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
-void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
+void snmp_asn1_enc_oid_cnt(u8_t ident_len, const s32_t *ident, u16_t *octets_needed);
 err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
 err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
 err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value);
 err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value);
-err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
+err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, const s32_t *ident);
 err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw);
 
 #ifdef __cplusplus
diff --git a/src/include/lwip/snmp_msg.h b/src/include/lwip/snmp_msg.h
index aa4a30a..57879d2 100644
--- a/src/include/lwip/snmp_msg.h
+++ b/src/include/lwip/snmp_msg.h
@@ -265,7 +265,7 @@ struct snmp_msg_trap
   ip_addr_t dip;
 
   /* source enterprise ID (sysObjectID) */
-  struct snmp_obj_id *enterprise;
+  const struct snmp_obj_id *enterprise;
   /* source IP address, raw network order format */
   u8_t sip_raw[4];
   /* generic trap code */
@@ -302,7 +302,7 @@ struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root);
 /** Handle an internal (recv) or external (private response) event. */
 void snmp_msg_event(u8_t request_id);
 err_t snmp_send_response(struct snmp_msg_pstat *m_stat);
-err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap);
+err_t snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific_trap);
 void snmp_coldstart_trap(void);
 void snmp_authfail_trap(void);
 
-- 
1.8.3.msysgit.0

