mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
SNMP: tiny preparation for SNMP to support more versions than just v1: store request version in struct snmp_msg_pstat so that the response can be sent with the same version (v2c might already work but getbulk is missing)
This commit is contained in:
parent
a22a92b481
commit
da5ccbf7d1
@ -1031,6 +1031,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
|
||||
snmp_inc_snmpinbadversions();
|
||||
return ERR_ARG;
|
||||
}
|
||||
m_stat->version = (u8_t)version;
|
||||
ofs += (1 + len_octets + len);
|
||||
snmp_asn1_dec_type(p, ofs, &type);
|
||||
derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len);
|
||||
|
@ -328,6 +328,7 @@ static u16_t
|
||||
snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len)
|
||||
{
|
||||
u16_t tot_len;
|
||||
s32_t snmp_req_ver;
|
||||
struct snmp_resp_header_lengths *rhl;
|
||||
|
||||
rhl = &m_stat->rhl;
|
||||
@ -352,7 +353,8 @@ snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len)
|
||||
snmp_asn1_enc_length_cnt(rhl->comlen, &rhl->comlenlen);
|
||||
tot_len += 1 + rhl->comlenlen + rhl->comlen;
|
||||
|
||||
snmp_asn1_enc_s32t_cnt(snmp_version, &rhl->verlen);
|
||||
snmp_req_ver = m_stat->version;
|
||||
snmp_asn1_enc_s32t_cnt(snmp_req_ver, &rhl->verlen);
|
||||
snmp_asn1_enc_length_cnt(rhl->verlen, &rhl->verlenlen);
|
||||
tot_len += 1 + rhl->verlen + rhl->verlenlen;
|
||||
|
||||
@ -496,6 +498,7 @@ static u16_t
|
||||
snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p)
|
||||
{
|
||||
u16_t ofs;
|
||||
s32_t snmp_req_ver;
|
||||
|
||||
ofs = 0;
|
||||
snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ));
|
||||
@ -507,7 +510,8 @@ snmp_resp_header_enc(struct snmp_msg_pstat *m_stat, struct pbuf *p)
|
||||
ofs += 1;
|
||||
snmp_asn1_enc_length(p, ofs, m_stat->rhl.verlen);
|
||||
ofs += m_stat->rhl.verlenlen;
|
||||
snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.verlen, snmp_version);
|
||||
snmp_req_ver = m_stat->version;
|
||||
snmp_asn1_enc_s32t(p, ofs, m_stat->rhl.verlen, snmp_req_ver);
|
||||
ofs += m_stat->rhl.verlen;
|
||||
|
||||
snmp_asn1_enc_type(p, ofs, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR));
|
||||
|
@ -226,6 +226,8 @@ struct snmp_msg_pstat
|
||||
ip_addr_t sip;
|
||||
/* source UDP port */
|
||||
u16_t sp;
|
||||
/* incoming snmp version */
|
||||
u8_t version;
|
||||
/* request type */
|
||||
u8_t rt;
|
||||
/* request ID */
|
||||
|
Loading…
x
Reference in New Issue
Block a user