if ((family == -1) || !*addr)
PRINTF("any");
else {
#ifdef USE_INET6
void *ptr = addr;
PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
#else
ipa.s_addr = *addr;
if ((family == -1) || ((!addr || !*addr) && (!mask || !*mask)))
if (ctx->fd >= 0) {
ctx->sin.sin_family = AF_INET;
ctx->sin.sin_port = htons(162);
if (connect(ctx->fd, &ctx->sin,
if (connect(ctx->fd, (struct sockaddr *)&ctx->sin,
sizeof(ctx->sin)) != 0) {
snmpv1_destroy(ctx);
return NULL;
snmpv2_destroy(ctx);