talkd.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /*
  17. * Copyright (c) 1983, 1993
  18. * The Regents of the University of California. All rights reserved.
  19. *
  20. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions
  22. * are met:
  23. * 1. Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. * 2. Redistributions in binary form must reproduce the above copyright
  26. * notice, this list of conditions and the following disclaimer in the
  27. * documentation and/or other materials provided with the distribution.
  28. * 4. Neither the name of the University nor the names of its contributors
  29. * may be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  33. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  36. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  40. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  41. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  42. * SUCH DAMAGE.
  43. *
  44. * @(#)talkd.h 8.1 (Berkeley) 6/2/93
  45. */
  46. #ifndef _PROTOCOLS_TALKD_H
  47. #define _PROTOCOLS_TALKD_H 1
  48. /*
  49. * This describes the protocol used by the talk server and clients.
  50. *
  51. * The talk server acts a repository of invitations, responding to
  52. * requests by clients wishing to rendezvous for the purpose of
  53. * holding a conversation. In normal operation, a client, the caller,
  54. * initiates a rendezvous by sending a CTL_MSG to the server of
  55. * type LOOK_UP. This causes the server to search its invitation
  56. * tables to check if an invitation currently exists for the caller
  57. * (to speak to the callee specified in the message). If the lookup
  58. * fails, the caller then sends an ANNOUNCE message causing the server
  59. * to broadcast an announcement on the callee's login ports requesting
  60. * contact. When the callee responds, the local server uses the
  61. * recorded invitation to respond with the appropriate rendezvous
  62. * address and the caller and callee client programs establish a
  63. * stream connection through which the conversation takes place.
  64. */
  65. #include <sys/types.h>
  66. #include <sys/socket.h>
  67. #include <stdint.h>
  68. #include <bits/types/struct_osockaddr.h>
  69. /*
  70. * Client->server request message format.
  71. */
  72. typedef struct {
  73. unsigned char vers; /* protocol version */
  74. unsigned char type; /* request type, see below */
  75. unsigned char answer; /* not used */
  76. unsigned char pad;
  77. uint32_t id_num; /* message id */
  78. struct osockaddr addr; /* old (4.3) style */
  79. struct osockaddr ctl_addr; /* old (4.3) style */
  80. int32_t pid; /* caller's process id */
  81. #define NAME_SIZE 12
  82. char l_name[NAME_SIZE];/* caller's name */
  83. char r_name[NAME_SIZE];/* callee's name */
  84. #define TTY_SIZE 16
  85. char r_tty[TTY_SIZE];/* callee's tty name */
  86. } CTL_MSG;
  87. /*
  88. * Server->client response message format.
  89. */
  90. typedef struct {
  91. unsigned char vers; /* protocol version */
  92. unsigned char type; /* type of request message, see below */
  93. unsigned char answer; /* response to request message, see below */
  94. unsigned char pad;
  95. uint32_t id_num; /* message id */
  96. struct osockaddr addr; /* address for establishing conversation */
  97. } CTL_RESPONSE;
  98. #define TALK_VERSION 1 /* protocol version */
  99. /* message type values */
  100. #define LEAVE_INVITE 0 /* leave invitation with server */
  101. #define LOOK_UP 1 /* check for invitation by callee */
  102. #define DELETE 2 /* delete invitation by caller */
  103. #define ANNOUNCE 3 /* announce invitation by caller */
  104. /* answer values */
  105. #define SUCCESS 0 /* operation completed properly */
  106. #define NOT_HERE 1 /* callee not logged in */
  107. #define FAILED 2 /* operation failed for unexplained reason */
  108. #define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
  109. #define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
  110. #define UNKNOWN_REQUEST 5 /* request has invalid type value */
  111. #define BADVERSION 6 /* request has invalid protocol version */
  112. #define BADADDR 7 /* request has invalid addr value */
  113. #define BADCTLADDR 8 /* request has invalid ctl_addr value */
  114. /*
  115. * Operational parameters.
  116. */
  117. #define MAX_LIFE 60 /* max time daemon saves invitations */
  118. /* RING_WAIT should be 10's of seconds less than MAX_LIFE */
  119. #define RING_WAIT 30 /* time to wait before resending invitation */
  120. #endif /* protocols/talkd.h */