DPRINTF(("putmsg: Unimplemented command %x\n", sc.cmd));
DPRINTF(("putmsg: Unimplemented command %lx\n", sc.cmd));
svr4_sys_putmsg(p, v, retval)	register struct proc *p;	void *v;	register_t *retval;{	struct svr4_sys_putmsg_args *uap = v;	struct filedesc	*fdp = p->p_fd;	struct file	*fp;	struct svr4_strbuf dat, ctl;	struct svr4_strmcmd sc;	struct svr4_netaddr *na;	struct socket *so;	struct svr4_strm *st;	int error;	struct sockaddr_in sa, *sap;	caddr_t sg;	if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||	    (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)		return EBADF;#ifdef DEBUG_SVR4	svr4_showmsg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),		     SCARG(uap, dat), SCARG(uap, flags));#endif /* DEBUG_SVR4 */	if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||	    (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)		return EBADF;	if (SCARG(uap, ctl) != NULL) {		if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)			return error;	}	else		ctl.len = -1;	if (SCARG(uap, dat) != NULL) {	    	if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)			return error;	}	else		dat.len = -1;	/*	 * Only for sockets for now.	 */	if (fp == NULL || fp->f_type != DTYPE_SOCKET) {		DPRINTF(("putmsg: bad file type\n"));		return EINVAL;	}	so = (struct socket *)  fp->f_data;	st = (struct svr4_strm *) so->so_internal;	if (ctl.len > sizeof(sc)) {		DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,			 sizeof(struct svr4_strmcmd)));		return EINVAL;	}	if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)		return error;	if (sc.len != sizeof(sa)) {		DPRINTF(("putmsg: Cannot handle variable address lengths\n"));		return ENOSYS;	}	na = SVR4_ADDROF(&sc);	bzero(&sa, sizeof(sa));	sa.sin_family = na->family;	sa.sin_port = na->port;	sa.sin_addr.s_addr = na->addr;	sg = stackgap_init(p->p_emul);	sap = (struct sockaddr_in *) stackgap_alloc(&sg,						    sizeof(struct sockaddr_in));	if ((error = copyout(&sa, sap, sizeof(sa))) != 0)		return error;	switch (st->s_cmd = sc.cmd) {	case SVR4_TI_CONNECT_REQUEST:	/* connect 	*/		{			struct sys_connect_args co;			co.s = SCARG(uap, fd);			co.name = (caddr_t) sap;			co.namelen = (int) sizeof(sa);			return sys_connect(p, &co, retval);		}	case SVR4_TI_SENDTO_REQUEST:	/* sendto 	*/		{			struct msghdr msg;			struct iovec aiov;			msg.msg_name = (caddr_t) sap;			msg.msg_namelen = sizeof(sa);			msg.msg_iov = &aiov;			msg.msg_iovlen = 1;			msg.msg_control = 0;#ifdef COMPAT_OLDSOCK			msg.msg_flags = 0;#endif /* COMPAT_OLDSOCK */			aiov.iov_base = dat.buf;			aiov.iov_len = dat.len;			error = sendit(p, SCARG(uap, fd), &msg,				       SCARG(uap, flags), retval);			*retval = 0;			return error;		}	default:		DPRINTF(("putmsg: Unimplemented command %x\n", sc.cmd));		return ENOSYS;	}}