• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/bsnmp/lib/

Lines Matching refs:snmp_client

74 struct snmp_client snmp_client;
131 seterr(struct snmp_client *sc, const char *fmt, ...)
202 seterr(&snmp_client, "no memory for table entry");
206 seterr(&snmp_client, "no memory for table entry");
220 seterr(&snmp_client, "bad index: need integer");
224 seterr(&snmp_client,
234 seterr(&snmp_client,
240 seterr(&snmp_client,
245 seterr(&snmp_client,
251 seterr(&snmp_client,
268 seterr(&snmp_client,
274 seterr(&snmp_client,
286 seterr(&snmp_client,
292 seterr(&snmp_client,
304 seterr(&snmp_client,
309 seterr(&snmp_client,
384 seterr(&snmp_client, "bad syntax (%u instead of %u)", b->syntax,
398 seterr(&snmp_client, "no memory for string");
448 if (snmp_client.version == SNMP_V1)
480 if (snmp_client.version == SNMP_V1 &&
487 seterr(&snmp_client, "error fetching table: status=%d index=%d",
497 seterr(&snmp_client,
502 seterr(&snmp_client,
512 seterr(&snmp_client,
547 seterr(&snmp_client,
553 seterr(&snmp_client, "inconsistency detected %llx %llx",
639 seterr(&snmp_client, "no response to fetch table request");
717 seterr(&snmp_client, "%s", strerror(errno));
853 snmp_client_init(struct snmp_client *c)
895 if (snmp_client.chost == NULL) {
896 if ((snmp_client.chost = malloc(1 + sizeof(DEFAULT_HOST)))
898 seterr(&snmp_client, "%s", strerror(errno));
901 strcpy(snmp_client.chost, DEFAULT_HOST);
905 seterr(&snmp_client, "%s", strerror(errno));
908 free(snmp_client.chost);
909 snmp_client.chost = ptr;
910 strcpy(snmp_client.chost, host);
912 if (snmp_client.cport == NULL) {
913 if ((snmp_client.cport = malloc(1 + sizeof(DEFAULT_PORT)))
915 seterr(&snmp_client, "%s", strerror(errno));
918 strcpy(snmp_client.cport, DEFAULT_PORT);
922 seterr(&snmp_client, "%s", strerror(errno));
925 free(snmp_client.cport);
926 snmp_client.cport = ptr;
927 strcpy(snmp_client.cport, port);
933 hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET :
937 error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0);
939 seterr(&snmp_client, "%s: %s", snmp_client.chost,
945 if ((snmp_client.fd = socket(res->ai_family, res->ai_socktype,
948 seterr(&snmp_client, "%s", strerror(errno));
952 } else if (connect(snmp_client.fd, res->ai_addr,
955 seterr(&snmp_client, "%s", strerror(errno));
957 (void)close(snmp_client.fd);
958 snmp_client.fd = -1;
971 (void)remove(snmp_client.local_path);
984 if (snmp_client.chost == NULL) {
985 if ((snmp_client.chost = malloc(1 + sizeof(DEFAULT_LOCAL)))
987 seterr(&snmp_client, "%s", strerror(errno));
990 strcpy(snmp_client.chost, DEFAULT_LOCAL);
994 seterr(&snmp_client, "%s", strerror(errno));
997 free(snmp_client.chost);
998 snmp_client.chost = ptr;
999 strcpy(snmp_client.chost, path);
1002 if (snmp_client.trans == SNMP_TRANS_LOC_DGRAM)
1007 if ((snmp_client.fd = socket(PF_LOCAL, stype, 0)) == -1) {
1008 seterr(&snmp_client, "%s", strerror(errno));
1012 snprintf(snmp_client.local_path, sizeof(snmp_client.local_path),
1015 if (mktemp(snmp_client.local_path) == NULL) {
1016 seterr(&snmp_client, "%s", strerror(errno));
1017 (void)close(snmp_client.fd);
1018 snmp_client.fd = -1;
1024 strcpy(sa.sun_path, snmp_client.local_path);
1026 if (bind(snmp_client.fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
1027 seterr(&snmp_client, "%s", strerror(errno));
1028 (void)close(snmp_client.fd);
1029 snmp_client.fd = -1;
1030 (void)remove(snmp_client.local_path);
1037 strlen(snmp_client.chost);
1038 strncpy(sa.sun_path, snmp_client.chost, sizeof(sa.sun_path) - 1);
1041 if (connect(snmp_client.fd, (struct sockaddr *)&sa, sa.sun_len) == -1) {
1042 seterr(&snmp_client, "%s", strerror(errno));
1043 (void)close(snmp_client.fd);
1044 snmp_client.fd = -1;
1045 (void)remove(snmp_client.local_path);
1061 if (snmp_client.fd != -1) {
1063 seterr(&snmp_client, "%s", strerror(errno));
1069 strlcpy(snmp_client.read_community, readcomm,
1070 sizeof(snmp_client.read_community));
1072 strlcpy(snmp_client.write_community, writecomm,
1073 sizeof(snmp_client.write_community));
1075 switch (snmp_client.trans) {
1090 seterr(&snmp_client, "bad transport mapping");
1095 if (setsockopt(snmp_client.fd, SOL_SOCKET, SO_SNDTIMEO,
1097 seterr(&snmp_client, "%s", strerror(errno));
1098 (void)close(snmp_client.fd);
1099 snmp_client.fd = -1;
1100 if (snmp_client.local_path[0] != '\0')
1101 (void)remove(snmp_client.local_path);
1130 if (snmp_client.fd != -1) {
1131 (void)close(snmp_client.fd);
1132 snmp_client.fd = -1;
1133 if (snmp_client.local_path[0] != '\0')
1134 (void)remove(snmp_client.local_path);
1139 snmp_client.timeout_stop(p1->timeout_id);
1143 free(snmp_client.chost);
1144 free(snmp_client.cport);
1156 strlcpy(pdu->community, snmp_client.write_community,
1159 strlcpy(pdu->community, snmp_client.read_community,
1163 pdu->version = snmp_client.version;
1168 if (snmp_client.version != SNMP_V3)
1171 pdu->identifier = ++snmp_client.identifier;
1172 pdu->engine.max_msg_size = snmp_client.engine.max_msg_size;
1174 pdu->security_model = snmp_client.security_model;
1176 if (snmp_client.security_model == SNMP_SECMODEL_USM) {
1177 memcpy(&pdu->engine, &snmp_client.engine, sizeof(pdu->engine));
1178 memcpy(&pdu->user, &snmp_client.user, sizeof(pdu->user));
1181 seterr(&snmp_client, "unknown security model");
1183 if (snmp_client.clen > 0) {
1184 memcpy(pdu->context_engine, snmp_client.cengine,
1185 snmp_client.clen);
1186 pdu->context_engine_len = snmp_client.clen;
1188 memcpy(pdu->context_engine, snmp_client.engine.engine_id,
1189 snmp_client.engine.engine_len);
1190 pdu->context_engine_len = snmp_client.engine.engine_len;
1193 strlcpy(pdu->context_name, snmp_client.cname,
1225 snmp_next_reqid(struct snmp_client * c)
1247 if ((buf = calloc(1, snmp_client.txbuflen)) == NULL) {
1248 seterr(&snmp_client, "%s", strerror(errno));
1252 pdu->request_id = snmp_next_reqid(&snmp_client);
1255 b.asn_len = snmp_client.txbuflen;
1257 seterr(&snmp_client, "%s", strerror(errno));
1262 if (snmp_client.dump_pdus)
1265 if ((ret = send(snmp_client.fd, buf, b.asn_ptr - buf, 0)) == -1) {
1266 seterr(&snmp_client, "%s", strerror(errno));
1285 listentry->reqid, listentry->retrycount, snmp_client.retries);
1289 if (listentry->retrycount > snmp_client.retries) {
1299 snmp_client.timeout_start(&snmp_client.timeout,
1311 seterr(&snmp_client, "%s", strerror(errno));
1331 snmp_client.timeout_start(&snmp_client.timeout, snmp_timeout,
1368 if ((buf = calloc(1, snmp_client.rxbuflen)) == NULL) {
1369 seterr(&snmp_client, "%s", strerror(errno));
1378 if (setsockopt(snmp_client.fd, SOL_SOCKET, SO_RCVTIMEO,
1380 seterr(&snmp_client, "setsockopt: %s",
1386 if (getsockopt(snmp_client.fd, SOL_SOCKET, SO_RCVTIMEO,
1388 seterr(&snmp_client, "getsockopt: %s",
1404 if ((flags = fcntl(snmp_client.fd, F_GETFL, 0)) == -1) {
1405 seterr(&snmp_client, "fcntl: %s",
1413 if (fcntl(snmp_client.fd, F_SETFL, flags) == -1) {
1414 seterr(&snmp_client, "fcntl: %s",
1422 ret = recv(snmp_client.fd, buf, snmp_client.rxbuflen, 0);
1428 (void)fcntl(snmp_client.fd, F_SETFL, flags);
1433 (void)setsockopt(snmp_client.fd, SOL_SOCKET, SO_RCVTIMEO,
1441 seterr(&snmp_client, "recv: %s", strerror(saved_errno));
1448 seterr(&snmp_client, "recv: socket closed by peer");
1457 if (snmp_client.security_model == SNMP_SECMODEL_USM) {
1458 memcpy(&pdu->engine, &snmp_client.engine, sizeof(pdu->engine));
1459 memcpy(&pdu->user, &snmp_client.user, sizeof(pdu->user));
1464 seterr(&snmp_client, "snmp_decode_pdu: failed %d", ret);
1470 if (snmp_client.dump_pdus)
1473 snmp_client.engine.engine_time = pdu->engine.engine_time;
1474 snmp_client.engine.engine_boots = pdu->engine.engine_boots;
1498 snmp_client.timeout_stop(listentry->timeout_id);
1516 seterr(&snmp_client, "no memory for returning PDU");
1613 if (snmp_client.version != SNMP_V1 &&
1697 struct timeval tv = snmp_client.timeout;
1715 for (i = 0; i <= snmp_client.retries; i++) {
1717 timeradd(&end, &snmp_client.timeout, &end);
1741 seterr(&snmp_client, "retry count exceeded");
1753 if (snmp_client.version != SNMP_V3)
1754 seterr(&snmp_client, "wrong version");
1756 strlcpy(cname, snmp_client.user.sec_name, sizeof(cname));
1757 cap = snmp_client.user.auth_proto;
1758 cpp = snmp_client.user.priv_proto;
1760 snmp_client.engine.engine_len = 0;
1761 snmp_client.engine.engine_boots = 0;
1762 snmp_client.engine.engine_time = 0;
1763 snmp_client.user.auth_proto = SNMP_AUTH_NOAUTH;
1764 snmp_client.user.priv_proto = SNMP_PRIV_NOPRIV;
1765 memset(snmp_client.user.sec_name, 0, sizeof(snmp_client.user.sec_name));
1773 seterr(&snmp_client, "wrong version");
1778 seterr(&snmp_client, "Error %d in responce", resp.error_status);
1782 snmp_client.engine.engine_len = resp.engine.engine_len;
1783 snmp_client.engine.max_msg_size = resp.engine.max_msg_size;
1784 memcpy(snmp_client.engine.engine_id, resp.engine.engine_id,
1787 strlcpy(snmp_client.user.sec_name, cname,
1788 sizeof(snmp_client.user.sec_name));
1789 snmp_client.user.auth_proto = cap;
1790 snmp_client.user.priv_proto = cpp;
1792 if (snmp_client.user.auth_proto == SNMP_AUTH_NOAUTH)
1796 snmp_passwd_to_keys(&snmp_client.user, passwd) != SNMP_CODE_OK ||
1797 snmp_get_local_keys(&snmp_client.user, snmp_client.engine.engine_id,
1798 snmp_client.engine.engine_len) != SNMP_CODE_OK)
1802 snmp_client.engine.engine_boots = resp.engine.engine_boots;
1805 snmp_client.engine.engine_time = resp.engine.engine_time;
1819 seterr(&snmp_client, "wrong version");
1824 seterr(&snmp_client, "Error %d in responce", resp.error_status);
1828 snmp_client.engine.engine_boots = resp.engine.engine_boots;
1829 snmp_client.engine.engine_time = resp.engine.engine_time;
1838 snmp_client_set_host(struct snmp_client *cl, const char *h)
1858 snmp_client_set_port(struct snmp_client *cl, const char *p)
1897 get_transp(struct snmp_client *sc, const char **strp)
1942 get_comm(struct snmp_client *sc, const char **strp)
1973 get_ipv6(struct snmp_client *sc, const char **strp)
2028 get_ipv4(struct snmp_client *sc, const char **strp)
2068 get_host(struct snmp_client *sc __unused, const char **strp)
2093 get_port(struct snmp_client *sc, const char **strp)
2116 save_str(struct snmp_client *sc, const char *const s[2])
2162 snmp_parse_server(struct snmp_client *sc, const char *str)