2 * net/tipc/port.c: TIPC port code
4 * Copyright (c) 1992-2007, 2014, Ericsson AB
5 * Copyright (c) 2004-2008, 2010-2013, Wind River Systems
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
40 #include "name_table.h"
43 #define MAX_REJECT_SIZE 1024
46 * tipc_port_peer_msg - verify message was sent by connected port's peer
48 * Handles cases where the node's network address has changed from
49 * the default of <0.0.0> to its configured setting.
51 int tipc_port_peer_msg(struct tipc_port
*p_ptr
, struct tipc_msg
*msg
)
56 if (msg_origport(msg
) != tipc_port_peerport(p_ptr
))
59 orignode
= msg_orignode(msg
);
60 peernode
= tipc_port_peernode(p_ptr
);
61 return (orignode
== peernode
) ||
62 (!orignode
&& (peernode
== tipc_own_addr
)) ||
63 (!peernode
&& (orignode
== tipc_own_addr
));
66 int tipc_publish(struct tipc_port
*p_ptr
, unsigned int scope
,
67 struct tipc_name_seq
const *seq
)
69 struct publication
*publ
;
74 key
= p_ptr
->ref
+ p_ptr
->pub_count
+ 1;
75 if (key
== p_ptr
->ref
)
78 publ
= tipc_nametbl_publish(seq
->type
, seq
->lower
, seq
->upper
,
79 scope
, p_ptr
->ref
, key
);
81 list_add(&publ
->pport_list
, &p_ptr
->publications
);
89 int tipc_withdraw(struct tipc_port
*p_ptr
, unsigned int scope
,
90 struct tipc_name_seq
const *seq
)
92 struct publication
*publ
;
93 struct publication
*tpubl
;
97 list_for_each_entry_safe(publ
, tpubl
,
98 &p_ptr
->publications
, pport_list
) {
99 tipc_nametbl_withdraw(publ
->type
, publ
->lower
,
100 publ
->ref
, publ
->key
);
104 list_for_each_entry_safe(publ
, tpubl
,
105 &p_ptr
->publications
, pport_list
) {
106 if (publ
->scope
!= scope
)
108 if (publ
->type
!= seq
->type
)
110 if (publ
->lower
!= seq
->lower
)
112 if (publ
->upper
!= seq
->upper
)
114 tipc_nametbl_withdraw(publ
->type
, publ
->lower
,
115 publ
->ref
, publ
->key
);
120 if (list_empty(&p_ptr
->publications
))
121 p_ptr
->published
= 0;
This page took 0.060026 seconds and 5 git commands to generate.