|
|
1.1 root 1: /*
2: * socket emulation routines
3: * pretty much 4.2 sys/uipc_socket2.c
4: */
5: #include "tcp.h"
6: #if NTCP > 0
7:
8: #include "../h/param.h"
9: #include "../h/systm.h"
10: #include "../h/stream.h"
11: #include "../h/inet/in.h"
12: #include "../h/inet/mbuf.h"
13: #include "../h/inet/tcp.h"
14: #include "../h/inet/tcp_timer.h"
15: #include "../h/inet/socket.h"
16: #include "../h/inet/tcp_var.h"
17:
18: /*
19: * Sequence from originating side is open /dev/tcp??, write
20: * struct tcpuser (see tcp_device.c), the soisconnecting(),
21: * soisconnected(), soisdisconnecting(), soisdisconnected().
22: * On listening side, sonewconn(so) is called when a connection
23: * is made to socket so, then soisconnected(), at which point the
24: * user is notified and should open the new /dev/tcp??.
25: */
26:
27: soisconnecting(so)
28: register struct socket *so;
29: {
30: so->so_state |= SS_ACTIVE;
31: /* no need to wake up user */
32: }
33:
34: soisconnected(so)
35: register struct socket *so;
36: {
37: tcp_isconnected(so); /* tell user */
38: }
39:
40: soisdisconnecting(so)
41: register struct socket *so;
42: {
43: so->so_state &= ~SS_PLEASEOPEN;
44: tcp_hungup(so); /* sends M_HANGUP */
45: }
46:
47: soisdisconnected(so)
48: register struct socket *so;
49: {
50: so->so_state &= ~(SS_ACTIVE|SS_PLEASEOPEN|SS_RCVATMARK);
51: if(so->so_state&SS_OPEN && !(so->so_state&SS_HUNGUP)) {
52: so->so_state |= SS_HUNGUP;
53: tcp_hungup(so);
54: }
55: }
56:
57: struct socket *
58: sonewconn(head)
59: register struct socket *head;
60: {
61: register struct socket *so;
62: extern struct socket *tcp_newconn();
63:
64: so = tcp_newconn(head);
65: if(so == 0)
66: goto bad;
67: if(tcp_attach(so))
68: goto bad;
69:
70: so->so_options = head->so_options & ~SO_ACCEPTCONN;
71: so->so_state = SS_ACTIVE|SS_PLEASEOPEN;
72: /* simulate PRU_ATTACH */
73: return(so);
74: bad:
75: printf("sonewconn bad\n");
76: return(0);
77: }
78:
79: soabort(so)
80: register struct socket *so;
81: {
82: if(so->so_tcpcb)
83: tcp_drop(so->so_tcpcb);
84: }
85:
86: socantrcvmore(so)
87: struct socket *so;
88: {
89: tcp_cantrcvmore(so);
90: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.