Revision 460fec67 slirp/tcp_input.c

b/slirp/tcp_input.c
41 41
#include <slirp.h>
42 42
#include "ip_icmp.h"
43 43

  
44
struct socket tcb;
45

  
46 44
#define	TCPREXMTTHRESH 3
47
struct	socket *tcp_last_so = &tcb;
48

  
49
tcp_seq tcp_iss;                /* tcp initial send seq # */
50 45

  
51 46
#define TCP_PAWS_IDLE	(24 * 24 * 60 * 60 * PR_SLOWHZ)
52 47

  
......
233 228
	u_long tiwin;
234 229
	int ret;
235 230
    struct ex_list *ex_ptr;
231
    Slirp *slirp;
236 232

  
237 233
	DEBUG_CALL("tcp_input");
238 234
	DEBUG_ARGS((dfd," m = %8lx  iphlen = %2d  inso = %lx\n",
......
243 239
	 */
244 240
	if (m == NULL) {
245 241
		so = inso;
242
		slirp = so->slirp;
246 243

  
247 244
		/* Re-set a few variables */
248 245
		tp = sototcpcb(so);
......
254 251

  
255 252
		goto cont_conn;
256 253
	}
254
	slirp = m->slirp;
257 255

  
258 256
	/*
259 257
	 * Get IP and TCP header together in first mbuf.
......
318 316
	m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
319 317
	m->m_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
320 318

  
321
    if (slirp_restrict) {
322
        for (ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
319
    if (slirp->restricted) {
320
        for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
323 321
            if (ex_ptr->ex_fport == ti->ti_dport &&
324 322
                ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) {
325 323
                break;
......
332 330
	 * Locate pcb for segment.
333 331
	 */
334 332
findso:
335
	so = tcp_last_so;
333
	so = slirp->tcp_last_so;
336 334
	if (so->so_fport != ti->ti_dport ||
337 335
	    so->so_lport != ti->ti_sport ||
338 336
	    so->so_laddr.s_addr != ti->ti_src.s_addr ||
339 337
	    so->so_faddr.s_addr != ti->ti_dst.s_addr) {
340
		so = solookup(&tcb, ti->ti_src, ti->ti_sport,
338
		so = solookup(&slirp->tcb, ti->ti_src, ti->ti_sport,
341 339
			       ti->ti_dst, ti->ti_dport);
342 340
		if (so)
343
			tcp_last_so = so;
341
			slirp->tcp_last_so = so;
344 342
	}
345 343

  
346 344
	/*
......
360 358
	  if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)
361 359
	    goto dropwithreset;
362 360

  
363
	  if ((so = socreate()) == NULL)
361
	  if ((so = socreate(slirp)) == NULL)
364 362
	    goto dropwithreset;
365 363
	  if (tcp_attach(so) < 0) {
366 364
	    free(so); /* Not sofree (if it failed, it's not insqued) */
......
555 553
	   * If this is destined for the control address, then flag to
556 554
	   * tcp_ctl once connected, otherwise connect
557 555
	   */
558
	  if ((so->so_faddr.s_addr & vnetwork_mask.s_addr) ==
559
	      vnetwork_addr.s_addr) {
560
	    if (so->so_faddr.s_addr != vhost_addr.s_addr &&
561
		so->so_faddr.s_addr != vnameserver_addr.s_addr) {
556
	  if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==
557
	      slirp->vnetwork_addr.s_addr) {
558
	    if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr &&
559
		so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) {
562 560
		/* May be an add exec */
563
		for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
561
		for (ex_ptr = slirp->exec_list; ex_ptr;
562
		     ex_ptr = ex_ptr->ex_next) {
564 563
		  if(ex_ptr->ex_fport == so->so_fport &&
565 564
		     so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
566 565
		    so->so_state |= SS_CTL;
......
631 630
	  if (iss)
632 631
	    tp->iss = iss;
633 632
	  else
634
	    tp->iss = tcp_iss;
635
	  tcp_iss += TCP_ISSINCR/2;
633
	    tp->iss = slirp->tcp_iss;
634
	  slirp->tcp_iss += TCP_ISSINCR/2;
636 635
	  tp->irs = ti->ti_seq;
637 636
	  tcp_sendseqinit(tp);
638 637
	  tcp_rcvseqinit(tp);

Also available in: Unified diff