lkml.org 
[lkml]   [2000]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Raw IPX socket
Date

Hi,

This is a real small patch allowing an IPX socket to be opened in RAW mode.

I have the patch for both 2.4.0-test4 and 2.2.14.

Thanks for your attention,

------------------------------------------------------------------------------
--- linux-2.4.0-test4/net/ipx/af_ipx.c Mon Jun 26 10:07:47 2000
+++ linux-2.4.0-test4-rawipx/net/ipx/af_ipx.c Wed Jun 28 12:18:08 2000
@@ -1758,6 +1758,7 @@

switch(sock->type)
{
+ case SOCK_RAW:
case SOCK_DGRAM:
sk = sk_alloc(PF_IPX, GFP_KERNEL, 1);
if(sk == NULL)
@@ -1801,7 +1802,8 @@
sock->sk = NULL;
ipx_destroy_socket(sk);

- if(sock->type == SOCK_DGRAM)
+ if(sock->type == SOCK_DGRAM ||
+ sock->type == SOCK_RAW)
MOD_DEC_USE_COUNT;

return (0);
@@ -1973,7 +1975,8 @@
addr->sipx_node,IPX_NODE_LEN);
sk->protinfo.af_ipx.type = addr->sipx_type;

- if(sock->type == SOCK_DGRAM )
+ if(sock->type == SOCK_DGRAM ||
+ sock->type == SOCK_RAW)
{
sock->state = SS_CONNECTED;
sk->state = TCP_ESTABLISHED;
@@ -2181,17 +2184,27 @@
goto out;

ipx = skb->nh.ipxh;
- copied = ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
- if(copied > size)
- {
- copied=size;
- msg->msg_flags |= MSG_TRUNC;
- }
-
- err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
+ if (sk->type == SOCK_RAW) {
+ copied = ntohs(ipx->ipx_pktsize);
+ if (copied > size) {
+ copied = size;
+ msg->msg_flags |= MSG_TRUNC;
+ }
+ err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+ } else {
+ copied = ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
+ if(copied > size) {
+ copied=size;
+ msg->msg_flags |= MSG_TRUNC;
+ }
+ err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
copied);
- if(err)
+ }
+ if(err) {
+ printk(KERN_WARNING "err, sockraw is %d\n", sk->type == SOCK_RAW);
goto out_free;
+ }
+
sk->stamp = skb->stamp;

msg->msg_namelen = sizeof(*sipx);
------------------------------------------------------------------------------
--- linux-2.2.14/net/ipx/af_ipx.c Tue Dec 14 10:26:05 1999
+++ linux-2.2.14-rawipx/net/ipx/af_ipx.c Wed Jun 28 12:27:32 2000
@@ -1785,6 +1785,7 @@

switch(sock->type)
{
+ case SOCK_RAW:
case SOCK_DGRAM:
sk = sk_alloc(PF_IPX, GFP_KERNEL, 1);
if(sk == NULL)
@@ -1828,7 +1829,8 @@
sock->sk = NULL;
ipx_destroy_socket(sk);

- if(sock->type == SOCK_DGRAM)
+ if(sock->type == SOCK_DGRAM ||
+ sock->type == SOCK_RAW)
MOD_DEC_USE_COUNT;

return (0);
@@ -2000,7 +2002,8 @@
addr->sipx_node,IPX_NODE_LEN);
sk->protinfo.af_ipx.type = addr->sipx_type;

- if(sock->type == SOCK_DGRAM )
+ if(sock->type == SOCK_DGRAM ||
+ sock->type == SOCK_RAW)
{
sock->state = SS_CONNECTED;
sk->state = TCP_ESTABLISHED;
@@ -2214,17 +2217,27 @@
goto out;

ipx = skb->nh.ipxh;
- copied = ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
- if(copied > size)
- {
- copied=size;
- msg->msg_flags |= MSG_TRUNC;
- }
-
- err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
+ if (sk->type == SOCK_RAW) {
+ copied = ntohs(ipx->ipx_pktsize);
+ if (copied > size) {
+ copied = size;
+ msg->msg_flags |= MSG_TRUNC;
+ }
+ err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+ } else {
+ copied = ntohs(ipx->ipx_pktsize) - sizeof(struct ipxhdr);
+ if(copied > size) {
+ copied=size;
+ msg->msg_flags |= MSG_TRUNC;
+ }
+ err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
copied);
- if(err)
+ }
+ if(err) {
+ printk(KERN_WARNING "err, sockraw is %d\n", sk->type == SOCK_RAW);
goto out_free;
+ }
+
sk->stamp = skb->stamp;

msg->msg_namelen = sizeof(*sipx);
------------------------------------------------------------------------------
--
Frederic.R.Roussel
Lead Software Engineer -o) (o-
Frederic.Roussel@efi.com /\\ Join the penguin force (o_ (o_ //\
(650) 357 3329 _\_v The Linux G3N3R47!0N (/)_ (/)_ v_/_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.147 / U:2.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site