From 6c59bcdfbb2098621400952f8500d83ce51bb3a2 Mon Sep 17 00:00:00 2001 From: Vojtech Vilimek Date: Thu, 19 Oct 2023 16:08:13 +0200 Subject: [PATCH] SNMP: Remove old code --- proto/snmp/snmp.c | 3 --- proto/snmp/snmp.h | 6 ------ proto/snmp/subagent.c | 30 +++++++++++------------------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/proto/snmp/snmp.c b/proto/snmp/snmp.c index e0e5e59c6..bde36779b 100644 --- a/proto/snmp/snmp.c +++ b/proto/snmp/snmp.c @@ -134,8 +134,6 @@ snmp_cleanup(struct snmp_proto *p) rfree(p->lock); p->lock = NULL; - p->partial_response = NULL; - struct snmp_register *r, *r2; WALK_LIST_DELSAFE(r, r2, p->register_queue) { @@ -338,7 +336,6 @@ snmp_start(struct proto *P) p->to_send = 0; p->errs = 0; - p->partial_response = NULL; p->startup_timer = tm_new_init(p->pool, snmp_startup_timeout, p, 0, 0); p->ping_timer = tm_new_init(p->pool, snmp_ping_timeout, p, 0, 0); diff --git a/proto/snmp/snmp.h b/proto/snmp/snmp.h index b75050ec6..34c4e7d60 100644 --- a/proto/snmp/snmp.h +++ b/proto/snmp/snmp.h @@ -161,12 +161,6 @@ struct snmp_proto { uint to_send; uint errs; - - /* - * if the packet hasn't been fully recieved, partial_reponse points - * into the TX buffer to the Response-PDU header (needed for packet payload) - */ - struct agentx_response *partial_response; }; //void snmp_tx(sock *sk); diff --git a/proto/snmp/subagent.c b/proto/snmp/subagent.c index 43510dffb..47ec574d3 100644 --- a/proto/snmp/subagent.c +++ b/proto/snmp/subagent.c @@ -878,7 +878,7 @@ parse_gets2_pdu(struct snmp_proto *p, byte * const pkt_start, uint size, uint *s }; } - if (!p->partial_response && c.size < sizeof(struct agentx_response)) + if (c.size < sizeof(struct agentx_response)) { snmp_manage_tbuf(p, &c); // TODO renew pkt, pkt_start pointers context clen @@ -1033,8 +1033,6 @@ send:; snmp_log("sk_send error"); // TODO think through the error state - p->partial_response = NULL; - mb_free(o_start); mb_free(o_end); @@ -1051,7 +1049,6 @@ partial: (c.byte_ord) ? put_u32(&h->payload, pkt_size) : (h->payload = pkt_size); //snmp_log("new rx-buffer size %u", h->payload); *skip = AGENTX_HEADER_SIZE; - p->partial_response = response_header; /* number of bytes parsed from RX-buffer */ return pkt - pkt_start; @@ -1396,24 +1393,19 @@ prepare_response(struct snmp_proto *p, struct snmp_pdu *c) { //snmp_log("prepare_response()"); - if (!p->partial_response) - { - struct agentx_response *r = (void *) c->buffer; - struct agentx_header *h = &r->h; - - SNMP_BLANK_HEADER(h, AGENTX_RESPONSE_PDU); - SNMP_SESSION(h, p); + struct agentx_response *r = (void *) c->buffer; + struct agentx_header *h = &r->h; - /* protocol doesn't care about subagent upTime */ - STORE_U32(r->uptime, 0); - STORE_U16(r->error, AGENTX_RES_NO_ERROR); - STORE_U16(r->index, 0); + SNMP_BLANK_HEADER(h, AGENTX_RESPONSE_PDU); + SNMP_SESSION(h, p); - ADVANCE(c->buffer, c->size, sizeof(struct agentx_response)); - return r; - } + /* protocol doesn't care about subagent upTime */ + STORE_U32(r->uptime, 0); + STORE_U16(r->error, AGENTX_RES_NO_ERROR); + STORE_U16(r->index, 0); - return p->partial_response; + ADVANCE(c->buffer, c->size, sizeof(struct agentx_response)); + return r; } -- 2.47.2