1 /* 2 * Copyright (C) 2010-2011 Robert Ancell. 3 * Author: Robert Ancell <robert.ancell@canonical.com> 4 * 5 * This program is free software: you can redistribute it and/or modify it under 6 * the terms of the GNU General Public License as published by the Free Software 7 * Foundation, either version 3 of the License, or (at your option) any later 8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the 9 * license. 10 */ 11 12 #ifndef XDMCP_PROTOCOL_H_ 13 #define XDMCP_PROTOCOL_H_ 14 15 #include <glib.h> 16 17 #define XDMCP_VERSION 1 18 19 typedef enum 20 { 21 XDMCP_BroadcastQuery = 1, 22 XDMCP_Query = 2, 23 XDMCP_IndirectQuery = 3, 24 XDMCP_ForwardQuery = 4, 25 XDMCP_Willing = 5, 26 XDMCP_Unwilling = 6, 27 XDMCP_Request = 7, 28 XDMCP_Accept = 8, 29 XDMCP_Decline = 9, 30 XDMCP_Manage = 10, 31 XDMCP_Refuse = 11, 32 XDMCP_Failed = 12, 33 XDMCP_KeepAlive = 13, 34 XDMCP_Alive = 14 35 } XDMCPOpcode; 36 37 typedef struct 38 { 39 guint16 length; 40 guchar *data; 41 } XDMCPData; 42 43 typedef struct 44 { 45 guint16 type; 46 XDMCPData address; 47 } XDMCPConnection; 48 49 typedef struct 50 { 51 XDMCPOpcode opcode; 52 53 union 54 { 55 struct 56 { 57 gchar **authentication_names; 58 } Query; 59 60 struct 61 { 62 XDMCPData client_address; 63 XDMCPData client_port; 64 gchar **authentication_names; 65 } ForwardQuery; 66 67 struct 68 { 69 gchar *authentication_name; 70 gchar *hostname; 71 gchar *status; 72 } Willing; 73 74 struct 75 { 76 gchar *hostname; 77 gchar *status; 78 } Unwilling; 79 80 struct 81 { 82 guint16 display_number; 83 guint8 n_connections; 84 XDMCPConnection *connections; 85 gchar *authentication_name; 86 XDMCPData authentication_data; 87 gchar **authorization_names; 88 gchar *manufacturer_display_id; 89 } Request; 90 91 struct 92 { 93 guint32 session_id; 94 gchar *authentication_name; 95 XDMCPData authentication_data; 96 gchar *authorization_name; 97 XDMCPData authorization_data; 98 } Accept; 99 100 struct 101 { 102 gchar *status; 103 gchar *authentication_name; 104 XDMCPData authentication_data; 105 } Decline; 106 107 struct 108 { 109 guint32 session_id; 110 guint16 display_number; 111 gchar *display_class; 112 } Manage; 113 114 struct 115 { 116 guint32 session_id; 117 } Refuse; 118 119 struct 120 { 121 guint32 session_id; 122 gchar *status; 123 } Failed; 124 125 struct 126 { 127 guint16 display_number; 128 guint32 session_id; 129 } KeepAlive; 130 131 struct 132 { 133 gboolean session_running; 134 guint32 session_id; 135 } Alive; 136 }; 137 } XDMCPPacket; 138 139 XDMCPPacket *xdmcp_packet_alloc (XDMCPOpcode opcode); 140 141 XDMCPPacket *xdmcp_packet_decode (const guchar *data, gsize length); 142 143 gssize xdmcp_packet_encode (XDMCPPacket *packet, guchar *data, gsize length); 144 145 gchar *xdmcp_packet_tostring (XDMCPPacket *packet); 146 147 void xdmcp_packet_free (XDMCPPacket *packet); 148 149 #endif /* XDMCP_PROTOCOL_H_ */ 150