Home | History | Annotate | Download | only in slirp-android

Lines Matching refs:so

20 static void sofcantrcvmore(struct socket *so);
21 static void sofcantsendmore(struct socket *so);
35 struct socket *so;
37 for (so = head->so_next; so != head; so = so->so_next) {
38 if (so->so_laddr_port == lport &&
39 so->so_laddr_ip == laddr &&
40 so->so_faddr_ip == faddr &&
41 so->so_faddr_port == fport)
45 if (so == head)
47 return so;
59 struct socket *so;
61 so = (struct socket *)malloc(sizeof(struct socket));
62 if(so) {
63 memset(so, 0, sizeof(struct socket));
64 so->so_state = SS_NOFDREF;
65 so->s = -1;
67 return(so);
74 sofree(struct socket *so)
76 if (so->so_state & SS_PROXIFIED)
77 proxy_manager_del(so);
79 if (so->so_emu==EMU_RSH && so->extra) {
80 sofree(so->extra);
81 so->extra=NULL;
83 if (so == tcp_last_so)
85 else if (so == udp_last_so)
88 m_free(so->so_m);
90 if(so->so_next && so->so_prev)
91 remque(so); /* crashes if so is not in a queue */
93 free(so);
96 size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np)
99 struct sbuf *sb = &so->so_snd;
101 int mss = so->so_tcpcb->t_maxseg;
104 DEBUG_ARG("so = %lx", (long )so);
158 * Read from so's socket into sb_snd, updating all relevant sbuf fields
159 * NOTE: This will only be called if it is select()ed for reading, so
163 soread(struct socket *so)
166 struct sbuf *sb = &so->so_snd;
170 DEBUG_ARG("so = %lx", (long )so);
176 sopreprbuf(so, iov, &n);
179 nn = readv(so->s, (struct iovec *)iov, n);
182 nn = socket_recv(so->s, iov[0].iov_base, iov[0].iov_len);
189 sofcantrcvmore(so);
190 tcp_sockclosed(sototcpcb(so));
207 ret = socket_recv(so->s, iov[1].iov_base, iov[1].iov_len);
223 int soreadbuf(struct socket *so, const char *buf, int size)
226 struct sbuf *sb = &so->so_snd;
230 DEBUG_ARG("so = %lx", (long )so);
236 if (sopreprbuf(so, iov, &n) < size)
259 sofcantrcvmore(so);
260 tcp_sockclosed(sototcpcb(so));
269 * so when OOB data arrives, we soread() it and everything
273 sorecvoob(struct socket *so)
275 struct tcpcb *tp = sototcpcb(so);
278 DEBUG_ARG("so = %lx", (long)so);
288 soread(so);
289 tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
300 sosendoob(struct socket *so)
302 struct sbuf *sb = &so->so_rcv;
308 DEBUG_ARG("so = %lx", (long)so);
311 if (so->so_urgc > 2048)
312 so->so_urgc = 2048; /* XXXX */
316 n = socket_send_oob(so->s, sb->sb_rptr, so->so_urgc); /* |MSG_DONTWAIT)); */
317 so->so_urgc -= n;
319 DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
327 if (len > so->so_urgc) len = so->so_urgc;
329 so->so_urgc -= len;
330 if (so->so_urgc) {
332 if (n > so->so_urgc) n = so->so_urgc;
334 so->so_urgc -= n;
337 n = socket_send_oob(so->s, buff, len); /* |MSG_DONTWAIT)); */
342 DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
354 * Write data from so_rcv to so's socket,
358 sowrite(struct socket *so)
361 struct sbuf *sb = &so->so_rcv;
366 DEBUG_ARG("so = %lx", (long)so);
368 if (so->so_urgc) {
369 sosendoob(so);
401 /* Check if there's urgent data to send, and if so, send it */
404 nn = writev(so->s, (const struct iovec *)iov, n);
408 nn = socket_send(so->s, iov[0].iov_base, iov[0].iov_len);
415 DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
416 so->so_state, errno));
417 sofcantsendmore(so);
418 tcp_sockclosed(sototcpcb(so));
425 ret = socket_send(so->s, iov[1].iov_base, iov[1].iov_len);
442 if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0)
443 sofcantsendmore(so);
452 sorecvfrom(struct socket *so)
457 DEBUG_ARG("so = %lx", (long)so);
459 if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */
463 len = socket_recvfrom(so->s, buff, 256, &addr);
474 icmp_error(so->so_m, ICMP_UNREACH,code, 0,errno_str);
476 icmp_reflect(so->so_m);
477 so->so_m = 0; /* Don't mbuf_free() it again! */
480 udp_detach(so);
494 /* if (so->so_fport != htons(53)) { */
495 n = socket_can_read(so->s);
504 m->m_len = socket_recvfrom(so->s, m->m_data, len, &addr);
514 icmp_error(so->so_m, ICMP_UNREACH,code, 0,errno_str);
520 * for the 4 minute (or whatever) timeout... So we time them
523 if (so->so_expire) {
524 if (so->so_faddr_port == 53)
525 so->so_expire = curtime + SO_EXPIREFAST;
527 so->so_expire = curtime + SO_EXPIRE;
540 udp_output_(so, m, &addr);
549 sosendto(struct socket *so, struct mbuf *m)
557 DEBUG_ARG("so = %lx", (long)so);
560 if ((so->so_faddr_ip & 0xffffff00) == special_addr_ip) {
562 int low = so->so_faddr_ip & 0xff;
569 addr_ip = so->so_faddr_ip;
571 addr_port = so->so_faddr_port;
585 so->so_laddr_ip, so->so_laddr_port,
599 ret = socket_sendto(so->s, m->m_data, m->m_len,&addr);
607 if (so->so_expire)
608 so->so_expire = curtime + SO_EXPIRE;
609 so->so_state = SS_ISFCONNECTED; /* So that it gets select()ed */
621 struct socket *so;
630 if ((so = socreate()) == NULL) {
631 /* free(so); Not sofree() ??? free(NULL) == NOP */
636 if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) {
637 free(so);
640 insque(so,&tcb);
646 so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
648 so->so_state = (SS_FACCEPTCONN|flags);
649 so->so_laddr_port = lport; /* Kept in host format */
650 so->so_laddr_ip = laddr; /* Ditto */
651 so->so_haddr_port = port;
659 so->so_faddr_port = sock_address_get_port(&addr);
664 so->so_faddr_ip = alias_addr_ip;
666 so->so_faddr_ip = addr_ip;
668 so->s = s;
669 return so;
676 struct socket *so;
678 for (so = tcb.so_next; so != &tcb; so = so->so_next) {
679 if (so->so_haddr_port == port) {
684 if (so == &tcb) {
688 sofcantrcvmore( so );
689 sofcantsendmore( so );
690 so->s );
691 so->s = -1;
692 sofree( so );
704 sorwakeup(so)
705 struct socket *so;
707 /* sowrite(so); */
708 /* FD_CLR(so->s,&writefds); */
717 sowwakeup(so)
718 struct socket *so;
731 soisfconnecting(struct socket *so)
733 so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE|
735 so->so_state |= SS_ISFCONNECTING; /* Clobber other states */
739 soisfconnected(struct socket *so)
741 so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF);
742 so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
746 sofcantrcvmore(struct socket *so)
748 if ((so->so_state & SS_NOFDREF) == 0) {
749 shutdown(so->s,0);
751 FD_CLR(so->s,global_writefds);
754 so->so_state &= ~(SS_ISFCONNECTING);
755 if (so->so_state & SS_FCANTSENDMORE)
756 so->so_state = SS_NOFDREF; /* Don't select it */ /* XXX close() here as well? */
758 so->so_state |= SS_FCANTRCVMORE;
762 sofcantsendmore(struct socket *so)
764 if ((so->so_state & SS_NOFDREF) == 0) {
765 shutdown(so->s,1); /* send FIN to fhost */
767 FD_CLR(so->s,global_readfds);
770 FD_CLR(so->s,global_xfds);
773 so->so_state &= ~(SS_ISFCONNECTING);
774 if (so->so_state & SS_FCANTRCVMORE)
775 so->so_state = SS_NOFDREF; /* as above */
777 so->so_state |= SS_FCANTSENDMORE;
781 soisfdisconnected(struct socket *so)
783 /* so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
784 /* close(so->s); */
785 /* so->so_state = SS_ISFDISCONNECTED; */
796 sofwdrain(struct socket *so)
798 if (so->so_rcv.sb_cc)
799 so->so_state |= SS_FWDRAIN;
801 sofcantsendmore(so);