linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: sock-ops->connect()
@ 2002-10-07 10:51 jnf
  0 siblings, 0 replies; 3+ messages in thread
From: jnf @ 2002-10-07 10:51 UTC (permalink / raw)
  To: Elias Athanasopoulos, jnf; +Cc: linux-c-programming


>I'm not very familiar with kernel internals, but I think you don't
>seem to allocate space for the sock structure.
>
 
its still failing even if i allocated space via (sock_alloc())
when i look through the source for sys_socket (/usr/src/linux/net/socket.c)
i see 

...
// sock_create ...
retval = sock_map_fd(sock);

when i look through the source for sock_map_fd, it basically 'creates the file structure and maps it to fd space of the current process.'

which considering in the connect call i see sock->file->f_flags, which seems to make sense that i would want to use this i suppose, but  i also got the impression that this was something done in a translation of sorts from user space to kernel land, but im already in kernel land, so im not really sure, and then not being able to find instances of it anywhere in my header files tells me maybe i dont? 

But I am a tee bit confused and any help would be appreciated 

again thanks
jnf

_____________________________________________________________
Sign up for FREE email from DoItYourself.com at http://doityourself.com

_____________________________________________________________
Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag

^ permalink raw reply	[flat|nested] 3+ messages in thread
* sock-ops->connect()
@ 2002-10-06 10:15 jnf
  2002-10-06 14:36 ` sock-ops->connect() Elias Athanasopoulos
  0 siblings, 1 reply; 3+ messages in thread
From: jnf @ 2002-10-06 10:15 UTC (permalink / raw)
  To: linux-c-programming

I'm working in the kernel trying to learn it better and how it implements networking, and i seem to have the honor of recieving a kernel panic (invalid operand 0000) when i try to make a call to connect(), the code is as follows:

char *ip;
MODULE_PARM(ip,"s");

// ...

struct socket *sock;
struct sockaddr_in adr;
int err,port;

// ...

port = 5260;

err = sock_create(AF_INET,SOCK_STREAM,IPPROTO_TCP,&sock);
if(err < 0) {
     printk("err sock_create\n");
     goto drop;
}

adr.sin_family      = AF_INET;
adr.sin_port        = htons(port);
adr.sin_addr.s_addr = in_aton(ip);
memset(&(adr.sin_zero,'\0',8);

err = sock->ops->connect(sock,(struct sockaddr *)&adr,sizeof(adr),0);

// ... etc

it doesnt make it past the connect() line, and im not sure why, any help would be greatly appreciated. Also what is the suggested method for creating sockets in the kernel? Is it necessary for me to use kernel_thread() ?

thank you
jnf


_____________________________________________________________
Sign up for FREE email from DoItYourself.com at http://doityourself.com

_____________________________________________________________
Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-07 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-07 10:51 sock-ops->connect() jnf
  -- strict thread matches above, loose matches on Subject: below --
2002-10-06 10:15 sock-ops->connect() jnf
2002-10-06 14:36 ` sock-ops->connect() Elias Athanasopoulos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).