5 ###################################################
8 # used in authentication, login
9 Type_Screen_Name = 0x0001;
10 Type_Roasted_Password = 0x0002;
11 Type_Client_ID_String = 0x0003;
12 Type_Error_URL = 0x0004;
13 Type_Connection_Address = 0x0005;
14 Type_Connection_Cookie = 0x0006;
15 Type_Error_Code = 0x0008;
16 Type_Message_of_the_Day = 0x000B;
17 Type_Client_Country = 0x000E;
18 Type_Client_Language = 0x000F;
19 Type_Client_Distribution = 0x0014;
20 Type_Client_ID = 0x0016;
21 Type_Client_Major_Version = 0x0017;
22 Type_Client_Minor_Version = 0x0018;
23 Type_Client_Lesser_Version = 0x0019;
24 Type_Client_Build_Version = 0x001A;
26 # used in client info, receiving messages
27 Type_User_Class = 0x0001;
28 User_Class_Unconfirmed = 0x0001;
29 User_Class_Administrator = 0x0002;
30 User_Class_AOL_Staff = 0x0004;
31 User_Class_Commercial = 0x0008;
32 User_Class_Free = 0x0010;
33 User_Class_Away = 0x0020;
34 User_Class_ICQ = 0x0040;
35 User_Class_Wireless = 0x0080;
38 Type_Signon_Time = 0x0003;
39 Type_Automated_Response = 0x0004;
40 Type_Member_Since = 0x0005;
41 Type_User_Status = 0x0006;
42 #top bytes - random flags
43 User_Status_Webaware = 0x00010000;
44 User_Status_Show_IP = 0x00020000;
45 User_Status_Birthday = 0x00080000;
46 User_Status_Webfront = 0x00200000;
47 User_Status_Direct_Connection_Disabled = 0x01000000; #no DC
48 User_Status_Direct_Connection_Authorized = 0x10000000; #DC after auth
49 User_Status_Direct_Connection_Contacts = 0x20000000; #DC with buddies only
50 #bottom bytes - status
51 User_Status_Online = 0x00000000;
52 User_Status_Away = 0x00000001;
53 User_Status_Do_Not_Disturb = 0x00000002;
54 User_Status_Not_Available = 0x00000004;
55 User_Status_Occupied = 0x00000010;
56 User_Status_Free_For_Chat = 0x00000020;
57 User_Status_Invisible = 0x00000100;
59 Type_External_IP = 0x000A;
61 Type_Direct_Connection_Info = 0x000C;
62 Direct_Connection_Disabled = 0x0000;
63 Direct_Connection_HTTPS_Proxy = 0x0001;
64 Direct_Connection_SOCKS_Proxy = 0x0002;
65 Direct_Connection_Normal = 0x0004;
66 Direct_Connection_Web = 0x0006; #= no direct connection
68 Type_Client_Idle_Time = 0x000F;
70 # used in service parameters
71 Type_Profile_Max_Length = 0x0001;
72 Type_Profile_Max_Capabilities = 0x0002;
73 Type_Client_Cabilities_List = 0x0005;
75 # used in buddy list parameters
76 Type_Buddylist_Max_Size = 0x0001;
77 Type_Buddylist_Max_Watchers = 0x0002;
79 # used in privacy management parameters
80 Type_Visible_List_Max_Size = 0x0001;
81 Type_Invisible_List_Max_Size = 0x0002;
83 # used for sending, receiving messages
84 Type_Message_Data = 0x0002;
85 Type_Server_Ack_Request = 0x0003;
86 Type_Store_If_Offline = 0x0006;
88 ###################################################
92 0x01 => "Invalid SNAC header.",
93 0x02 => "Server rate limit exceeded.",
94 0x03 => "Client rate limit exceeded.",
95 0x04 => "Recipient is not logged in.",
96 0x05 => "Requested service unavailable.",
97 0x06 => "Requested service not defined.",
98 0x07 => "You sent obsolete SNAC.",
99 0x08 => "Not supported by server.",
100 0x09 => "Not supported by client.",
101 0x0A => "Refused by client.",
102 0x0B => "Reply too big.",
103 0x0C => "Responses lost.",
104 0x0D => "Request denied.",
105 0x0E => "Incorrect SNAC format.",
106 0x0F => "Insufficient rights.",
107 0x10 => "In local permit/deny (recipient blocked).",
108 0x11 => "Sender too evil.",
109 0x12 => "Receiver too evil.",
110 0x13 => "User temporarily unavailable.",
112 0x15 => "List overflow.",
113 0x16 => "Request ambiguous.",
114 0x17 => "Server queue full.",
115 0x18 => "Not while on AOL."
118 ###################################################
121 def construct_tlv_raw(type, data)
128 Client.logger.info("TLV::construct_tlv_raw"){ "Built TLV of length #{tlv.length}, as hex: " + tlv.unpack("H*").join() + "." };
133 def construct_tlv_empty(type)
134 return construct_tlv_raw(type, "");
137 def construct_tlv_short(type, data)
138 return construct_tlv_raw(type, [data].pack("n"));
141 def construct_tlv_int(type, data)
142 return construct_tlv_raw(type, [data].pack("N"));
145 def construct_tlv_string(type, data)
146 return construct_tlv_raw(type, data);
149 ###################################################
152 def parse_tlv_raw(data)
154 Client.logger.error("TLV::parse_tlv_raw"){ "Data isn't a proper TLV." };
155 raise OscarError, "Communication error."
157 type, length = data.unpack("nn");
160 if(!data || (data.length < length))
161 Client.logger.error("TLV::parse_tlv_raw"){ "Expected length #{length} is greater than data length #{data.length}." };
162 raise OscarError, "Communication error."
164 curdata = data.slice!(0..(length-1));
166 Client.logger.info("TLV::parse_tlv_raw"){ "Parsing TLV: #{sprintf('0x%04x', type)}, #{sprintf('0x%04x', length)}." };
168 Client.logger.info("TLV::parse_tlv_raw"){ "or as hex: " + curdata.unpack("H*").join() + "."};
171 return type, curdata, data;
174 def parse_tlv_short(data)
175 type, val, consumed = parse_tlv_raw(data);
176 return type, val.unpack("n").first(), consumed;
179 def parse_tlv_string(data)
180 type, str, consumed = parse_tlv_raw(data);
181 return type, str, consumed;