Date: Wed, 23 Jun 1999 17:08:29 -0400 (EDT) From: Dan Seguin <dseg@texar.com> To: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Connect and so on.. Message-ID: <Pine.BSF.4.05.9906231642050.21269-100000@pak2.texar.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9906231642050.21269-100000>