summaryrefslogtreecommitdiff
path: root/debian/patches/0013-pfinet-make-the-demuxers-payload-aware.patch
blob: 30c144afe389f8f5c99b1f3ebada489af4d36244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From ea0ceb8c7b62a4ba8ddabdfb8cb80acbc25106a6 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sun, 13 Apr 2014 14:03:48 +0200
Subject: [PATCH hurd 13/30] pfinet: make the demuxers payload-aware

* pfinet/ethernet.c (ethernet_demuxer): Make the demuxer payload-aware.
* pfinet/main.c (pfinet_demuxer): Likewise.
---
 pfinet/ethernet.c | 20 +++++++++++++++++++-
 pfinet/main.c     | 10 +++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c
index 053fd1b..17967ce 100644
--- a/pfinet/ethernet.c
+++ b/pfinet/ethernet.c
@@ -116,12 +116,30 @@ ethernet_demuxer (mach_msg_header_t *inp,
   int datalen;
   struct ether_device *edev;
   struct device *dev = 0;
+  mach_port_t local_port;
 
   if (inp->msgh_id != NET_RCV_MSG_ID)
     return 0;
 
+  if (MACH_MSGH_BITS_LOCAL (inp->msgh_bits) ==
+      MACH_MSG_TYPE_PROTECTED_PAYLOAD)
+    {
+      struct port_info *pi = ports_lookup_payload (NULL,
+                                                   inp->msgh_protected_payload,
+                                                   NULL);
+      if (pi)
+        {
+          local_port = pi->port_right;
+          ports_port_deref (pi);
+        }
+      else
+        local_port = MACH_PORT_NULL;
+    }
+  else
+    local_port = inp->msgh_local_port;
+
   for (edev = ether_dev; edev; edev = edev->next)
-    if (inp->msgh_local_port == edev->readptname)
+    if (local_port == edev->readptname)
       dev = &edev->dev;
 
   if (! dev)
diff --git a/pfinet/main.c b/pfinet/main.c
index 0f1fbfc..e0599bb 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -86,7 +86,15 @@ pfinet_demuxer (mach_msg_header_t *inp,
 
   /* We have several classes in one bucket, which need to be demuxed
      differently.  */
-  pi = ports_lookup_port(pfinet_bucket, inp->msgh_local_port, socketport_class);
+  if (MACH_MSGH_BITS_LOCAL (inp->msgh_bits) ==
+      MACH_MSG_TYPE_PROTECTED_PAYLOAD)
+    pi = ports_lookup_payload (pfinet_bucket,
+                               inp->msgh_protected_payload,
+                               socketport_class);
+  else
+    pi = ports_lookup_port (pfinet_bucket,
+                            inp->msgh_local_port,
+                            socketport_class);
   
   if (pi)
     {
-- 
2.1.3