Deleted Added
full compact
spx_reass.c (24659) spx_reass.c (25345)
1/*
2 * Copyright (c) 1995, Mike Mitchell
3 * Copyright (c) 1984, 1985, 1986, 1987, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)spx_usrreq.h
35 *
1/*
2 * Copyright (c) 1995, Mike Mitchell
3 * Copyright (c) 1984, 1985, 1986, 1987, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)spx_usrreq.h
35 *
36 * $Id: spx_usrreq.c,v 1.10 1997/02/22 09:42:00 peter Exp $
36 * $Id: spx_usrreq.c,v 1.11 1997/04/05 20:05:11 jhay Exp $
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <sys/mbuf.h>
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <sys/mbuf.h>
43#include <sys/proc.h>
43#include <sys/protosw.h>
44#include <sys/queue.h>
45#include <sys/socket.h>
46#include <sys/socketvar.h>
47#include <sys/errno.h>
48
49#include <net/if.h>
50#include <net/route.h>

--- 18 unchanged lines hidden (view full) ---

69int spx_use_delack = 0;
70u_short spx_newchecks[50];
71
72struct spx_istat spx_istat;
73u_short spx_iss;
74
75static int spx_usr_abort(struct socket *so);
76static int spx_accept(struct socket *so, struct mbuf *nam);
44#include <sys/protosw.h>
45#include <sys/queue.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
48#include <sys/errno.h>
49
50#include <net/if.h>
51#include <net/route.h>

--- 18 unchanged lines hidden (view full) ---

70int spx_use_delack = 0;
71u_short spx_newchecks[50];
72
73struct spx_istat spx_istat;
74u_short spx_iss;
75
76static int spx_usr_abort(struct socket *so);
77static int spx_accept(struct socket *so, struct mbuf *nam);
77static int spx_attach(struct socket *so, int proto);
78static int spx_bind(struct socket *so, struct mbuf *nam);
79static int spx_connect(struct socket *so, struct mbuf *nam);
78static int spx_attach(struct socket *so, int proto, struct proc *p);
79static int spx_bind(struct socket *so, struct mbuf *nam, struct proc *p);
80static int spx_connect(struct socket *so, struct mbuf *nam, struct proc *p);
80static int spx_detach(struct socket *so);
81static int spx_usr_disconnect(struct socket *so);
81static int spx_detach(struct socket *so);
82static int spx_usr_disconnect(struct socket *so);
82static int spx_listen(struct socket *so);
83static int spx_listen(struct socket *so, struct proc *p);
83static int spx_rcvd(struct socket *so, int flags);
84static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags);
85static int spx_send(struct socket *so, int flags, struct mbuf *m,
84static int spx_rcvd(struct socket *so, int flags);
85static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags);
86static int spx_send(struct socket *so, int flags, struct mbuf *m,
86 struct mbuf *addr, struct mbuf *control);
87 struct mbuf *addr, struct mbuf *control, struct proc *p);
87static int spx_shutdown(struct socket *so);
88static int spx_shutdown(struct socket *so);
88static int spx_sp_attach(struct socket *so, int proto);
89static int spx_sp_attach(struct socket *so, int proto, struct proc *p);
89
90struct pr_usrreqs spx_usrreqs = {
91 spx_usr_abort, spx_accept, spx_attach, spx_bind,
92 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
93 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
94 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
95 ipx_sockaddr
96};

--- 108 unchanged lines hidden (view full) ---

205 am->m_len = sizeof (struct sockaddr_ipx);
206 sipx = mtod(am, struct sockaddr_ipx *);
207 sipx->sipx_len = sizeof(*sipx);
208 sipx->sipx_family = AF_IPX;
209 sipx->sipx_addr = si->si_sna;
210 laddr = ipxp->ipxp_laddr;
211 if (ipx_nullhost(laddr))
212 ipxp->ipxp_laddr = si->si_dna;
90
91struct pr_usrreqs spx_usrreqs = {
92 spx_usr_abort, spx_accept, spx_attach, spx_bind,
93 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
94 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
95 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
96 ipx_sockaddr
97};

--- 108 unchanged lines hidden (view full) ---

206 am->m_len = sizeof (struct sockaddr_ipx);
207 sipx = mtod(am, struct sockaddr_ipx *);
208 sipx->sipx_len = sizeof(*sipx);
209 sipx->sipx_family = AF_IPX;
210 sipx->sipx_addr = si->si_sna;
211 laddr = ipxp->ipxp_laddr;
212 if (ipx_nullhost(laddr))
213 ipxp->ipxp_laddr = si->si_dna;
213 if (ipx_pcbconnect(ipxp, am)) {
214 if (ipx_pcbconnect(ipxp, am, &proc0)) {
214 ipxp->ipxp_laddr = laddr;
215 (void) m_free(am);
216 spx_istat.noconn++;
217 goto drop;
218 }
219 (void) m_free(am);
220 spx_template(cb);
221 dropsocket = 0; /* committed to socket */

