transport.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* transport.h: Rx transport management
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #ifndef _LINUX_RXRPC_TRANSPORT_H
  12. #define _LINUX_RXRPC_TRANSPORT_H
  13. #include <rxrpc/types.h>
  14. #include <rxrpc/krxiod.h>
  15. #include <rxrpc/rxrpc.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/rwsem.h>
  18. typedef int (*rxrpc_newcall_fnx_t)(struct rxrpc_call *call);
  19. extern wait_queue_head_t rxrpc_krxiod_wq;
  20. /*****************************************************************************/
  21. /*
  22. * Rx operation specification
  23. * - tables of these must be sorted by op ID so that they can be binary-chop searched
  24. */
  25. struct rxrpc_operation
  26. {
  27. unsigned id; /* operation ID */
  28. size_t asize; /* minimum size of argument block */
  29. const char *name; /* name of operation */
  30. void *user; /* initial user data */
  31. };
  32. /*****************************************************************************/
  33. /*
  34. * Rx transport service record
  35. */
  36. struct rxrpc_service
  37. {
  38. struct list_head link; /* link in services list on transport */
  39. struct module *owner; /* owner module */
  40. rxrpc_newcall_fnx_t new_call; /* new call handler function */
  41. const char *name; /* name of service */
  42. unsigned short service_id; /* Rx service ID */
  43. rxrpc_call_attn_func_t attn_func; /* call requires attention callback */
  44. rxrpc_call_error_func_t error_func; /* call error callback */
  45. rxrpc_call_aemap_func_t aemap_func; /* abort -> errno mapping callback */
  46. const struct rxrpc_operation *ops_begin; /* beginning of operations table */
  47. const struct rxrpc_operation *ops_end; /* end of operations table */
  48. };
  49. /*****************************************************************************/
  50. /*
  51. * Rx transport endpoint record
  52. */
  53. struct rxrpc_transport
  54. {
  55. atomic_t usage;
  56. struct socket *socket; /* my UDP socket */
  57. struct list_head services; /* services listening on this socket */
  58. struct list_head link; /* link in transport list */
  59. struct list_head proc_link; /* link in transport proc list */
  60. struct list_head krxiodq_link; /* krxiod attention queue link */
  61. spinlock_t lock; /* access lock */
  62. struct list_head peer_active; /* active peers connected to over this socket */
  63. struct list_head peer_graveyard; /* inactive peer list */
  64. spinlock_t peer_gylock; /* peer graveyard lock */
  65. wait_queue_head_t peer_gy_waitq; /* wait queue hit when peer graveyard is empty */
  66. rwlock_t peer_lock; /* peer list access lock */
  67. atomic_t peer_count; /* number of peers */
  68. struct rxrpc_peer_ops *peer_ops; /* default peer operations */
  69. unsigned short port; /* port upon which listening */
  70. volatile char error_rcvd; /* T if received ICMP error outstanding */
  71. };
  72. extern int rxrpc_create_transport(unsigned short port,
  73. struct rxrpc_transport **_trans);
  74. static inline void rxrpc_get_transport(struct rxrpc_transport *trans)
  75. {
  76. BUG_ON(atomic_read(&trans->usage) <= 0);
  77. atomic_inc(&trans->usage);
  78. //printk("rxrpc_get_transport(%p{u=%d})\n",
  79. // trans, atomic_read(&trans->usage));
  80. }
  81. extern void rxrpc_put_transport(struct rxrpc_transport *trans);
  82. extern int rxrpc_add_service(struct rxrpc_transport *trans,
  83. struct rxrpc_service *srv);
  84. extern void rxrpc_del_service(struct rxrpc_transport *trans,
  85. struct rxrpc_service *srv);
  86. extern void rxrpc_trans_receive_packet(struct rxrpc_transport *trans);
  87. extern int rxrpc_trans_immediate_abort(struct rxrpc_transport *trans,
  88. struct rxrpc_message *msg,
  89. int error);
  90. #endif /* _LINUX_RXRPC_TRANSPORT_H */