Revision 3b46e624 slirp/udp.c

b/slirp/udp.c
168 168
	if (so->so_lport != uh->uh_sport ||
169 169
	    so->so_laddr.s_addr != ip->ip_src.s_addr) {
170 170
		struct socket *tmp;
171
	
171

  
172 172
		for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) {
173 173
			if (tmp->so_lport == uh->uh_sport &&
174 174
			    tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
......
198 198
	    sofree(so);
199 199
	    goto bad;
200 200
	  }
201
	 
201

  
202 202
	  /*
203 203
	   * Setup fields
204 204
	   */
205 205
	  /* udp_last_so = so; */
206 206
	  so->so_laddr = ip->ip_src;
207 207
	  so->so_lport = uh->uh_sport;
208
	 
208

  
209 209
	  if ((so->so_iptos = udp_tos(so)) == 0)
210 210
	    so->so_iptos = ip->ip_tos;
211
	 
211

  
212 212
	  /*
213 213
	   * XXXXX Here, check if it's in udpexec_list,
214 214
	   * and if it is, do the fork_exec() etc.
......
233 233
	  m->m_data -= iphlen;
234 234
	  *ip=save_ip;
235 235
	  DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
236
	  icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno)); 
236
	  icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
237 237
	}
238 238

  
239 239
	m_free(so->so_m);   /* used for ICMP if error on sorecvfrom */
......
320 320
    }
321 321
    daddr.sin_addr = so->so_laddr;
322 322
    daddr.sin_port = so->so_lport;
323
   
323

  
324 324
    return udp_output2(so, m, &saddr, &daddr, so->so_iptos);
325 325
}
326 326

  
......
449 449
		 */
450 450
		if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
451 451
			return;
452
	
452

  
453 453
#define	IS_OLD	(so->so_emu == EMU_TALK)
454 454

  
455 455
#define COPY_MSG(dest, src) { dest->type = src->type; \
......
480 480
			OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
481 481
			strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
482 482
		}
483
	
483

  
484 484
		if (type == LOOK_UP)
485 485
			return;		/* for LOOK_UP this is enough */
486
		
486

  
487 487
		if (IS_OLD) {		/* make a copy of the message */
488 488
			COPY_MSG(nmsg, omsg);
489 489
			nmsg->vers = 1;
......
507 507
		if (type == ANNOUNCE) {
508 508
			int s;
509 509
			u_short temp_port;
510
		
510

  
511 511
			for(req = req_tbl; req; req = req->next)
512 512
				if (so == req->udp_so)
513 513
					break;  	/* found it */
514
				
514

  
515 515
			if (!req) {	/* no entry for so, create new */
516 516
				req = (struct talk_request *)
517 517
					malloc(sizeof(struct talk_request));
518 518
				req->udp_so = so;
519
				req->tcp_so = solisten(0,	
519
				req->tcp_so = solisten(0,
520 520
					OTOSIN(omsg, addr)->sin_addr.s_addr,
521 521
					OTOSIN(omsg, addr)->sin_port,
522 522
					SS_FACCEPTONCE);
523 523
				req->next = req_tbl;
524 524
				req_tbl = req;
525
			}		
526
		
525
			}
526

  
527 527
			/* replace port number in addr field */
528 528
			addrlen = sizeof(addr);
529 529
			getsockname(req->tcp_so->s,
530 530
					(struct sockaddr *) &addr,
531
					&addrlen);	
531
					&addrlen);
532 532
			OTOSIN(omsg, addr)->sin_port = addr.sin_port;
533 533
			OTOSIN(omsg, addr)->sin_addr = our_addr;
534 534
			OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
535
			OTOSIN(nmsg, addr)->sin_addr = our_addr;	
536
		
535
			OTOSIN(nmsg, addr)->sin_addr = our_addr;
536

  
537 537
			/* send LEAVE_INVITEs */
538 538
			temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
539 539
			OTOSIN(omsg, ctl_addr)->sin_port = 0;
540 540
			OTOSIN(nmsg, ctl_addr)->sin_port = 0;
541
			omsg->type = nmsg->type = LEAVE_INVITE;		
542
		
541
			omsg->type = nmsg->type = LEAVE_INVITE;
542

  
543 543
			s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
544 544
			addr.sin_addr = our_addr;
545 545
			addr.sin_family = AF_INET;
......
555 555
			OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
556 556
			OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
557 557
		}
558
	
558

  
559 559
		/*
560 560
		 * If it is a DELETE message, we send a copy to the
561 561
		 * local daemons. Then we delete the entry corresponding
562 562
		 * to our socket from the request table.
563 563
		 */
564
	
564

  
565 565
		if (type == DELETE) {
566 566
			struct talk_request *temp_req, *req_next;
567 567
			int s;
568 568
			u_short temp_port;
569
		
569

  
570 570
			temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
571 571
			OTOSIN(omsg, ctl_addr)->sin_port = 0;
572 572
			OTOSIN(nmsg, ctl_addr)->sin_port = 0;
573
		
573

  
574 574
			s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
575 575
			addr.sin_addr = our_addr;
576 576
			addr.sin_family = AF_INET;
......
581 581
			sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
582 582
				(struct sockaddr *)&addr, sizeof(addr));
583 583
			closesocket(s);
584
		
584

  
585 585
			OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
586 586
			OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
587 587

  
......
604 604
				}
605 605
			}
606 606
		}
607
	
608
		return;	
607

  
608
		return;
609 609
#endif
610
	
610

  
611 611
	case EMU_CUSEEME:
612 612

  
613 613
		/*
......
623 623
			cu_head->s_port = addr.sin_port;
624 624
			cu_head->so_addr = our_addr.s_addr;
625 625
		}
626
	
626

  
627 627
		return;
628 628
	}
629 629
}

Also available in: Unified diff