From owner-freebsd-hackers Wed Jun 23 14: 6:25 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from pak2.texar.com (unknown [216.208.160.130]) by hub.freebsd.org (Postfix) with ESMTP id 404571535D for ; Wed, 23 Jun 1999 14:05:40 -0700 (PDT) (envelope-from dseg@pak2.texar.com) Received: from localhost (dseg@localhost) by pak2.texar.com (8.9.2/8.8.3) with ESMTP id RAA21346 for ; Wed, 23 Jun 1999 17:08:30 -0400 (EDT) Date: Wed, 23 Jun 1999 17:08:29 -0400 (EDT) From: Dan Seguin To: FreeBSD Hackers Subject: Connect and so on.. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi All. I'm trying to create a system call that will burst a (pseudo) quick tcp message out to a remote host every time that it is called. I've got the system call all worked out as a kld, it loads and restores without a hitch. I use the calling proc's table as it is passed to the system call, and am trying to call socket and connect as if the user process originally called them one by one (from userland syscall 97 and 98). I seem to be getting the correct behaviour from socket, but the connect call fails. After DDB'ing and breaking on the call to connect, it appears to fail at copyin with an EFAULT (invalid address). Call stack: copyin from getsockaddr from connect. What am I missing here, and/or what incorrect assumptions have I made? I'm including the actual system call function below. Thanks! Dan P.S. I test the system call from userland with a small C prog that uses syscall(). -------- CODE starts ---------------- static int init_comms(p, uap) struct proc *p; register struct nosys_args *uap; { int sockfd1, stat; struct socket_args socket_uap; struct connect_args connect_uap; static struct sockaddr_in servaddr; socket_uap.domain = PF_LOCAL; socket_uap.type = SOCK_STREAM; socket_uap.protocol = 0; printf("\ninit_comms: proc -> pid: %d\n", (int) p->p_pid); stat = socket(p, &socket_uap); sockfd1 = p->p_retval[0]; bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_LOCAL; servaddr.sin_port = htons(13); servaddr.sin_len = sizeof servaddr; if ( inet_aton((char *) "127.0.0.1", &servaddr.sin_addr) <= 0 ) printf("\ninet_aton failed.\n"); printf("\nservaddr: %x\n", servaddr.sin_addr.s_addr); /* Prints 100007e */ connect_uap.s = sockfd1; connect_uap.name = (caddr_t) &servaddr; connect_uap.namelen = sizeof servaddr; stat = 0; stat = connect(p, &connect_uap); printf("\nConnect Stat: %d\n", stat); /* Prints 14 (EFAULT) */ return 0; } ------------------------- Code Ends ----------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message