snmp.c (2b8026620c8afbea7b2ec873e1b26e025c67ba8f) snmp.c (72cd7a520d65ad6c36e208486118fbc92039423e)
1/*
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
5 *
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Copyright (c) 2010 The FreeBSD Foundation

--- 750 unchanged lines hidden (view full) ---

759 if (asn_put_integer(b, pdu->identifier) != ASN_ERR_OK)
760 return (SNMP_CODE_FAILED);
761
762 if (asn_put_integer(b, pdu->engine.max_msg_size) != ASN_ERR_OK)
763 return (SNMP_CODE_FAILED);
764
765 if (pdu->type != SNMP_PDU_RESPONSE &&
766 pdu->type != SNMP_PDU_TRAP &&
1/*
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
5 *
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Copyright (c) 2010 The FreeBSD Foundation

--- 750 unchanged lines hidden (view full) ---

759 if (asn_put_integer(b, pdu->identifier) != ASN_ERR_OK)
760 return (SNMP_CODE_FAILED);
761
762 if (asn_put_integer(b, pdu->engine.max_msg_size) != ASN_ERR_OK)
763 return (SNMP_CODE_FAILED);
764
765 if (pdu->type != SNMP_PDU_RESPONSE &&
766 pdu->type != SNMP_PDU_TRAP &&
767 pdu->type != SNMP_PDU_TRAP2 &&
767 pdu->type != SNMP_PDU_REPORT)
768 pdu->flags |= SNMP_MSG_REPORT_FLAG;
769
770 if (asn_put_octetstring(b, (u_char *)&pdu->flags, 1)
771 != ASN_ERR_OK)
772 return (SNMP_CODE_FAILED);
773
774 if (asn_put_integer(b, pdu->security_model) != ASN_ERR_OK)

--- 396 unchanged lines hidden (view full) ---

1171 from->v.octetstring.octets, to->v.octetstring.len);
1172 }
1173 } else
1174 to->v = from->v;
1175 return (0);
1176}
1177
1178void
768 pdu->type != SNMP_PDU_REPORT)
769 pdu->flags |= SNMP_MSG_REPORT_FLAG;
770
771 if (asn_put_octetstring(b, (u_char *)&pdu->flags, 1)
772 != ASN_ERR_OK)
773 return (SNMP_CODE_FAILED);
774
775 if (asn_put_integer(b, pdu->security_model) != ASN_ERR_OK)

--- 396 unchanged lines hidden (view full) ---

1172 from->v.octetstring.octets, to->v.octetstring.len);
1173 }
1174 } else
1175 to->v = from->v;
1176 return (0);
1177}
1178
1179void
1179snmp_pdu_init_secparams(struct snmp_pdu *pdu, struct snmp_engine *eng,
1180 struct snmp_user *user)
1180snmp_pdu_init_secparams(struct snmp_pdu *pdu)
1181{
1182 int32_t rval;
1183
1181{
1182 int32_t rval;
1183
1184 memcpy(&pdu->engine, eng, sizeof(pdu->engine));
1185 memcpy(&pdu->user, user, sizeof(pdu->user));
1186
1187 if (user->auth_proto != SNMP_AUTH_NOAUTH)
1184 if (pdu->user.auth_proto != SNMP_AUTH_NOAUTH)
1188 pdu->flags |= SNMP_MSG_AUTH_FLAG;
1189
1185 pdu->flags |= SNMP_MSG_AUTH_FLAG;
1186
1190 switch (user->priv_proto) {
1187 switch (pdu->user.priv_proto) {
1191 case SNMP_PRIV_DES:
1188 case SNMP_PRIV_DES:
1192 memcpy(pdu->msg_salt, &eng->engine_boots,
1193 sizeof(eng->engine_boots));
1189 memcpy(pdu->msg_salt, &pdu->engine.engine_boots,
1190 sizeof(pdu->engine.engine_boots));
1194 rval = random();
1191 rval = random();
1195 memcpy(pdu->msg_salt + sizeof(eng->engine_boots), &rval,
1192 memcpy(pdu->msg_salt + sizeof(pdu->engine.engine_boots), &rval,
1196 sizeof(int32_t));
1197 pdu->flags |= SNMP_MSG_PRIV_FLAG;
1198 break;
1199 case SNMP_PRIV_AES:
1200 rval = random();
1201 memcpy(pdu->msg_salt, &rval, sizeof(int32_t));
1202 rval = random();
1203 memcpy(pdu->msg_salt + sizeof(int32_t), &rval, sizeof(int32_t));

--- 253 unchanged lines hidden ---
1193 sizeof(int32_t));
1194 pdu->flags |= SNMP_MSG_PRIV_FLAG;
1195 break;
1196 case SNMP_PRIV_AES:
1197 rval = random();
1198 memcpy(pdu->msg_salt, &rval, sizeof(int32_t));
1199 rval = random();
1200 memcpy(pdu->msg_salt + sizeof(int32_t), &rval, sizeof(int32_t));

--- 253 unchanged lines hidden ---