Updated Changelog
[centerim/davrieb.git] / firetalk / oscar.c
blobf06b0e8a894124fb7af165b3ded4efecaec924fc
1 /*
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>
22 #include <sys/time.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <netdb.h>
26 #include <unistd.h>
27 #include <arpa/inet.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <ctype.h>
32 #include <stdarg.h>
34 #include "firetalk-int.h"
35 #include "firetalk.h"
36 #include "oscar.h"
38 #define LOGIN_SERVER "login.oscar.aol.com"
39 #define LOGIN_PORT 443
41 struct s_oscar_flap {
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 {
49 int s;
50 unsigned short local_sequence;
51 unsigned short remote_sequence;
52 char *cookie;
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) {
65 close(c->s);
66 free(c);
67 firetalkerror = error;
68 firetalk_callback_disconnect(c,error);
69 firetalkerror = FE_SUCCESS;
70 return 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;
82 return FE_PACKET;
84 if (send(c->s,data,length,0) != length) {
85 (void) oscar_internal_disconnect(c,FE_PACKET);
86 firetalkerror = FE_PACKET;
87 return FE_PACKET;
89 firetalkerror = FE_SUCCESS;
90 return FE_SUCCESS;
93 static int oscar_get_cookie(struct s_oscar_connection * const c) {
94 return 0;