Jan,
In attach i send you a diff file regarding the af_packet.c file where the RAW
SOCKET is implemented, similar to the DGRAM SOCKET.
I've already run some tests on it and everything looks OK.
Please run some more, or ask to (to some other interested person) and publish
the results.
Now i'm starting with the ETH_P_ALL to the protocol definition.
Were, in the code, can i start to see the protocol filter implementation?
And wath is the best thing to do regarding ETH_P_ALL? Remove from QUEUE or
copy the message from buffer and it still remains there? The second has the
problem of the queue grows undefined.
Any suggestions?
Thanks
--
Jorge Almeida
[EMAIL PROTECTED]
DISCLAIMER: This message may contain confidential information or privileged
material and is intended only for the individual(s) named. If you are not a
named addressee and mistakenly received this message you should not copy or
otherwise disseminate it: please delete this e-mail from your system and notify
the sender immediately. E-mail transmissions are not guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete or contain viruses. Therefore, the sender does not
accept liability for any errors or omissions in the contents of this message
that arise as a result of e-mail transmissions. Please request a hard copy
version if verification is required. Critical Software, SA.
--- rtnet-0.9.4/stack/packet/af_packet.c 2006-08-06 19:23:36.000000000 +0100
+++ rtnet-0.9.4/stack/packet/af_packet.c 2006-08-28 16:07:35.000000000 +0100
@@ -89,7 +89,7 @@
rtdm_lock_get_irqsave(&sock->param_lock, context);
- /* release exisiting binding */
+ /* release existing binding */
if ((pt->type != 0) && ((ret = rtdev_remove_pack(pt)) < 0)) {
rtdm_lock_put_irqrestore(&sock->param_lock, context);
return ret;
@@ -277,7 +277,7 @@
/* non-blocking receive? */
if (testbits(msg_flags, MSG_DONTWAIT))
timeout = -1;
-
+// rt_printk("Packet:DEBUG: timeout %lld \n",timeout);
ret = rtdm_sem_timeddown(&sock->pending_sem, timeout, NULL);
if (unlikely(ret < 0)) {
if ((ret != -EWOULDBLOCK) && (ret != -ETIMEDOUT))
@@ -313,10 +313,45 @@
copy_len = len;
msg->msg_flags |= MSG_TRUNC;
}
+
+ if(sockctx->device->socket_type == SOCK_DGRAM)
+ {
+// rt_printk("Packet:DEBUG: SOCKET DGRAM SELECTED\n");
+ /* copy the data */
+ rt_memcpy_tokerneliovec(msg->msg_iov, skb->data, copy_len);
+ }
+ else if (sockctx->device->socket_type == SOCK_RAW)
+ {
+ int nBufferLen = 0;
+ int nI = 0;
+ unsigned char puchBuffer[ETH_FRAME_LEN] = {0};
+
+ memcpy((puchBuffer+nBufferLen), eth->h_dest,ETH_ALEN);
+ nBufferLen += ETH_ALEN;
- /* copy the data */
- rt_memcpy_tokerneliovec(msg->msg_iov, skb->data, copy_len);
+ memcpy((puchBuffer+nBufferLen), eth->h_source,ETH_ALEN);
+ nBufferLen += ETH_ALEN;
+
+ memcpy((puchBuffer+nBufferLen), &(eth->h_proto),2);
+ nBufferLen += 2;
+ memcpy((puchBuffer+nBufferLen), skb->data, copy_len);
+ nBufferLen += copy_len;
+ /* start DEBUG purpouse*/
+// rt_printk("Message Received: ");
+// for(nI = 0; nI <nBufferLen ; nI++)
+// rt_printk(" %02X",puchBuffer[nI]);
+// rt_printk("\n");
+ /* end DEBUG purpouse*/
+ /* copy the data to user */
+ rt_memcpy_tokerneliovec(msg->msg_iov, puchBuffer, nBufferLen);
+ /* new buffer length*/
+ real_len = nBufferLen;
+ }
+ else
+ {
+ rt_printk("Packet: Socket type Not Supported\n");
+ }
if ((msg_flags & MSG_PEEK) == 0) {
rtdev_dereference(skb->rtdev);
kfree_rtskb(skb);
@@ -383,12 +418,38 @@
rtskb->rtdev = rtdev;
rtskb->priority = sock->priority;
-
- if (rtdev->hard_header) {
- ret = rtdev->hard_header(rtskb, rtdev, ntohs(sll->sll_protocol),
- sll->sll_addr, rtdev->dev_addr, rtskb->len);
- if (ret < 0)
- goto err;
+ // SOCK_DGRAM
+ if(sockctx->device->socket_type == SOCK_DGRAM)
+ {
+// rt_printk("Packet:DEBUG: SOCKET DGRAM SELECTED\n");
+
+ if (rtdev->hard_header) {
+ ret = rtdev->hard_header(rtskb, rtdev, ntohs(sll->sll_protocol),
+ sll->sll_addr, rtdev->dev_addr, rtskb->len);
+ if (ret < 0)
+ goto err;
+ }
+ }
+ // SOCK_RAW
+ else if (sockctx->device->socket_type == SOCK_RAW)
+ {
+// rt_printk("Packet:DEBUG: SOCKET RAW SELECTED\n");
+ unsigned char puchBuffer[ETH_FRAME_LEN];
+
+ if (rtdev->hard_header) {
+ ret = rtdev->hard_header(rtskb, rtdev, (rtskb->data+ETH_ALEN+ETH_ALEN),
+ sll->sll_addr, (rtskb->data+ETH_ALEN), (rtskb->len - ETH_HLEN));
+ if (ret < 0)
+ goto err;
+ }
+ memcpy(puchBuffer,rtskb->data,rtskb->len);
+ memcpy(rtskb->data,(puchBuffer+ETH_HLEN),(rtskb->len - ETH_HLEN));
+ rtskb->len = rtskb->len - ETH_HLEN;
+// rt_printk("Packet:DEBUG: SOCKET RAW SELECTED and exit\n");
+ }
+ else
+ {
+ rt_printk("Packet: Socket type Not Supported\n");
}
if ((rtdev->flags & IFF_UP) != 0) {
@@ -409,8 +470,6 @@
return ret;
}
-
-
static struct rtdm_device packet_proto_dev = {
struct_version: RTDM_DEVICE_STRUCT_VER,
@@ -430,7 +489,7 @@
ioctl_nrt: rt_packet_ioctl,
recvmsg_rt: rt_packet_recvmsg,
sendmsg_rt: rt_packet_sendmsg
- },
+},
device_class: RTDM_CLASS_NETWORK,
device_sub_class: RTDM_SUBCLASS_RTNET,
@@ -443,15 +502,55 @@
};
+static struct rtdm_device raw_packet_proto_dev = {
+ struct_version: RTDM_DEVICE_STRUCT_VER,
+
+ device_flags: RTDM_PROTOCOL_DEVICE,
+ context_size: sizeof(struct rtsocket),
+
+ protocol_family: PF_PACKET,
+ socket_type: SOCK_RAW,
+
+ socket_rt: rt_packet_socket,
+ socket_nrt: rt_packet_socket,
+
+ ops: {
+ close_rt: rt_packet_close,
+ close_nrt: rt_packet_close,
+ ioctl_rt: rt_packet_ioctl,
+ ioctl_nrt: rt_packet_ioctl,
+ recvmsg_rt: rt_packet_recvmsg,
+ sendmsg_rt: rt_packet_sendmsg
+ },
+
+ device_class: RTDM_CLASS_NETWORK,
+ device_sub_class: RTDM_SUBCLASS_RTNET,
+ driver_name: "rtrawpacket",
+ driver_version: RTNET_RTDM_VER,
+ peripheral_name: "Real-Time Packet Socket Interface",
+ provider_name: rtnet_rtdm_provider_name,
+
+ proc_name: "PACKET_RAW"
+};
+
+
int __init rt_packet_proto_init(void)
{
- return rtdm_dev_register(&packet_proto_dev);
+ int nReturn = -1;
+ nReturn = rtdm_dev_register(&packet_proto_dev);
+ if(nReturn != 0)
+ return nReturn;
+// rt_printk("DGRAM return = %d\n",nReturn);
+ nReturn = rtdm_dev_register(&raw_packet_proto_dev);
+// rt_printk("RAW return = %d\n",nReturn);
+ return nReturn;
}
void rt_packet_proto_release(void)
{
rtdm_dev_unregister(&packet_proto_dev, 1000);
+ rtdm_dev_unregister(&raw_packet_proto_dev, 1000);
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
RTnet-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-developers