From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTs4l-00054l-8z for qemu-devel@nongnu.org; Thu, 23 Jul 2009 02:46:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTs4g-00053O-Nw for qemu-devel@nongnu.org; Thu, 23 Jul 2009 02:46:46 -0400 Received: from [199.232.76.173] (port=55078 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTs4g-000538-Cc for qemu-devel@nongnu.org; Thu, 23 Jul 2009 02:46:42 -0400 Received: from mx20.gnu.org ([199.232.41.8]:18635) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MTs4f-0006NU-Kv for qemu-devel@nongnu.org; Thu, 23 Jul 2009 02:46:42 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MTs4e-0002Mh-BB for qemu-devel@nongnu.org; Thu, 23 Jul 2009 02:46:41 -0400 Message-ID: <4A68074C.1030000@web.de> Date: Thu, 23 Jul 2009 08:46:36 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1248310395.14831.22.camel@localhost.localdomain> In-Reply-To: <1248310395.14831.22.camel@localhost.localdomain> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA111A67B3DE93C0A95BF1246" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] slirp: Remove UDP protocol emulation (talk, cuseeme) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ed Swierk Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA111A67B3DE93C0A95BF1246 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Ed Swierk wrote: > The UDP emulation code for talk has been commented out since the > beginning of time, and unless someone who runs CU-SeeMe on qemu with > user-mode networking can vouch that the special magic (a) is necessary > and (b) works, let's get rid of the code. >=20 > Signed-off-by: Ed Swierk >=20 As expressed before, I don't feel like I could comment on the usefulness of the to-be-removed emulation. But if no one speaks up on this, the patch has my ack. Jan > --- > diff --git a/slirp/misc.h b/slirp/misc.h > index c335394..da68d09 100644 > --- a/slirp/misc.h > +++ b/slirp/misc.h > @@ -36,11 +36,6 @@ void do_wait(int); > =20 > #define EMU_NOCONNECT 0x10 /* Don't connect */ > =20 > -/* UDP emulations */ > -#define EMU_TALK 0x1 > -#define EMU_NTALK 0x2 > -#define EMU_CUSEEME 0x3 > - > struct tos_t { > u_int16_t lport; > u_int16_t fport; > diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h > index 5a0e6c1..e977e77 100644 > --- a/slirp/slirp_config.h > +++ b/slirp/slirp_config.h > @@ -2,9 +2,6 @@ > * User definable configuration options > */ > =20 > -/* Undefine if you don't want talk emulation */ > -#undef EMULATE_TALK > - > /* Define if you want the connection to be probed */ > /* XXX Not working yet, so ignore this for now */ > #undef PROBE_CONN > diff --git a/slirp/udp.c b/slirp/udp.c > index e0a6693..a88b645 100644 > --- a/slirp/udp.c > +++ b/slirp/udp.c > @@ -42,7 +42,6 @@ > #include "ip_icmp.h" > =20 > static u_int8_t udp_tos(struct socket *so); > -static void udp_emu(struct socket *so, struct mbuf *m); > =20 > void > udp_init(Slirp *slirp) > @@ -202,9 +201,6 @@ udp_input(register struct mbuf *m, int iphlen) > /* > * Now we sendto() the packet. > */ > - if (so->so_emu) > - udp_emu(so, m); > - > if(sosendto(so,m) =3D=3D -1) { > m->m_len +=3D iphlen; > m->m_data -=3D iphlen; > @@ -306,31 +302,9 @@ int udp_output(struct socket *so, struct mbuf *m, > int > udp_attach(struct socket *so) > { > - struct sockaddr_in addr; > - > if((so->s =3D socket(AF_INET,SOCK_DGRAM,0)) !=3D -1) { > - /* > - * Here, we bind() the socket. Although not really needed > - * (sendto() on an unbound socket will bind it), it's done > - * here so that emulation of ytalk etc. don't have to do it > - */ > - addr.sin_family =3D AF_INET; > - addr.sin_port =3D 0; > - addr.sin_addr.s_addr =3D INADDR_ANY; > - if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) { > - int lasterrno=3Derrno; > - closesocket(so->s); > - so->s=3D-1; > -#ifdef _WIN32 > - WSASetLastError(lasterrno); > -#else > - errno=3Dlasterrno; > -#endif > - } else { > - /* success, insert in queue */ > - so->so_expire =3D curtime + SO_EXPIRE; > - insque(so, &so->slirp->udb); > - } > + so->so_expire =3D curtime + SO_EXPIRE; > + insque(so, &so->slirp->udb); > } > return(so->s); > } > @@ -344,9 +318,6 @@ udp_detach(struct socket *so) > =20 > static const struct tos_t udptos[] =3D { > {0, 53, IPTOS_LOWDELAY, 0}, /* DNS */ > - {517, 517, IPTOS_LOWDELAY, EMU_TALK}, /* talk */ > - {518, 518, IPTOS_LOWDELAY, EMU_NTALK}, /* ntalk */ > - {0, 7648, IPTOS_LOWDELAY, EMU_CUSEEME}, /* Cu-Seeme */ > {0, 0, 0, 0} > }; > =20 > @@ -367,239 +338,6 @@ udp_tos(struct socket *so) > return 0; > } > =20 > -#ifdef EMULATE_TALK > -#include "talkd.h" > -#endif > - > -/* > - * Here, talk/ytalk/ntalk requests must be emulated > - */ > -static void > -udp_emu(struct socket *so, struct mbuf *m) > -{ > - struct sockaddr_in addr; > - socklen_t addrlen =3D sizeof(addr); > -#ifdef EMULATE_TALK > - CTL_MSG_OLD *omsg; > - CTL_MSG *nmsg; > - char buff[sizeof(CTL_MSG)]; > - u_char type; > - > -struct talk_request { > - struct talk_request *next; > - struct socket *udp_so; > - struct socket *tcp_so; > -} *req; > - > - static struct talk_request *req_tbl =3D 0; > - > -#endif > - > -struct cu_header { > - uint16_t d_family; // destination family > - uint16_t d_port; // destination port > - uint32_t d_addr; // destination address > - uint16_t s_family; // source family > - uint16_t s_port; // source port > - uint32_t so_addr; // source address > - uint32_t seqn; // sequence number > - uint16_t message; // message > - uint16_t data_type; // data type > - uint16_t pkt_len; // packet length > -} *cu_head; > - > - switch(so->so_emu) { > - > -#ifdef EMULATE_TALK > - case EMU_TALK: > - case EMU_NTALK: > - /* > - * Talk emulation. We always change the ctl_addr to get > - * some answers from the daemon. When an ANNOUNCE comes, > - * we send LEAVE_INVITE to the local daemons. Also when a > - * DELETE comes, we send copies to the local daemons. > - */ > - if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0) > - return; > - > -#define IS_OLD (so->so_emu =3D=3D EMU_TALK) > - > -#define COPY_MSG(dest, src) { dest->type =3D src->type; \ > - dest->id_num =3D src->id_num; \ > - dest->pid =3D src->pid; \ > - dest->addr =3D src->addr; \ > - dest->ctl_addr =3D src->ctl_addr; \ > - memcpy(&dest->l_name, &src->l_name, NAME_SIZE_OLD); \ > - memcpy(&dest->r_name, &src->r_name, NAME_SIZE_OLD); \ > - memcpy(&dest->r_tty, &src->r_tty, TTY_SIZE); } > - > -#define OTOSIN(ptr, field) ((struct sockaddr_in *)&ptr->field) > -/* old_sockaddr to sockaddr_in */ > - > - > - if (IS_OLD) { /* old talk */ > - omsg =3D mtod(m, CTL_MSG_OLD*); > - nmsg =3D (CTL_MSG *) buff; > - type =3D omsg->type; > - OTOSIN(omsg, ctl_addr)->sin_port =3D addr.sin_port; > - OTOSIN(omsg, ctl_addr)->sin_addr =3D our_addr; > - pstrcpy(omsg->l_name, NAME_SIZE_OLD, getlogin(= )); > - } else { /* new talk */ > - omsg =3D (CTL_MSG_OLD *) buff; > - nmsg =3D mtod(m, CTL_MSG *); > - type =3D nmsg->type; > - OTOSIN(nmsg, ctl_addr)->sin_port =3D addr.sin_port; > - OTOSIN(nmsg, ctl_addr)->sin_addr =3D our_addr; > - pstrcpy(nmsg->l_name, NAME_SIZE_OLD, getlogin(= )); > - } > - > - if (type =3D=3D LOOK_UP) > - return; /* for LOOK_UP this is enough */ > - > - if (IS_OLD) { /* make a copy of the message */ > - COPY_MSG(nmsg, omsg); > - nmsg->vers =3D 1; > - nmsg->answer =3D 0; > - } else > - COPY_MSG(omsg, nmsg); > - > - /* > - * If if is an ANNOUNCE message, we go through the > - * request table to see if a tcp port has already > - * been redirected for this socket. If not, we solisten() > - * a new socket and add this entry to the table. > - * The port number of the tcp socket and our IP > - * are put to the addr field of the message structures. > - * Then a LEAVE_INVITE is sent to both local daemon > - * ports, 517 and 518. This is why we have two copies > - * of the message, one in old talk and one in new talk > - * format. > - */ > - > - if (type =3D=3D ANNOUNCE) { > - int s; > - u_short temp_port; > - > - for(req =3D req_tbl; req; req =3D req->next) > - if (so =3D=3D req->udp_so) > - break; /* found it */ > - > - if (!req) { /* no entry for so, create new */ > - req =3D (struct talk_request *) > - malloc(sizeof(struct talk_request)); > - req->udp_so =3D so; > - req->tcp_so =3D solisten(0, > - OTOSIN(omsg, addr)->sin_addr.s_addr, > - OTOSIN(omsg, addr)->sin_port, > - SS_FACCEPTONCE); > - req->next =3D req_tbl; > - req_tbl =3D req; > - } > - > - /* replace port number in addr field */ > - addrlen =3D sizeof(addr); > - getsockname(req->tcp_so->s, > - (struct sockaddr *) &addr, > - &addrlen); > - OTOSIN(omsg, addr)->sin_port =3D addr.sin_port; > - OTOSIN(omsg, addr)->sin_addr =3D our_addr; > - OTOSIN(nmsg, addr)->sin_port =3D addr.sin_port; > - OTOSIN(nmsg, addr)->sin_addr =3D our_addr; > - > - /* send LEAVE_INVITEs */ > - temp_port =3D OTOSIN(omsg, ctl_addr)->sin_port; > - OTOSIN(omsg, ctl_addr)->sin_port =3D 0; > - OTOSIN(nmsg, ctl_addr)->sin_port =3D 0; > - omsg->type =3D nmsg->type =3D LEAVE_INVITE; > - > - s =3D socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); > - addr.sin_addr =3D our_addr; > - addr.sin_family =3D AF_INET; > - addr.sin_port =3D htons(517); > - sendto(s, (char *)omsg, sizeof(*omsg), 0, > - (struct sockaddr *)&addr, sizeof(addr)); > - addr.sin_port =3D htons(518); > - sendto(s, (char *)nmsg, sizeof(*nmsg), 0, > - (struct sockaddr *) &addr, sizeof(addr)); > - closesocket(s) ; > - > - omsg->type =3D nmsg->type =3D ANNOUNCE; > - OTOSIN(omsg, ctl_addr)->sin_port =3D temp_port; > - OTOSIN(nmsg, ctl_addr)->sin_port =3D temp_port; > - } > - > - /* > - * If it is a DELETE message, we send a copy to the > - * local daemons. Then we delete the entry corresponding > - * to our socket from the request table. > - */ > - > - if (type =3D=3D DELETE) { > - struct talk_request *temp_req, *req_next; > - int s; > - u_short temp_port; > - > - temp_port =3D OTOSIN(omsg, ctl_addr)->sin_port; > - OTOSIN(omsg, ctl_addr)->sin_port =3D 0; > - OTOSIN(nmsg, ctl_addr)->sin_port =3D 0; > - > - s =3D socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); > - addr.sin_addr =3D our_addr; > - addr.sin_family =3D AF_INET; > - addr.sin_port =3D htons(517); > - sendto(s, (char *)omsg, sizeof(*omsg), 0, > - (struct sockaddr *)&addr, sizeof(addr)); > - addr.sin_port =3D htons(518); > - sendto(s, (char *)nmsg, sizeof(*nmsg), 0, > - (struct sockaddr *)&addr, sizeof(addr)); > - closesocket(s); > - > - OTOSIN(omsg, ctl_addr)->sin_port =3D temp_port; > - OTOSIN(nmsg, ctl_addr)->sin_port =3D temp_port; > - > - /* delete table entry */ > - if (so =3D=3D req_tbl->udp_so) { > - temp_req =3D req_tbl; > - req_tbl =3D req_tbl->next; > - free(temp_req); > - } else { > - temp_req =3D req_tbl; > - for(req =3D req_tbl->next; req; req =3D req_next) { > - req_next =3D req->next; > - if (so =3D=3D req->udp_so) { > - temp_req->next =3D req_next; > - free(req); > - break; > - } else { > - temp_req =3D req; > - } > - } > - } > - } > - > - return; > -#endif > - > - case EMU_CUSEEME: > - > - /* > - * Cu-SeeMe emulation. > - * Hopefully the packet is more that 16 bytes long. We don't > - * do any other tests, just replace the address and port > - * fields. > - */ > - if (m->m_len >=3D sizeof (*cu_head)) { > - if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0) > - return; > - cu_head =3D mtod(m, struct cu_header *); > - cu_head->s_port =3D addr.sin_port; > - cu_head->so_addr =3D our_addr.s_addr; > - } > - > - return; > - } > -} > - > struct socket * > udp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr= , > u_int lport, int flags) >=20 >=20 >=20 >=20 >=20 --------------enigA111A67B3DE93C0A95BF1246 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpoB0wACgkQniDOoMHTA+m8PACfe3f1HLqXguJj68zKDWVQyp4B 6fgAn0s6wwbQaJW+s2kNToAs1WyVgpPg =XIp7 -----END PGP SIGNATURE----- --------------enigA111A67B3DE93C0A95BF1246--