--- 946 unchanged lines hidden (view full) ---

1168 SPXT_RANGESET(cb->s_timer[SPXT_PERSIST],
1169 t*spx_backoff[cb->s_rxtshift],
1170 SPXTV_PERSMIN, SPXTV_PERSMAX);
1171 if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
1172 cb->s_rxtshift++;
1173}
1174/*ARGSUSED*/
1175int
215 ipxp->ipxp_laddr = laddr;
216 (void) m_free(am);
217 spx_istat.noconn++;
218 goto drop;
219 }
220 (void) m_free(am);
221 spx_template(cb);
222 dropsocket = 0; /* committed to socket */

--- 946 unchanged lines hidden (view full) ---

1169 SPXT_RANGESET(cb->s_timer[SPXT_PERSIST],
1170 t*spx_backoff[cb->s_rxtshift],
1171 SPXTV_PERSMIN, SPXTV_PERSMAX);
1172 if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
1173 cb->s_rxtshift++;
1174}
1175/*ARGSUSED*/
1176int
1176spx_ctloutput(req, so, level, name, value)
1177spx_ctloutput(req, so, level, name, value, p)
1177 int req;
1178 struct socket *so;
1179 int level, name;
1180 struct mbuf **value;
1178 int req;
1179 struct socket *so;
1180 int level, name;
1181 struct mbuf **value;
1182 struct proc *p;
1181{
1182 register struct mbuf *m;
1183 struct ipxpcb *ipxp = sotoipxpcb(so);
1184 register struct spxpcb *cb;
1185 int mask, error = 0;
1186
1187 if (level != IPXPROTO_SPX) {
1188 /* This will have to be changed when we do more general
1189 stacking of protocols */
1183{
1184 register struct mbuf *m;
1185 struct ipxpcb *ipxp = sotoipxpcb(so);
1186 register struct spxpcb *cb;
1187 int mask, error = 0;
1188
1189 if (level != IPXPROTO_SPX) {
1190 /* This will have to be changed when we do more general
1191 stacking of protocols */
1190 return (ipx_ctloutput(req, so, level, name, value));
1192 return (ipx_ctloutput(req, so, level, name, value, p));
1191 }
1192 if (ipxp == NULL) {
1193 error = EINVAL;
1194 goto release;
1195 } else
1196 cb = ipxtospxpcb(ipxp);
1197
1198 switch (req) {

--- 133 unchanged lines hidden (view full) ---

1332
1333 nam->m_len = sizeof (struct sockaddr_ipx);
1334 sipx->sipx_family = AF_IPX;
1335 sipx->sipx_addr = ipxp->ipxp_faddr;
1336 return (0);
1337}
1338
1339static int
1193 }
1194 if (ipxp == NULL) {
1195 error = EINVAL;
1196 goto release;
1197 } else
1198 cb = ipxtospxpcb(ipxp);
1199
1200 switch (req) {

--- 133 unchanged lines hidden (view full) ---

1334
1335 nam->m_len = sizeof (struct sockaddr_ipx);
1336 sipx->sipx_family = AF_IPX;
1337 sipx->sipx_addr = ipxp->ipxp_faddr;
1338 return (0);
1339}
1340
1341static int
1340spx_attach(so, proto)
1342spx_attach(so, proto, p)
1341 struct socket *so;
1342 int proto;
1343 struct socket *so;
1344 int proto;
1345 struct proc *p;
1343{
1344 int error;
1345 int s;
1346 struct ipxpcb *ipxp;
1347 struct spxpcb *cb;
1348 struct mbuf *mm;
1349 struct sockbuf *sb;
1350
1351 ipxp = sotoipxpcb(so);
1352 cb = ipxtospxpcb(ipxp);
1353
1354 if (ipxp != NULL)
1355 return (EISCONN);
1356 s = splnet();
1346{
1347 int error;
1348 int s;
1349 struct ipxpcb *ipxp;
1350 struct spxpcb *cb;
1351 struct mbuf *mm;
1352 struct sockbuf *sb;
1353
1354 ipxp = sotoipxpcb(so);
1355 cb = ipxtospxpcb(ipxp);
1356
1357 if (ipxp != NULL)
1358 return (EISCONN);
1359 s = splnet();
1357 error = ipx_pcballoc(so, &ipxpcb);
1360 error = ipx_pcballoc(so, &ipxpcb, p);
1358 if (error)
1359 goto spx_attach_end;
1360 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
1361 error = soreserve(so, (u_long) 3072, (u_long) 3072);
1362 if (error)
1363 goto spx_attach_end;
1364 }
1365 ipxp = sotoipxpcb(so);

--- 32 unchanged lines hidden (view full) ---

1398 SPXTV_MIN, SPXTV_REXMTMAX);
1399 ipxp->ipxp_pcb = (caddr_t) cb;
1400spx_attach_end:
1401 splx(s);
1402 return (error);
1403}
1404
1405static int
1361 if (error)
1362 goto spx_attach_end;
1363 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
1364 error = soreserve(so, (u_long) 3072, (u_long) 3072);
1365 if (error)
1366 goto spx_attach_end;
1367 }
1368 ipxp = sotoipxpcb(so);

