Lines Matching full:pdu
423 snmp_create_v1_trap(struct snmp_pdu *pdu, char *com, in snmp_create_v1_trap() argument
426 memset(pdu, 0, sizeof(*pdu)); in snmp_create_v1_trap()
427 strlcpy(pdu->community, com, sizeof(pdu->community)); in snmp_create_v1_trap()
429 pdu->version = SNMP_V1; in snmp_create_v1_trap()
430 pdu->type = SNMP_PDU_TRAP; in snmp_create_v1_trap()
431 pdu->enterprise = systemg.object_id; in snmp_create_v1_trap()
432 memcpy(pdu->agent_addr, snmpd.trap1addr, 4); in snmp_create_v1_trap()
433 pdu->generic_trap = trap_oid->subs[trap_oid->len - 1] - 1; in snmp_create_v1_trap()
434 pdu->specific_trap = 0; in snmp_create_v1_trap()
435 pdu->time_stamp = get_ticks() - start_tick; in snmp_create_v1_trap()
436 pdu->nbindings = 0; in snmp_create_v1_trap()
440 snmp_create_v2_trap(struct snmp_pdu *pdu, char *com, in snmp_create_v2_trap() argument
443 memset(pdu, 0, sizeof(*pdu)); in snmp_create_v2_trap()
444 strlcpy(pdu->community, com, sizeof(pdu->community)); in snmp_create_v2_trap()
446 pdu->version = SNMP_V2c; in snmp_create_v2_trap()
447 pdu->type = SNMP_PDU_TRAP2; in snmp_create_v2_trap()
448 pdu->request_id = reqid_next(trap_reqid); in snmp_create_v2_trap()
449 pdu->error_index = 0; in snmp_create_v2_trap()
450 pdu->error_status = SNMP_ERR_NOERROR; in snmp_create_v2_trap()
452 pdu->bindings[0].var = oid_sysUpTime; in snmp_create_v2_trap()
453 pdu->bindings[0].var.subs[pdu->bindings[0].var.len++] = 0; in snmp_create_v2_trap()
454 pdu->bindings[0].syntax = SNMP_SYNTAX_TIMETICKS; in snmp_create_v2_trap()
455 pdu->bindings[0].v.uint32 = get_ticks() - start_tick; in snmp_create_v2_trap()
457 pdu->bindings[1].var = oid_snmpTrapOID; in snmp_create_v2_trap()
458 pdu->bindings[1].var.subs[pdu->bindings[1].var.len++] = 0; in snmp_create_v2_trap()
459 pdu->bindings[1].syntax = SNMP_SYNTAX_OID; in snmp_create_v2_trap()
460 pdu->bindings[1].v.oid = *trap_oid; in snmp_create_v2_trap()
462 pdu->nbindings = 2; in snmp_create_v2_trap()
466 snmp_create_v3_trap(struct snmp_pdu *pdu, struct target_param *target, in snmp_create_v3_trap() argument
471 memset(pdu, 0, sizeof(*pdu)); in snmp_create_v3_trap()
473 pdu->version = SNMP_V3; in snmp_create_v3_trap()
474 pdu->type = SNMP_PDU_TRAP2; in snmp_create_v3_trap()
475 pdu->request_id = reqid_next(trap_reqid); in snmp_create_v3_trap()
476 pdu->error_index = 0; in snmp_create_v3_trap()
477 pdu->error_status = SNMP_ERR_NOERROR; in snmp_create_v3_trap()
479 pdu->bindings[0].var = oid_sysUpTime; in snmp_create_v3_trap()
480 pdu->bindings[0].var.subs[pdu->bindings[0].var.len++] = 0; in snmp_create_v3_trap()
481 pdu->bindings[0].syntax = SNMP_SYNTAX_TIMETICKS; in snmp_create_v3_trap()
482 pdu->bindings[0].v.uint32 = get_ticks() - start_tick; in snmp_create_v3_trap()
484 pdu->bindings[1].var = oid_snmpTrapOID; in snmp_create_v3_trap()
485 pdu->bindings[1].var.subs[pdu->bindings[1].var.len++] = 0; in snmp_create_v3_trap()
486 pdu->bindings[1].syntax = SNMP_SYNTAX_OID; in snmp_create_v3_trap()
487 pdu->bindings[1].v.oid = *trap_oid; in snmp_create_v3_trap()
489 pdu->nbindings = 2; in snmp_create_v3_trap()
493 memcpy(pdu->engine.engine_id, snmpd_engine.engine_id, in snmp_create_v3_trap()
495 pdu->engine.engine_len = snmpd_engine.engine_len; in snmp_create_v3_trap()
496 pdu->engine.engine_boots = snmpd_engine.engine_boots; in snmp_create_v3_trap()
497 pdu->engine.engine_time = snmpd_engine.engine_time; in snmp_create_v3_trap()
498 pdu->engine.max_msg_size = snmpd_engine.max_msg_size; in snmp_create_v3_trap()
499 strlcpy(pdu->user.sec_name, target->secname, in snmp_create_v3_trap()
500 sizeof(pdu->user.sec_name)); in snmp_create_v3_trap()
501 pdu->security_model = target->sec_model; in snmp_create_v3_trap()
503 pdu->context_engine_len = snmpd_engine.engine_len; in snmp_create_v3_trap()
504 memcpy(pdu->context_engine, snmpd_engine.engine_id, in snmp_create_v3_trap()
509 usmuser = usm_find_user(pdu->engine.engine_id, in snmp_create_v3_trap()
510 pdu->engine.engine_len, pdu->user.sec_name); in snmp_create_v3_trap()
512 pdu->user.auth_proto = usmuser->suser.auth_proto; in snmp_create_v3_trap()
513 pdu->user.priv_proto = usmuser->suser.priv_proto; in snmp_create_v3_trap()
514 memcpy(pdu->user.auth_key, usmuser->suser.auth_key, in snmp_create_v3_trap()
515 sizeof(pdu->user.auth_key)); in snmp_create_v3_trap()
516 memcpy(pdu->user.priv_key, usmuser->suser.priv_key, in snmp_create_v3_trap()
517 sizeof(pdu->user.priv_key)); in snmp_create_v3_trap()
519 snmp_pdu_init_secparams(pdu); in snmp_create_v3_trap()
526 struct snmp_pdu pdu; in snmp_send_trap() local
545 snmp_create_v1_trap(&pdu, t->comm, trap_oid); in snmp_send_trap()
547 snmp_create_v2_trap(&pdu, t->comm, trap_oid); in snmp_send_trap()
551 pdu.bindings[pdu.nbindings++] = *v; in snmp_send_trap()
554 if (snmp_pdu_auth_access(&pdu, &ip) != SNMP_CODE_OK) { in snmp_send_trap()
565 snmp_output(&pdu, sndbuf, &sndlen, "TRAP"); in snmp_send_trap()
601 snmp_create_v1_trap(&pdu, tp->secname, trap_oid); in snmp_send_trap()
605 snmp_create_v2_trap(&pdu, tp->secname, trap_oid); in snmp_send_trap()
609 snmp_create_v3_trap(&pdu, tp, trap_oid); in snmp_send_trap()
618 pdu.bindings[pdu.nbindings++] = *v; in snmp_send_trap()
621 if (snmp_pdu_auth_access(&pdu, &ip) != SNMP_CODE_OK) { in snmp_send_trap()
632 snmp_output(&pdu, sndbuf, &sndlen, "TRAP"); in snmp_send_trap()