connection.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* connection.h: Rx connection record
  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_CONNECTION_H
  12. #define _LINUX_RXRPC_CONNECTION_H
  13. #include <rxrpc/types.h>
  14. #include <rxrpc/krxtimod.h>
  15. struct sk_buff;
  16. /*****************************************************************************/
  17. /*
  18. * Rx connection
  19. * - connections are matched by (rmt_port,rmt_addr,service_id,conn_id,clientflag)
  20. * - connections only retain a refcount on the peer when they are active
  21. * - connections with refcount==0 are inactive and reside in the peer's graveyard
  22. */
  23. struct rxrpc_connection
  24. {
  25. atomic_t usage;
  26. struct rxrpc_transport *trans; /* transport endpoint */
  27. struct rxrpc_peer *peer; /* peer from/to which connected */
  28. struct rxrpc_service *service; /* responsible service (inbound conns) */
  29. struct rxrpc_timer timeout; /* decaching timer */
  30. struct list_head link; /* link in peer's list */
  31. struct list_head proc_link; /* link in proc list */
  32. struct list_head err_link; /* link in ICMP error processing list */
  33. struct list_head id_link; /* link in ID grant list */
  34. struct sockaddr_in addr; /* remote address */
  35. struct rxrpc_call *channels[4]; /* channels (active calls) */
  36. wait_queue_head_t chanwait; /* wait for channel to become available */
  37. spinlock_t lock; /* access lock */
  38. struct timeval atime; /* last access time */
  39. size_t mtu_size; /* MTU size for outbound messages */
  40. unsigned call_counter; /* call ID counter */
  41. rxrpc_serial_t serial_counter; /* packet serial number counter */
  42. /* the following should all be in net order */
  43. __be32 in_epoch; /* peer's epoch */
  44. __be32 out_epoch; /* my epoch */
  45. __be32 conn_id; /* connection ID, appropriately shifted */
  46. __be16 service_id; /* service ID */
  47. uint8_t security_ix; /* security ID */
  48. uint8_t in_clientflag; /* RXRPC_CLIENT_INITIATED if we are server */
  49. uint8_t out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
  50. };
  51. extern int rxrpc_create_connection(struct rxrpc_transport *trans,
  52. __be16 port,
  53. __be32 addr,
  54. uint16_t service_id,
  55. void *security,
  56. struct rxrpc_connection **_conn);
  57. extern int rxrpc_connection_lookup(struct rxrpc_peer *peer,
  58. struct rxrpc_message *msg,
  59. struct rxrpc_connection **_conn);
  60. static inline void rxrpc_get_connection(struct rxrpc_connection *conn)
  61. {
  62. BUG_ON(atomic_read(&conn->usage)<0);
  63. atomic_inc(&conn->usage);
  64. //printk("rxrpc_get_conn(%p{u=%d})\n",conn,atomic_read(&conn->usage));
  65. }
  66. extern void rxrpc_put_connection(struct rxrpc_connection *conn);
  67. extern int rxrpc_conn_receive_call_packet(struct rxrpc_connection *conn,
  68. struct rxrpc_call *call,
  69. struct rxrpc_message *msg);
  70. extern void rxrpc_conn_handle_error(struct rxrpc_connection *conn, int local, int errno);
  71. #endif /* _LINUX_RXRPC_CONNECTION_H */