Lines Matching +full:input +full:- +full:value

98 	p->input.peerlen = sizeof(p->ret);  in udp_input()
99 snmpd_input(&p->input, &p->tport); in udp_input()
113 if ((p->input.fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { in udp_init_port()
117 ip = (p->addr[0] << 24) | (p->addr[1] << 16) | (p->addr[2] << 8) | in udp_init_port()
118 p->addr[3]; in udp_init_port()
121 addr.sin_port = htons(p->port); in udp_init_port()
125 if (setsockopt(p->input.fd, IPPROTO_IP, IP_RECVDSTADDR, &on, in udp_init_port()
126 sizeof(on)) == -1) { in udp_init_port()
128 close(p->input.fd); in udp_init_port()
129 p->input.fd = -1; in udp_init_port()
132 p->recvdstaddr = true; in udp_init_port()
134 if (bind(p->input.fd, (struct sockaddr *)&addr, sizeof(addr))) { in udp_init_port()
136 close(p->input.fd); in udp_init_port()
137 p->input.fd = -1; in udp_init_port()
141 p->port); in udp_init_port()
142 close(p->input.fd); in udp_init_port()
143 p->input.fd = -1; in udp_init_port()
146 if ((p->input.id = fd_select(p->input.fd, udp_input, in udp_init_port()
148 close(p->input.fd); in udp_init_port()
149 p->input.fd = -1; in udp_init_port()
172 port->tport.index.len = 5; in udp_open_port()
173 port->tport.index.subs[0] = addr[0]; in udp_open_port()
174 port->tport.index.subs[1] = addr[1]; in udp_open_port()
175 port->tport.index.subs[2] = addr[2]; in udp_open_port()
176 port->tport.index.subs[3] = addr[3]; in udp_open_port()
177 port->tport.index.subs[4] = udp_port; in udp_open_port()
179 port->addr[0] = addr[0]; in udp_open_port()
180 port->addr[1] = addr[1]; in udp_open_port()
181 port->addr[2] = addr[2]; in udp_open_port()
182 port->addr[3] = addr[3]; in udp_open_port()
183 port->port = udp_port; in udp_open_port()
185 port->input.fd = -1; in udp_open_port()
186 port->input.id = NULL; in udp_open_port()
187 port->input.stream = 0; in udp_open_port()
188 port->input.cred = 0; in udp_open_port()
189 port->input.peer = (struct sockaddr *)&port->ret; in udp_open_port()
190 port->input.peerlen = sizeof(port->ret); in udp_open_port()
192 trans_insert_port(my_trans, &port->tport); in udp_open_port()
195 (err = udp_init_port(&port->tport)) != SNMP_ERR_NOERROR) { in udp_open_port()
196 udp_close_port(&port->tport); in udp_open_port()
211 snmpd_input_close(&port->input); in udp_close_port()
238 if (p->recvdstaddr) { in udp_send()
243 cmsg->cmsg_level = IPPROTO_IP; in udp_send()
244 cmsg->cmsg_type = IP_SENDSRCADDR; in udp_send()
245 cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); in udp_send()
246 memcpy(CMSG_DATA(cmsg), &p->dstaddr, sizeof(struct in_addr)); in udp_send()
252 return (sendmsg(p->input.fd, &msg, 0)); in udp_send()
261 pi->priv = (cred->sc_euid == 0); in check_priv_dgram()
263 pi->priv = 0; in check_priv_dgram()
267 * Input from a datagram socket.
283 if (pi->buf == NULL) { in udp_recv()
284 /* no buffer yet - allocate one */ in udp_recv()
285 if ((pi->buf = buf_alloc(0)) == NULL) { in udp_recv()
286 /* ups - could not get buffer. Read away input in udp_recv()
288 (void)recvfrom(pi->fd, embuf, sizeof(embuf), in udp_recv()
291 return (-1); in udp_recv()
293 pi->buflen = buf_size(0); in udp_recv()
297 msg.msg_name = pi->peer; in udp_recv()
298 msg.msg_namelen = pi->peerlen; in udp_recv()
306 iov[0].iov_base = pi->buf; in udp_recv()
307 iov[0].iov_len = pi->buflen; in udp_recv()
309 len = recvmsg(pi->fd, &msg, 0); in udp_recv()
311 if (len == -1 || len == 0) in udp_recv()
313 return (-1); in udp_recv()
316 /* truncated - drop */ in udp_recv()
319 return (-1); in udp_recv()
322 pi->length = (size_t)len; in udp_recv()
326 if (cmsg->cmsg_level == IPPROTO_IP && in udp_recv()
327 cmsg->cmsg_type == IP_RECVDSTADDR) in udp_recv()
328 memcpy(&p->dstaddr, CMSG_DATA(cmsg), in udp_recv()
330 if (cmsg->cmsg_level == SOL_SOCKET && in udp_recv()
331 cmsg->cmsg_type == SCM_CREDS) in udp_recv()
335 if (pi->cred) in udp_recv()
345 op_snmp_port(struct snmp_context *ctx, struct snmp_value *value, in op_snmp_port() argument
348 asn_subid_t which = value->var.subs[sub-1]; in op_snmp_port()
357 &value->var, sub)) == NULL) in op_snmp_port()
359 index_append(&value->var, sub, &p->tport.index); in op_snmp_port()
364 &value->var, sub)) == NULL) in op_snmp_port()
370 &value->var, sub); in op_snmp_port()
371 ctx->scratch->int1 = (p != NULL); in op_snmp_port()
375 if (!TRUTH_OK(value->v.integer)) in op_snmp_port()
378 ctx->scratch->int2 = TRUTH_GET(value->v.integer); in op_snmp_port()
380 if (ctx->scratch->int2) { in op_snmp_port()
383 /* already open - do nothing */ in op_snmp_port()
386 if (index_decode(&value->var, sub, iidx, addr, &port)) in op_snmp_port()
391 /* close SNMP port - do in commit */ in op_snmp_port()
397 &value->var, sub); in op_snmp_port()
398 if (ctx->scratch->int1 == 0) { in op_snmp_port()
400 if (ctx->scratch->int2 == 1) { in op_snmp_port()
403 udp_close_port(&p->tport); in op_snmp_port()
410 &value->var, sub); in op_snmp_port()
411 if (ctx->scratch->int1 == 1) { in op_snmp_port()
413 if (ctx->scratch->int2 == 0) { in op_snmp_port()
416 udp_close_port(&p->tport); in op_snmp_port()
426 * Come here to fetch the value in op_snmp_port()
431 value->v.integer = 1; in op_snmp_port()