aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/subscr.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2008-05-19 16:28:32 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-19 16:28:32 -0400
commit8e9501f5188d90eed737240453c32cad01849c96 (patch)
tree44bce2ae23d8e9b3b8b105fc8663fa32fd113dfe /net/tipc/subscr.c
parente15f880409c807bb589e9492263564e80f0de6e9 (diff)
tipc: Add support for customized subscription endianness
This patch enables TIPC's topology server code to do customized endianness conversions on a per-subscription basis. (This capability is needed to support the upcoming consolidation of subscriber and subscription object references.) Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/subscr.c')
-rw-r--r--net/tipc/subscr.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 81e2bd5f2413..a62e5d30638c 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -47,7 +47,6 @@
47 * @subscriber_list: adjacent subscribers in top. server's list of subscribers 47 * @subscriber_list: adjacent subscribers in top. server's list of subscribers
48 * @subscription_list: list of subscription objects for this subscriber 48 * @subscription_list: list of subscription objects for this subscriber
49 * @port_ref: object reference to port used to communicate with subscriber 49 * @port_ref: object reference to port used to communicate with subscriber
50 * @swap: indicates if subscriber uses opposite endianness in its messages
51 */ 50 */
52 51
53struct subscriber { 52struct subscriber {
@@ -56,7 +55,6 @@ struct subscriber {
56 struct list_head subscriber_list; 55 struct list_head subscriber_list;
57 struct list_head subscription_list; 56 struct list_head subscription_list;
58 u32 port_ref; 57 u32 port_ref;
59 int swap;
60}; 58};
61 59
62/** 60/**
@@ -109,11 +107,11 @@ static void subscr_send_event(struct subscription *sub,
109 msg_sect.iov_base = (void *)&sub->evt; 107 msg_sect.iov_base = (void *)&sub->evt;
110 msg_sect.iov_len = sizeof(struct tipc_event); 108 msg_sect.iov_len = sizeof(struct tipc_event);
111 109
112 sub->evt.event = htohl(event, sub->owner->swap); 110 sub->evt.event = htohl(event, sub->swap);
113 sub->evt.found_lower = htohl(found_lower, sub->owner->swap); 111 sub->evt.found_lower = htohl(found_lower, sub->swap);
114 sub->evt.found_upper = htohl(found_upper, sub->owner->swap); 112 sub->evt.found_upper = htohl(found_upper, sub->swap);
115 sub->evt.port.ref = htohl(port_ref, sub->owner->swap); 113 sub->evt.port.ref = htohl(port_ref, sub->swap);
116 sub->evt.port.node = htohl(node, sub->owner->swap); 114 sub->evt.port.node = htohl(node, sub->swap);
117 tipc_send(sub->owner->port_ref, 1, &msg_sect); 115 tipc_send(sub->owner->port_ref, 1, &msg_sect);
118} 116}
119 117
@@ -324,18 +322,16 @@ static void subscr_subscribe(struct tipc_subscr *s,
324 struct subscriber *subscriber) 322 struct subscriber *subscriber)
325{ 323{
326 struct subscription *sub; 324 struct subscription *sub;
325 int swap;
327 326
328 /* Determine/update subscriber's endianness */ 327 /* Determine subscriber's endianness */
329 328
330 if (s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE)) 329 swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE));
331 subscriber->swap = 0;
332 else
333 subscriber->swap = 1;
334 330
335 /* Detect & process a subscription cancellation request */ 331 /* Detect & process a subscription cancellation request */
336 332
337 if (s->filter & htohl(TIPC_SUB_CANCEL, subscriber->swap)) { 333 if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) {
338 s->filter &= ~htohl(TIPC_SUB_CANCEL, subscriber->swap); 334 s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
339 subscr_cancel(s, subscriber); 335 subscr_cancel(s, subscriber);
340 return; 336 return;
341 } 337 }
@@ -360,11 +356,11 @@ static void subscr_subscribe(struct tipc_subscr *s,
360 356
361 /* Initialize subscription object */ 357 /* Initialize subscription object */
362 358
363 sub->seq.type = htohl(s->seq.type, subscriber->swap); 359 sub->seq.type = htohl(s->seq.type, swap);
364 sub->seq.lower = htohl(s->seq.lower, subscriber->swap); 360 sub->seq.lower = htohl(s->seq.lower, swap);
365 sub->seq.upper = htohl(s->seq.upper, subscriber->swap); 361 sub->seq.upper = htohl(s->seq.upper, swap);
366 sub->timeout = htohl(s->timeout, subscriber->swap); 362 sub->timeout = htohl(s->timeout, swap);
367 sub->filter = htohl(s->filter, subscriber->swap); 363 sub->filter = htohl(s->filter, swap);
368 if ((!(sub->filter & TIPC_SUB_PORTS) 364 if ((!(sub->filter & TIPC_SUB_PORTS)
369 == !(sub->filter & TIPC_SUB_SERVICE)) 365 == !(sub->filter & TIPC_SUB_SERVICE))
370 || (sub->seq.lower > sub->seq.upper)) { 366 || (sub->seq.lower > sub->seq.upper)) {
@@ -378,6 +374,7 @@ static void subscr_subscribe(struct tipc_subscr *s,
378 INIT_LIST_HEAD(&sub->subscription_list); 374 INIT_LIST_HEAD(&sub->subscription_list);
379 INIT_LIST_HEAD(&sub->nameseq_list); 375 INIT_LIST_HEAD(&sub->nameseq_list);
380 list_add(&sub->subscription_list, &subscriber->subscription_list); 376 list_add(&sub->subscription_list, &subscriber->subscription_list);
377 sub->swap = swap;
381 atomic_inc(&topsrv.subscription_count); 378 atomic_inc(&topsrv.subscription_count);
382 if (sub->timeout != TIPC_WAIT_FOREVER) { 379 if (sub->timeout != TIPC_WAIT_FOREVER) {
383 k_init_timer(&sub->timer, 380 k_init_timer(&sub->timer,