FreeBSD/contrib/bsnmp/snmpd/main.c
/*
 * Send a PDU to a given port
 */
Send a PDU to a given port
Send a PDU to a given port
void
snmp_send_port(void *targ, const struct asn_oid *port, struct snmp_pdu *pdu,
    const struct sockaddr *addr, socklen_t addrlen)
{
	struct transport *trans = targ;
	struct tport *tp;
	u_char *sndbuf;
	size_t sndlen;
	ssize_t len;
	TAILQ_FOREACH(tp, &trans->table, link)
		if (asn_compare_oid(port, &tp->index) == 0)
			break;
	if (tp == 0)
		return;
	if ((sndbuf = buf_alloc(1)) == NULL)
		return;
	snmp_output(pdu, sndbuf, &sndlen, "SNMP PROXY");
	len = trans->vtab->send(tp, sndbuf, sndlen, addr, addrlen);
	if (len == -1)
		syslog(LOG_ERR, "sendto: %m");
	else if ((size_t)len != sndlen)
		syslog(LOG_ERR, "sendto: short write %zu/%zu",
		    sndlen, (size_t)len);
	free(sndbuf);
}
void snmp_send_port ( void * targ , const struct asn_oid * port , struct snmp_pdu * pdu , const struct sockaddr * addr , socklen_t addrlen ) { struct transport * trans = targ ; struct tport * tp ; u_char * sndbuf ; size_t sndlen ; ssize_t len ; TAILQ_FOREACH ( tp , & trans -> table , link ) if ( asn_compare_oid ( port , & tp -> index ) == 0 ) break ; if ( tp == 0 ) return ; if ( ( sndbuf = buf_alloc ( 1 ) ) == NULL ) return ; snmp_output ( pdu , sndbuf , & sndlen , " " ) ; len = trans -> vtab -> send ( tp , sndbuf , sndlen , addr , addrlen ) ; if ( len == -1 ) syslog ( LOG_ERR , " " ) ; else if ( ( size_t ) len != sndlen ) syslog ( LOG_ERR , " " , sndlen , ( size_t ) len ) ; free ( sndbuf ) ; }
Send a PDU to a given port
Send a PDU to a given port