--- 32 unchanged lines hidden (view full) ---

1401 SPXTV_MIN, SPXTV_REXMTMAX);
1402 ipxp->ipxp_pcb = (caddr_t) cb;
1403spx_attach_end:
1404 splx(s);
1405 return (error);
1406}
1407
1408static int
1406spx_bind(so, nam)
1409spx_bind(so, nam, p)
1407 struct socket *so;
1408 struct mbuf *nam;
1410 struct socket *so;
1411 struct mbuf *nam;
1412 struct proc *p;
1409{
1410 struct ipxpcb *ipxp;
1411
1412 ipxp = sotoipxpcb(so);
1413
1413{
1414 struct ipxpcb *ipxp;
1415
1416 ipxp = sotoipxpcb(so);
1417
1414 return (ipx_pcbbind(ipxp, nam));
1418 return (ipx_pcbbind(ipxp, nam, p));
1415}
1416
1417/*
1418 * Initiate connection to peer.
1419 * Enter SYN_SENT state, and mark socket as connecting.
1420 * Start keep-alive timer, setup prototype header,
1421 * Send initial system packet requesting connection.
1422 */
1423static int
1419}
1420
1421/*
1422 * Initiate connection to peer.
1423 * Enter SYN_SENT state, and mark socket as connecting.
1424 * Start keep-alive timer, setup prototype header,
1425 * Send initial system packet requesting connection.
1426 */
1427static int
1424spx_connect(so, nam)
1428spx_connect(so, nam, p)
1425 struct socket *so;
1426 struct mbuf *nam;
1429 struct socket *so;
1430 struct mbuf *nam;
1431 struct proc *p;
1427{
1428 int error;
1429 int s;
1430 struct ipxpcb *ipxp;
1431 struct spxpcb *cb;
1432
1433 ipxp = sotoipxpcb(so);
1434 cb = ipxtospxpcb(ipxp);
1435
1436 s = splnet();
1437 if (ipxp->ipxp_lport == 0) {
1432{
1433 int error;
1434 int s;
1435 struct ipxpcb *ipxp;
1436 struct spxpcb *cb;
1437
1438 ipxp = sotoipxpcb(so);
1439 cb = ipxtospxpcb(ipxp);
1440
1441 s = splnet();
1442 if (ipxp->ipxp_lport == 0) {
1438 error = ipx_pcbbind(ipxp, (struct mbuf *)0);
1443 error = ipx_pcbbind(ipxp, (struct mbuf *)0, p);
1439 if (error)
1440 goto spx_connect_end;
1441 }
1444 if (error)
1445 goto spx_connect_end;
1446 }
1442 error = ipx_pcbconnect(ipxp, nam);
1447 error = ipx_pcbconnect(ipxp, nam, p);
1443 if (error)
1444 goto spx_connect_end;
1445 soisconnecting(so);
1446 spxstat.spxs_connattempt++;
1447 cb->s_state = TCPS_SYN_SENT;
1448 cb->s_did = 0;
1449 spx_template(cb);
1450 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;

--- 53 unchanged lines hidden (view full) ---

1504
1505 s = splnet();
1506 spx_disconnect(cb);
1507 splx(s);
1508 return (0);
1509}
1510
1511static int
1448 if (error)
1449 goto spx_connect_end;
1450 soisconnecting(so);
1451 spxstat.spxs_connattempt++;
1452 cb->s_state = TCPS_SYN_SENT;
1453 cb->s_did = 0;
1454 spx_template(cb);
1455 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;

--- 53 unchanged lines hidden (view full) ---

1509
1510 s = splnet();
1511 spx_disconnect(cb);
1512 splx(s);
1513 return (0);
1514}
1515
1516static int
1512spx_listen(so)
1517spx_listen(so, p)
1513 struct socket *so;
1518 struct socket *so;
1519 struct proc *p;
1514{
1515 int error;
1516 struct ipxpcb *ipxp;
1517 struct spxpcb *cb;
1518
1519 error = 0;
1520 ipxp = sotoipxpcb(so);
1521 cb = ipxtospxpcb(ipxp);
1522
1523 if (ipxp->ipxp_lport == 0)
1520{
1521 int error;
1522 struct ipxpcb *ipxp;
1523 struct spxpcb *cb;
1524
1525 error = 0;
1526 ipxp = sotoipxpcb(so);
1527 cb = ipxtospxpcb(ipxp);
1528
1529 if (ipxp->ipxp_lport == 0)
1524 error = ipx_pcbbind(ipxp, (struct mbuf *)0);
1530 error = ipx_pcbbind(ipxp, (struct mbuf *)0, p);
1525 if (error == 0)
1526 cb->s_state = TCPS_LISTEN;
1527 return (error);
1528}
1529
1530/*
1531 * After a receive, possibly send acknowledgment
1532 * updating allocation.

--- 35 unchanged lines hidden (view full) ---

1568 m->m_len = 1;
1569 *mtod(m, caddr_t) = cb->s_iobc;
1570 return (0);
1571 }
1572 return (EINVAL);
1573}
1574
1575static int
1531 if (error == 0)
1532 cb->s_state = TCPS_LISTEN;
1533 return (error);
1534}
1535
1536/*
1537 * After a receive, possibly send acknowledgment
1538 * updating allocation.

--- 35 unchanged lines hidden (view full) ---

1574 m->m_len = 1;
1575 *mtod(m, caddr_t) = cb->s_iobc;
1576 return (0);
1577 }
1578 return (EINVAL);
1579}
1580
1581static int
1576spx_send(so, flags, m, addr, controlp)
1582spx_send(so, flags, m, addr, controlp, p)
1577 struct socket *so;
1578 int flags;
1579 struct mbuf *m;
1580 struct mbuf *addr;
1581 struct mbuf *controlp;
1583 struct socket *so;
1584 int flags;
1585 struct mbuf *m;
1586 struct mbuf *addr;
1587 struct mbuf *controlp;
1588 struct proc *p;
1582{
1583 int error;
1584 int s;
1585 struct ipxpcb *ipxp;
1586 struct spxpcb *cb;
1587
1588 error = 0;
1589 ipxp = sotoipxpcb(so);

--- 46 unchanged lines hidden (view full) ---

1636 cb = spx_usrclosed(cb);
1637 if (cb)
1638 error = spx_output(cb, (struct mbuf *) 0);
1639 splx(s);
1640 return (error);
1641}
1642
1643static int
1589{
1590 int error;
1591 int s;
1592 struct ipxpcb *ipxp;
1593 struct spxpcb *cb;
1594
1595 error = 0;
1596 ipxp = sotoipxpcb(so);

--- 46 unchanged lines hidden (view full) ---

1643 cb = spx_usrclosed(cb);
1644 if (cb)
1645 error = spx_output(cb, (struct mbuf *) 0);
1646 splx(s);
1647 return (error);
1648}
1649
1650static int
1644spx_sp_attach(so, proto)
1651spx_sp_attach(so, proto, p)
1645 struct socket *so;
1646 int proto;
1652 struct socket *so;
1653 int proto;
1654 struct proc *p;
1647{
1648 int error;
1649 struct ipxpcb *ipxp;
1650 struct spxpcb *cb;
1651
1655{
1656 int error;
1657 struct ipxpcb *ipxp;
1658 struct spxpcb *cb;
1659
1652 error = spx_attach(so, proto);
1660 error = spx_attach(so, proto, p);
1653 if (error == 0) {
1654 ipxp = sotoipxpcb(so);
1655 ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |=
1656 (SF_HI | SF_HO | SF_PI);
1657 }
1658 return (error);
1659}
1660

--- 278 unchanged lines hidden ---
1661 if (error == 0) {
1662 ipxp = sotoipxpcb(so);
1663 ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |=
1664 (SF_HI | SF_HO | SF_PI);
1665 }
1666 return (error);
1667}
1668

--- 278 unchanged lines hidden ---