2 * net/tipc/config.c: TIPC configuration management code
4 * Copyright (c) 2002-2006, Ericsson AB
5 * Copyright (c) 2004-2007, 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.
44 #include "name_table.h"
53 struct list_head subd_list
;
60 u32 link_subscriptions
;
61 struct list_head link_subscribers
;
64 static struct manager mng
= { 0};
66 static DEFINE_SPINLOCK(config_lock
);
68 static const void *req_tlv_area
; /* request message TLV area */
69 static int req_tlv_space
; /* request message TLV area size */
70 static int rep_headroom
; /* reply message headroom to use */
73 void tipc_cfg_link_event(u32 addr
, char *name
, int up
)
75 /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */
79 struct sk_buff
*tipc_cfg_reply_alloc(int payload_size
)
83 buf
= alloc_skb(rep_headroom
+ payload_size
, GFP_ATOMIC
);
85 skb_reserve(buf
, rep_headroom
);
89 int tipc_cfg_append_tlv(struct sk_buff
*buf
, int tlv_type
,
90 void *tlv_data
, int tlv_data_size
)
92 struct tlv_desc
*tlv
= (struct tlv_desc
*)skb_tail_pointer(buf
);
93 int new_tlv_space
= TLV_SPACE(tlv_data_size
);
95 if (skb_tailroom(buf
) < new_tlv_space
) {
96 dbg("tipc_cfg_append_tlv unable to append TLV\n");
99 skb_put(buf
, new_tlv_space
);
100 tlv
->tlv_type
= htons(tlv_type
);
101 tlv
->tlv_len
= htons(TLV_LENGTH(tlv_data_size
));
102 if (tlv_data_size
&& tlv_data
)
103 memcpy(TLV_DATA(tlv
), tlv_data
, tlv_data_size
);
107 struct sk_buff
*tipc_cfg_reply_unsigned_type(u16 tlv_type
, u32 value
)
112 buf
= tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value
)));
114 value_net
= htonl(value
);
115 tipc_cfg_append_tlv(buf
, tlv_type
, &value_net
,
121 struct sk_buff
*tipc_cfg_reply_string_type(u16 tlv_type
, char *string
)
124 int string_len
= strlen(string
) + 1;
126 buf
= tipc_cfg_reply_alloc(TLV_SPACE(string_len
));
128 tipc_cfg_append_tlv(buf
, tlv_type
, string
, string_len
);
137 /* Now obsolete code for handling commands not yet implemented the new way */
139 int tipc_cfg_cmd(const struct tipc_cmd_msg
* msg
,
143 struct tipc_portid
*orig
)
150 case TIPC_REMOVE_LINK
:
151 case TIPC_CMD_BLOCK_LINK
:
152 case TIPC_CMD_UNBLOCK_LINK
:
153 if (!cfg_check_connection(orig
))
154 rv
= link_control(msg
->argv
.link_name
, msg
->cmd
, 0);
160 tipc_isconnected(mng
.conn_port_ref
, &connected
);
161 if (connected
|| !orig
) {
165 rv
= tipc_connect2port(mng
.conn_port_ref
, orig
);
170 case TIPC_GET_PEER_ADDRESS
:
171 *ret_size
= link_peer_addr(msg
->argv
.link_name
, data
, sz
);
173 case TIPC_GET_ROUTES
:
183 static void cfg_cmd_event(struct tipc_cmd_msg
*msg
,
186 struct tipc_portid
const *orig
)
189 struct tipc_cmd_result_msg rmsg
;
190 struct iovec msg_sect
[2];
193 msg
->cmd
= ntohl(msg
->cmd
);
195 cfg_prepare_res_msg(msg
->cmd
, msg
->usr_handle
, rv
, &rmsg
, msg_sect
,
197 if (ntohl(msg
->magic
) != TIPC_MAGIC
)
201 case TIPC_CREATE_LINK
:
202 if (!cfg_check_connection(orig
))
203 rv
= disc_create_link(&msg
->argv
.create_link
);
205 case TIPC_LINK_SUBSCRIBE
:
207 struct subscr_data
*sub
;
209 if (mng
.link_subscriptions
> 64)
211 sub
= kmalloc(sizeof(*sub
),
214 warn("Memory squeeze; dropped remote link subscription\n");
217 INIT_LIST_HEAD(&sub
->subd_list
);
218 tipc_createport(mng
.user_ref
,
220 TIPC_HIGH_IMPORTANCE
,
223 (tipc_conn_shutdown_event
)cfg_linksubscr_cancel
,
226 (tipc_conn_msg_event
)cfg_linksubscr_cancel
,
229 if (!sub
->port_ref
) {
233 memcpy(sub
->usr_handle
,msg
->usr_handle
,
234 sizeof(sub
->usr_handle
));
235 sub
->domain
= msg
->argv
.domain
;
236 list_add_tail(&sub
->subd_list
, &mng
.link_subscribers
);
237 tipc_connect2port(sub
->port_ref
, orig
);
238 rmsg
.retval
= TIPC_OK
;
239 tipc_send(sub
->port_ref
, 2u, msg_sect
);
240 mng
.link_subscriptions
++;
244 rv
= tipc_cfg_cmd(msg
, data
, sz
, (u32
*)&msg_sect
[1].iov_len
, orig
);
247 rmsg
.result_len
= htonl(msg_sect
[1].iov_len
);
248 rmsg
.retval
= htonl(rv
);
249 tipc_cfg_respond(msg_sect
, 2u, orig
);
253 static struct sk_buff
*cfg_enable_bearer(void)
255 struct tipc_bearer_config
*args
;
257 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_BEARER_CONFIG
))
258 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
260 args
= (struct tipc_bearer_config
*)TLV_DATA(req_tlv_area
);
261 if (tipc_enable_bearer(args
->name
,
262 ntohl(args
->detect_scope
),
263 ntohl(args
->priority
)))
264 return tipc_cfg_reply_error_string("unable to enable bearer");
266 return tipc_cfg_reply_none();
269 static struct sk_buff
*cfg_disable_bearer(void)
271 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_BEARER_NAME
))
272 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
274 if (tipc_disable_bearer((char *)TLV_DATA(req_tlv_area
)))
275 return tipc_cfg_reply_error_string("unable to disable bearer");
277 return tipc_cfg_reply_none();
280 static struct sk_buff
*cfg_set_own_addr(void)
284 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_NET_ADDR
))
285 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
287 addr
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
288 if (addr
== tipc_own_addr
)
289 return tipc_cfg_reply_none();
290 if (!tipc_addr_node_valid(addr
))
291 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
293 if (tipc_mode
== TIPC_NET_MODE
)
294 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
295 " (cannot change node address once assigned)");
298 * Must release all spinlocks before calling start_net() because
299 * Linux version of TIPC calls eth_media_start() which calls
300 * register_netdevice_notifier() which may block!
302 * Temporarily releasing the lock should be harmless for non-Linux TIPC,
303 * but Linux version of eth_media_start() should really be reworked
304 * so that it can be called with spinlocks held.
307 spin_unlock_bh(&config_lock
);
308 tipc_core_start_net(addr
);
309 spin_lock_bh(&config_lock
);
310 return tipc_cfg_reply_none();
313 static struct sk_buff
*cfg_set_remote_mng(void)
317 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
318 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
320 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
321 tipc_remote_management
= (value
!= 0);
322 return tipc_cfg_reply_none();
325 static struct sk_buff
*cfg_set_max_publications(void)
329 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
330 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
332 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
333 if (value
!= delimit(value
, 1, 65535))
334 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
335 " (max publications must be 1-65535)");
336 tipc_max_publications
= value
;
337 return tipc_cfg_reply_none();
340 static struct sk_buff
*cfg_set_max_subscriptions(void)
344 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
345 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
347 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
348 if (value
!= delimit(value
, 1, 65535))
349 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
350 " (max subscriptions must be 1-65535");
351 tipc_max_subscriptions
= value
;
352 return tipc_cfg_reply_none();
355 static struct sk_buff
*cfg_set_max_ports(void)
359 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
360 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
361 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
362 if (value
== tipc_max_ports
)
363 return tipc_cfg_reply_none();
364 if (value
!= delimit(value
, 127, 65535))
365 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
366 " (max ports must be 127-65535)");
367 if (tipc_mode
!= TIPC_NOT_RUNNING
)
368 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
369 " (cannot change max ports while TIPC is active)");
370 tipc_max_ports
= value
;
371 return tipc_cfg_reply_none();
374 static struct sk_buff
*cfg_set_max_zones(void)
378 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
379 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
380 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
381 if (value
== tipc_max_zones
)
382 return tipc_cfg_reply_none();
383 if (value
!= delimit(value
, 1, 255))
384 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
385 " (max zones must be 1-255)");
386 if (tipc_mode
== TIPC_NET_MODE
)
387 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
388 " (cannot change max zones once TIPC has joined a network)");
389 tipc_max_zones
= value
;
390 return tipc_cfg_reply_none();
393 static struct sk_buff
*cfg_set_max_clusters(void)
397 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
398 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
399 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
400 if (value
!= delimit(value
, 1, 1))
401 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
402 " (max clusters fixed at 1)");
403 return tipc_cfg_reply_none();
406 static struct sk_buff
*cfg_set_max_nodes(void)
410 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
411 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
412 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
413 if (value
== tipc_max_nodes
)
414 return tipc_cfg_reply_none();
415 if (value
!= delimit(value
, 8, 2047))
416 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
417 " (max nodes must be 8-2047)");
418 if (tipc_mode
== TIPC_NET_MODE
)
419 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
420 " (cannot change max nodes once TIPC has joined a network)");
421 tipc_max_nodes
= value
;
422 return tipc_cfg_reply_none();
425 static struct sk_buff
*cfg_set_max_slaves(void)
429 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
430 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
431 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
433 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
434 " (max secondary nodes fixed at 0)");
435 return tipc_cfg_reply_none();
438 static struct sk_buff
*cfg_set_netid(void)
442 if (!TLV_CHECK(req_tlv_area
, req_tlv_space
, TIPC_TLV_UNSIGNED
))
443 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR
);
444 value
= ntohl(*(__be32
*)TLV_DATA(req_tlv_area
));
445 if (value
== tipc_net_id
)
446 return tipc_cfg_reply_none();
447 if (value
!= delimit(value
, 1, 9999))
448 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
449 " (network id must be 1-9999)");
450 if (tipc_mode
== TIPC_NET_MODE
)
451 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
452 " (cannot change network id once TIPC has joined a network)");
454 return tipc_cfg_reply_none();
457 struct sk_buff
*tipc_cfg_do_cmd(u32 orig_node
, u16 cmd
, const void *request_area
,
458 int request_space
, int reply_headroom
)
460 struct sk_buff
*rep_tlv_buf
;
462 spin_lock_bh(&config_lock
);
464 /* Save request and reply details in a well-known location */
466 req_tlv_area
= request_area
;
467 req_tlv_space
= request_space
;
468 rep_headroom
= reply_headroom
;
470 /* Check command authorization */
472 if (likely(orig_node
== tipc_own_addr
)) {
473 /* command is permitted */
474 } else if (cmd
>= 0x8000) {
475 rep_tlv_buf
= tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
476 " (cannot be done remotely)");
478 } else if (!tipc_remote_management
) {
479 rep_tlv_buf
= tipc_cfg_reply_error_string(TIPC_CFG_NO_REMOTE
);
482 else if (cmd
>= 0x4000) {
485 if ((tipc_nametbl_translate(TIPC_ZM_SRV
, 0, &domain
) == 0) ||
486 (domain
!= orig_node
)) {
487 rep_tlv_buf
= tipc_cfg_reply_error_string(TIPC_CFG_NOT_ZONE_MSTR
);
492 /* Call appropriate processing routine */
496 rep_tlv_buf
= tipc_cfg_reply_none();
498 case TIPC_CMD_GET_NODES
:
499 rep_tlv_buf
= tipc_node_get_nodes(req_tlv_area
, req_tlv_space
);
501 case TIPC_CMD_GET_LINKS
:
502 rep_tlv_buf
= tipc_node_get_links(req_tlv_area
, req_tlv_space
);
504 case TIPC_CMD_SHOW_LINK_STATS
:
505 rep_tlv_buf
= tipc_link_cmd_show_stats(req_tlv_area
, req_tlv_space
);
507 case TIPC_CMD_RESET_LINK_STATS
:
508 rep_tlv_buf
= tipc_link_cmd_reset_stats(req_tlv_area
, req_tlv_space
);
510 case TIPC_CMD_SHOW_NAME_TABLE
:
511 rep_tlv_buf
= tipc_nametbl_get(req_tlv_area
, req_tlv_space
);
513 case TIPC_CMD_GET_BEARER_NAMES
:
514 rep_tlv_buf
= tipc_bearer_get_names();
516 case TIPC_CMD_GET_MEDIA_NAMES
:
517 rep_tlv_buf
= tipc_media_get_names();
519 case TIPC_CMD_SHOW_PORTS
:
520 rep_tlv_buf
= tipc_port_get_ports();
523 case TIPC_CMD_SHOW_PORT_STATS
:
524 rep_tlv_buf
= port_show_stats(req_tlv_area
, req_tlv_space
);
526 case TIPC_CMD_RESET_PORT_STATS
:
527 rep_tlv_buf
= tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
);
530 case TIPC_CMD_SET_LOG_SIZE
:
531 rep_tlv_buf
= tipc_log_resize_cmd(req_tlv_area
, req_tlv_space
);
533 case TIPC_CMD_DUMP_LOG
:
534 rep_tlv_buf
= tipc_log_dump();
536 case TIPC_CMD_SET_LINK_TOL
:
537 case TIPC_CMD_SET_LINK_PRI
:
538 case TIPC_CMD_SET_LINK_WINDOW
:
539 rep_tlv_buf
= tipc_link_cmd_config(req_tlv_area
, req_tlv_space
, cmd
);
541 case TIPC_CMD_ENABLE_BEARER
:
542 rep_tlv_buf
= cfg_enable_bearer();
544 case TIPC_CMD_DISABLE_BEARER
:
545 rep_tlv_buf
= cfg_disable_bearer();
547 case TIPC_CMD_SET_NODE_ADDR
:
548 rep_tlv_buf
= cfg_set_own_addr();
550 case TIPC_CMD_SET_REMOTE_MNG
:
551 rep_tlv_buf
= cfg_set_remote_mng();
553 case TIPC_CMD_SET_MAX_PORTS
:
554 rep_tlv_buf
= cfg_set_max_ports();
556 case TIPC_CMD_SET_MAX_PUBL
:
557 rep_tlv_buf
= cfg_set_max_publications();
559 case TIPC_CMD_SET_MAX_SUBSCR
:
560 rep_tlv_buf
= cfg_set_max_subscriptions();
562 case TIPC_CMD_SET_MAX_ZONES
:
563 rep_tlv_buf
= cfg_set_max_zones();
565 case TIPC_CMD_SET_MAX_CLUSTERS
:
566 rep_tlv_buf
= cfg_set_max_clusters();
568 case TIPC_CMD_SET_MAX_NODES
:
569 rep_tlv_buf
= cfg_set_max_nodes();
571 case TIPC_CMD_SET_MAX_SLAVES
:
572 rep_tlv_buf
= cfg_set_max_slaves();
574 case TIPC_CMD_SET_NETID
:
575 rep_tlv_buf
= cfg_set_netid();
577 case TIPC_CMD_GET_REMOTE_MNG
:
578 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_remote_management
);
580 case TIPC_CMD_GET_MAX_PORTS
:
581 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_ports
);
583 case TIPC_CMD_GET_MAX_PUBL
:
584 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_publications
);
586 case TIPC_CMD_GET_MAX_SUBSCR
:
587 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_subscriptions
);
589 case TIPC_CMD_GET_MAX_ZONES
:
590 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_zones
);
592 case TIPC_CMD_GET_MAX_CLUSTERS
:
593 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_clusters
);
595 case TIPC_CMD_GET_MAX_NODES
:
596 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_nodes
);
598 case TIPC_CMD_GET_MAX_SLAVES
:
599 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_max_slaves
);
601 case TIPC_CMD_GET_NETID
:
602 rep_tlv_buf
= tipc_cfg_reply_unsigned(tipc_net_id
);
604 case TIPC_CMD_NOT_NET_ADMIN
:
606 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN
);
609 rep_tlv_buf
= tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
610 " (unknown command)");
614 /* Return reply buffer */
616 spin_unlock_bh(&config_lock
);
620 static void cfg_named_msg_event(void *userdata
,
622 struct sk_buff
**buf
,
626 struct tipc_portid
const *orig
,
627 struct tipc_name_seq
const *dest
)
629 struct tipc_cfg_msg_hdr
*req_hdr
;
630 struct tipc_cfg_msg_hdr
*rep_hdr
;
631 struct sk_buff
*rep_buf
;
633 /* Validate configuration message header (ignore invalid message) */
635 req_hdr
= (struct tipc_cfg_msg_hdr
*)msg
;
636 if ((size
< sizeof(*req_hdr
)) ||
637 (size
!= TCM_ALIGN(ntohl(req_hdr
->tcm_len
))) ||
638 (ntohs(req_hdr
->tcm_flags
) != TCM_F_REQUEST
)) {
639 warn("Invalid configuration message discarded\n");
643 /* Generate reply for request (if can't, return request) */
645 rep_buf
= tipc_cfg_do_cmd(orig
->node
,
646 ntohs(req_hdr
->tcm_type
),
647 msg
+ sizeof(*req_hdr
),
648 size
- sizeof(*req_hdr
),
649 BUF_HEADROOM
+ MAX_H_SIZE
+ sizeof(*rep_hdr
));
651 skb_push(rep_buf
, sizeof(*rep_hdr
));
652 rep_hdr
= (struct tipc_cfg_msg_hdr
*)rep_buf
->data
;
653 memcpy(rep_hdr
, req_hdr
, sizeof(*rep_hdr
));
654 rep_hdr
->tcm_len
= htonl(rep_buf
->len
);
655 rep_hdr
->tcm_flags
&= htons(~TCM_F_REQUEST
);
661 /* NEED TO ADD CODE TO HANDLE FAILED SEND (SUCH AS CONGESTION) */
662 tipc_send_buf2port(port_ref
, orig
, rep_buf
, rep_buf
->len
);
665 int tipc_cfg_init(void)
667 struct tipc_name_seq seq
;
670 memset(&mng
, 0, sizeof(mng
));
671 INIT_LIST_HEAD(&mng
.link_subscribers
);
673 res
= tipc_attach(&mng
.user_ref
, NULL
, NULL
);
677 res
= tipc_createport(mng
.user_ref
, NULL
, TIPC_CRITICAL_IMPORTANCE
,
679 NULL
, cfg_named_msg_event
, NULL
,
680 NULL
, &mng
.port_ref
);
684 seq
.type
= TIPC_CFG_SRV
;
685 seq
.lower
= seq
.upper
= tipc_own_addr
;
686 res
= tipc_nametbl_publish_rsv(mng
.port_ref
, TIPC_ZONE_SCOPE
, &seq
);
693 err("Unable to create configuration service\n");
694 tipc_detach(mng
.user_ref
);
699 void tipc_cfg_stop(void)
702 tipc_detach(mng
.user_ref
);