summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2023-11-06 11:04:42 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2023-11-06 11:04:42 +0000
commit426be7888c75278c3b73e826f845f162f71375ab (patch)
tree769a13cdc13ba0f33a79754372006d05a78d1e73 /usr.sbin/snmpd
parent415607828b0338ba391b6b0f0dea288e58077ab4 (diff)
Hook up agentx-{Add,Remove}AgentCaps-PDU to appl_{add,remove}agentcaps.
OK tb@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r--usr.sbin/snmpd/application_agentx.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/usr.sbin/snmpd/application_agentx.c b/usr.sbin/snmpd/application_agentx.c
index c661cda6192..3614ea9e183 100644
--- a/usr.sbin/snmpd/application_agentx.c
+++ b/usr.sbin/snmpd/application_agentx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: application_agentx.c,v 1.13 2023/10/27 10:23:58 martijn Exp $ */
+/* $OpenBSD: application_agentx.c,v 1.14 2023/11/06 11:04:41 martijn Exp $ */
/*
* Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org>
*
@@ -89,6 +89,8 @@ void appl_agentx_get(struct appl_backend *, int32_t, int32_t, const char *,
struct appl_varbind *);
void appl_agentx_getnext(struct appl_backend *, int32_t, int32_t, const char *,
struct appl_varbind *);
+void appl_agentx_addagentcaps(struct appl_agentx_session *, struct ax_pdu *);
+void appl_agentx_removeagentcaps(struct appl_agentx_session *, struct ax_pdu *);
void appl_agentx_response(struct appl_agentx_session *, struct ax_pdu *);
void appl_agentx_send(int, short, void *);
struct ber_oid *appl_agentx_oid2ber_oid(struct ax_oid *, struct ber_oid *);
@@ -436,11 +438,11 @@ appl_agentx_recv(int fd, short event, void *cookie)
event_add(&(conn->conn_wev), NULL);
break;
case AX_PDU_TYPE_ADDAGENTCAPS:
+ appl_agentx_addagentcaps(session, pdu);
+ break;
case AX_PDU_TYPE_REMOVEAGENTCAPS:
- log_warnx("%s: %s: not supported", name,
- ax_pdutype2string(pdu->ap_header.aph_type));
- error = APPL_ERROR_PROCESSINGERROR;
- goto fail;
+ appl_agentx_removeagentcaps(session, pdu);
+ break;
case AX_PDU_TYPE_RESPONSE:
appl_agentx_response(session, pdu);
break;
@@ -810,6 +812,57 @@ appl_agentx_getnext(struct appl_backend *backend, int32_t transactionid,
}
void
+appl_agentx_addagentcaps(struct appl_agentx_session *session,
+ struct ax_pdu *pdu)
+{
+ struct ber_oid oid;
+ enum appl_error error;
+
+ if (appl_agentx_oid2ber_oid(&(pdu->ap_payload.ap_addagentcaps.ap_oid),
+ &oid) == NULL) {
+ log_warnx("%s: Failed to add agent capabilities: oid too small",
+ session->sess_backend.ab_name);
+ error = APPL_ERROR_PARSEERROR;
+ goto fail;
+ }
+
+ error = appl_addagentcaps(pdu->ap_context.aos_string, &oid,
+ pdu->ap_payload.ap_addagentcaps.ap_descr.aos_string,
+ &(session->sess_backend));
+
+ fail:
+ ax_response(session->sess_conn->conn_ax, session->sess_id,
+ pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
+ smi_getticks(), error, 0, NULL, 0);
+ event_add(&(session->sess_conn->conn_wev), NULL);
+}
+
+void
+appl_agentx_removeagentcaps(struct appl_agentx_session *session,
+ struct ax_pdu *pdu)
+{
+ struct ber_oid oid;
+ enum appl_error error;
+
+ if (appl_agentx_oid2ber_oid(&(pdu->ap_payload.ap_addagentcaps.ap_oid),
+ &oid) == NULL) {
+ log_warnx("%s: Failed to remove agent capabilities: "
+ "oid too small", session->sess_backend.ab_name);
+ error = APPL_ERROR_PARSEERROR;
+ goto fail;
+ }
+
+ error = appl_removeagentcaps(pdu->ap_context.aos_string, &oid,
+ &(session->sess_backend));
+
+ fail:
+ ax_response(session->sess_conn->conn_ax, session->sess_id,
+ pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
+ smi_getticks(), error, 0, NULL, 0);
+ event_add(&(session->sess_conn->conn_wev), NULL);
+}
+
+void
appl_agentx_response(struct appl_agentx_session *session, struct ax_pdu *pdu)
{
struct appl_varbind *response = NULL;