server.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * net/tipc/server.h: Include file for TIPC server code
  3. *
  4. * Copyright (c) 2012-2013, Wind River Systems
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright holders nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * Alternatively, this software may be distributed under the terms of the
  20. * GNU General Public License ("GPL") version 2 as published by the Free
  21. * Software Foundation.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _TIPC_SERVER_H
  36. #define _TIPC_SERVER_H
  37. #include "core.h"
  38. #define TIPC_SERVER_NAME_LEN 32
  39. /**
  40. * struct tipc_server - TIPC server structure
  41. * @conn_idr: identifier set of connection
  42. * @idr_lock: protect the connection identifier set
  43. * @idr_in_use: amount of allocated identifier entry
  44. * @rcvbuf_cache: memory cache of server receive buffer
  45. * @rcv_wq: receive workqueue
  46. * @send_wq: send workqueue
  47. * @max_rcvbuf_size: maximum permitted receive message length
  48. * @tipc_conn_new: callback will be called when new connection is incoming
  49. * @tipc_conn_shutdown: callback will be called when connection is shut down
  50. * @tipc_conn_recvmsg: callback will be called when message arrives
  51. * @saddr: TIPC server address
  52. * @name: server name
  53. * @imp: message importance
  54. * @type: socket type
  55. * @enabled: identify whether server is launched or not
  56. */
  57. struct tipc_server {
  58. struct idr conn_idr;
  59. spinlock_t idr_lock;
  60. int idr_in_use;
  61. struct kmem_cache *rcvbuf_cache;
  62. struct workqueue_struct *rcv_wq;
  63. struct workqueue_struct *send_wq;
  64. int max_rcvbuf_size;
  65. void *(*tipc_conn_new) (int conid);
  66. void (*tipc_conn_shutdown) (int conid, void *usr_data);
  67. void (*tipc_conn_recvmsg) (int conid, struct sockaddr_tipc *addr,
  68. void *usr_data, void *buf, size_t len);
  69. struct sockaddr_tipc *saddr;
  70. const char name[TIPC_SERVER_NAME_LEN];
  71. int imp;
  72. int type;
  73. int enabled;
  74. };
  75. int tipc_conn_sendmsg(struct tipc_server *s, int conid,
  76. struct sockaddr_tipc *addr, void *data, size_t len);
  77. /**
  78. * tipc_conn_terminate - terminate connection with server
  79. *
  80. * Note: Must call it in process context since it might sleep
  81. */
  82. void tipc_conn_terminate(struct tipc_server *s, int conid);
  83. int tipc_server_start(struct tipc_server *s);
  84. void tipc_server_stop(struct tipc_server *s);
  85. #endif