/[pengfork]/pengfork/src/iptunnel/cli2aol.c
ViewVC logotype

Diff of /pengfork/src/iptunnel/cli2aol.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by chupa, Sun Sep 8 17:22:20 2002 UTC revision 1.5 by chupa, Mon Sep 9 22:59:42 2002 UTC
# Line 31  Line 31 
31  #include "iptunnel/cli2aol.h"  #include "iptunnel/cli2aol.h"
32    
33  void  void
34  get_ip_client (in, out, timeout)  get_ip_client (in)
35       buffer_t *in;       buffer_t *in;
      buffer_t *out;  
      int timeout;  
36  {  {
37    char *ip;    char *ip;
38    size_t ip_size;    size_t ip_size;
39      size_t data_size;
40    char *data;    char *data;
41    char *ip_data;    char *ip_data;
42    struct short_ip *small;    struct short_ip *small;
43    struct long_ip *big;    struct long_ip *big;
44      int i;
45    
46    debug (1, "IP TUNNEL - Sending IP...\n");    debug (1, "IP TUNNEL - Sending IP...\n");
47    while (iface->get (in, &ip, &ip_size))    while (iface->get (in, &ip, &ip_size))
48      {      {
49        if (ip_size > 0x7f)        if (ip_size > 0x7f)
50          {          {
         data = malloc( ip_size + sizeof(*big) );  
         big = (struct long_ip *) data;  
51          debug (1, "IP TUNNEL - Sending a big packet\n");          debug (1, "IP TUNNEL - Sending a big packet\n");
52            data_size = (ip_size>MAX_OUTPUT)?MAX_OUTPUT:ip_size;
53            data = malloc( data_size + sizeof(*big) );
54            big = (struct long_ip *) data;
55            big->ipnum = ipnum;            big->ipnum = ipnum;
56            big->len = htons(ip_size) | ~IP_LEN_MASK;            big->len = htons(ip_size | ~IP_LEN_MASK);
57          ip_data = data + sizeof(*big);          ip_data = data + sizeof(*big);
58            memcpy (ip_data, ip, ip_size);            memcpy (ip_data, ip, data_size);
59            fdo_send(acout, TOKEN ("yc"), data, ip_size + sizeof(*big));            fdo_send( TOKEN ("yc"), data, data_size + sizeof(*big));
60          free(data);          free(data);
61            /* Send extra packets if needed */
62            for(i=1;ip_size-i*MAX_OUTPUT<MAX_OUTPUT;i++)
63              {
64                debug (1, "IP TUNNEL - Sending an extra packet\n");
65                data_size = (ip_size-i*MAX_OUTPUT>MAX_OUTPUT)?
66                  MAX_OUTPUT:ip_size-i*MAX_OUTPUT;
67                data = malloc( data_size );
68                memcpy (data, ip+i*MAX_OUTPUT, data_size);
69                fdo_send( TOKEN ("yd"), data, data_size);
70                free(data);
71              }
72          }          }
73        else        else
74          {          {
75              debug (1, "IP TUNNEL - Sending a small packet\n");
76          data = malloc( ip_size + sizeof(*small) );          data = malloc( ip_size + sizeof(*small) );
77          small = (struct short_ip *) data;          small = (struct short_ip *) data;
           debug (1, "IP TUNNEL - Sending a small packet\n");  
78            small->ipnum = ipnum;            small->ipnum = ipnum;
79          small->long_bit = 0;          small->long_bit = 0;
80            small->len = ip_size;            small->len = ip_size;
81          ip_data = data + sizeof(*small);          ip_data = data + sizeof(*small);
82            memcpy (ip_data, ip, ip_size);            memcpy (ip_data, ip, ip_size);
83            fdo_send (acout, TOKEN ("yc"), data, ip_size + sizeof(*small));            fdo_send ( TOKEN ("yc"), data, ip_size + sizeof(*small));
84          free(data);          free(data);
85          }          }
86      }      }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26