2 oscar.c - FireTalk OSCAR protocol definitions
3 Copyright (C) 2000 Ian Gulliver
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of version 2 of the GNU General Public License as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 midendian can suck my left nut.
21 #include <sys/types.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
27 #include <arpa/inet.h>
34 #include "firetalk-int.h"
38 #define LOGIN_SERVER "login.oscar.aol.com"
39 #define LOGIN_PORT 443
42 unsigned char command_start
;
43 unsigned char channel_id
;
44 unsigned short sequence_number
;
45 unsigned short data_length
;
48 struct s_oscar_connection
{
50 unsigned short local_sequence
;
51 unsigned short remote_sequence
;
55 #define FLAP_CHANNEL_NEWCON 0x01
56 #define FLAP_CHANNEL_SNAC 0x02
57 #define FLAP_CHANNEL_ERROR 0x03
58 #define FLAP_CHANNEL_CLOSE 0x04
60 static int oscar_internal_disconnect(struct s_oscar_connection
* const c
, const int error
);
61 static int oscar_send_flap(struct s_oscar_connection
* const c
, const unsigned char channel_id
, const unsigned short length
, const char * const data
);
62 static int oscar_get_cookie(struct s_oscar_connection
* const c
);
64 static int oscar_internal_disconnect(struct s_oscar_connection
* const c
, const int error
) {
67 firetalkerror
= error
;
68 firetalk_callback_disconnect(c
,error
);
69 firetalkerror
= FE_SUCCESS
;
73 static int oscar_send_flap(struct s_oscar_connection
* const c
, const unsigned char channel_id
, const unsigned short length
, const char * const data
) {
74 static struct s_oscar_flap header
= { (unsigned char)0x2a, '\0', 0x0000, 0x0000 };
76 header
.channel_id
= channel_id
;
77 header
.sequence_number
= c
->local_sequence
++;
78 header
.data_length
= length
;
79 if (send(c
->s
,&header
,sizeof(struct s_oscar_flap
),0) != sizeof(struct s_oscar_flap
)) {
80 (void) oscar_internal_disconnect(c
,FE_PACKET
);
81 firetalkerror
= FE_PACKET
;
84 if (send(c
->s
,data
,length
,0) != length
) {
85 (void) oscar_internal_disconnect(c
,FE_PACKET
);
86 firetalkerror
= FE_PACKET
;
89 firetalkerror
= FE_SUCCESS
;
93 static int oscar_get_cookie(struct s_oscar_connection
* const c
) {