Add renegotiation patch from Yuri (ppp-aug10-patch)
Indentation and style cleanups Make md5.c use standard memcpy and memset
This commit is contained in:
parent
5779efc7ae
commit
d490579025
7 changed files with 2628 additions and 2666 deletions
3
Changes
3
Changes
|
|
@ -10,7 +10,8 @@
|
||||||
- Add startup script and monitor script from Yuri
|
- Add startup script and monitor script from Yuri
|
||||||
- Some logging correctness fixes from Iain Wade
|
- Some logging correctness fixes from Iain Wade
|
||||||
- Add support for LCP Ident and CallBack (rejection only) from Yuri
|
- Add support for LCP Ident and CallBack (rejection only) from Yuri
|
||||||
- Initiate LCP if not attempted by the client
|
- Initiate LCP if not attempted by the client, or in renegotiation - Yuri
|
||||||
|
- Indentation and style cleanups
|
||||||
|
|
||||||
* Tue Jul 13 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.1
|
* Tue Jul 13 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.1
|
||||||
- Update INSTALL, Docs/manual.html documentation.
|
- Update INSTALL, Docs/manual.html documentation.
|
||||||
|
|
|
||||||
11
bgp.c
11
bgp.c
|
|
@ -10,7 +10,7 @@
|
||||||
* nor RFC2385 (which requires a kernel patch on 2.4 kernels).
|
* nor RFC2385 (which requires a kernel patch on 2.4 kernels).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char const *cvs_id_bgp = "$Id: bgp.c,v 1.2 2004-06-28 02:43:13 fred_nerk Exp $";
|
char const *cvs_id_bgp = "$Id: bgp.c,v 1.3 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -63,8 +63,7 @@ int bgp_setup(int as)
|
||||||
peer->sock = -1;
|
peer->sock = -1;
|
||||||
peer->state = peer->next_state = Disabled;
|
peer->state = peer->next_state = Disabled;
|
||||||
|
|
||||||
if (!((peer->outbuf = malloc(sizeof(*peer->outbuf)))
|
if (!((peer->outbuf = malloc(sizeof(*peer->outbuf))) && (peer->inbuf = malloc(sizeof(*peer->inbuf)))))
|
||||||
&& (peer->inbuf = malloc(sizeof(*peer->inbuf)))))
|
|
||||||
{
|
{
|
||||||
log(0, 0, 0, 0, "Can't allocate buffers for bgp peer (%s)\n",
|
log(0, 0, 0, 0, "Can't allocate buffers for bgp peer (%s)\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
@ -108,8 +107,7 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int enable)
|
||||||
|
|
||||||
if (!(h = gethostbyname(name)) || h->h_addrtype != AF_INET)
|
if (!(h = gethostbyname(name)) || h->h_addrtype != AF_INET)
|
||||||
{
|
{
|
||||||
log(0, 0, 0, 0, "Can't get address for BGP peer %s (%s)\n",
|
log(0, 0, 0, 0, "Can't get address for BGP peer %s (%s)\n", name, h ? "no address" : hstrerror(h_errno));
|
||||||
name, h ? "no address" : hstrerror(h_errno));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1320,8 +1318,7 @@ int cmd_restart_bgp(struct cli_def *cli, char *command, char **argv, int argc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
addr = inet_toa(bgp_peers[i].addr);
|
addr = inet_toa(bgp_peers[i].addr);
|
||||||
if (argc && strcmp(addr, argv[0]) &&
|
if (argc && strcmp(addr, argv[0]) && strncmp(bgp_peers[i].name, argv[0], strlen(argv[0])))
|
||||||
strncmp(bgp_peers[i].name, argv[0], strlen(argv[0])))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bgp_peers[i].cli_flag = BGP_CLI_RESTART;
|
bgp_peers[i].cli_flag = BGP_CLI_RESTART;
|
||||||
|
|
|
||||||
2
cli.c
2
cli.c
|
|
@ -2,7 +2,7 @@
|
||||||
// vim: sw=4 ts=8
|
// vim: sw=4 ts=8
|
||||||
|
|
||||||
char const *cvs_name = "$Name: $";
|
char const *cvs_name = "$Name: $";
|
||||||
char const *cvs_id_cli = "$Id: cli.c,v 1.10 2004-07-11 07:57:33 bodea Exp $";
|
char const *cvs_id_cli = "$Id: cli.c,v 1.11 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
||||||
47
l2tpns.c
47
l2tpns.c
|
|
@ -4,7 +4,7 @@
|
||||||
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
||||||
// vim: sw=8 ts=8
|
// vim: sw=8 ts=8
|
||||||
|
|
||||||
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.21 2004-08-02 06:06:28 fred_nerk Exp $";
|
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.22 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -1780,6 +1780,7 @@ void processudp(u8 * buf, int len, struct sockaddr_in *addr)
|
||||||
// TBA
|
// TBA
|
||||||
break;
|
break;
|
||||||
case 12: // ICCN
|
case 12: // ICCN
|
||||||
|
if ( amagic == 0) amagic = time_now;
|
||||||
session[s].magic = amagic; // set magic number
|
session[s].magic = amagic; // set magic number
|
||||||
session[s].l2tp_flags = aflags; // set flags received
|
session[s].l2tp_flags = aflags; // set flags received
|
||||||
log(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags);
|
log(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags);
|
||||||
|
|
@ -2785,6 +2786,7 @@ void snoop_send_packet(char *packet, u16 size, ipt destination, u16 port)
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_acct_info()
|
void dump_acct_info()
|
||||||
|
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
char timestr[64];
|
char timestr[64];
|
||||||
|
|
@ -2808,7 +2810,7 @@ void dump_acct_info()
|
||||||
if (!(f = fopen(filename, "w")))
|
if (!(f = fopen(filename, "w")))
|
||||||
{
|
{
|
||||||
log(0, 0, 0, 0, "Can't write accounting info to %s: %s\n", filename, strerror(errno));
|
log(0, 0, 0, 0, "Can't write accounting info to %s: %s\n", filename, strerror(errno));
|
||||||
return;
|
return ;
|
||||||
}
|
}
|
||||||
log(3, 0, 0, 0, "Dumping accounting information to %s\n", filename);
|
log(3, 0, 0, 0, "Dumping accounting information to %s\n", filename);
|
||||||
fprintf(f, "# dslwatch.pl dump file V1.01\n"
|
fprintf(f, "# dslwatch.pl dump file V1.01\n"
|
||||||
|
|
@ -2833,7 +2835,8 @@ void dump_acct_info()
|
||||||
session[i].pout = session[i].cout = 0;
|
session[i].pout = session[i].cout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f) fclose(f);
|
if (f)
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main program
|
// Main program
|
||||||
|
|
@ -3088,26 +3091,26 @@ void read_state()
|
||||||
int i;
|
int i;
|
||||||
ippoolt itmp;
|
ippoolt itmp;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char magic[sizeof(DUMP_MAGIC)-1];
|
char magic[sizeof(DUMP_MAGIC) - 1];
|
||||||
u32 buf[2];
|
u32 buf[2];
|
||||||
|
|
||||||
if (!config->save_state)
|
if (!config->save_state)
|
||||||
{
|
{
|
||||||
unlink(STATEFILE);
|
unlink(STATEFILE);
|
||||||
return;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(STATEFILE, &sb) < 0)
|
if (stat(STATEFILE, &sb) < 0)
|
||||||
{
|
{
|
||||||
unlink(STATEFILE);
|
unlink(STATEFILE);
|
||||||
return;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb.st_mtime < (time(NULL) - 60))
|
if (sb.st_mtime < (time(NULL) - 60))
|
||||||
{
|
{
|
||||||
log(0, 0, 0, 0, "State file is too old to read, ignoring\n");
|
log(0, 0, 0, 0, "State file is too old to read, ignoring\n");
|
||||||
unlink(STATEFILE);
|
unlink(STATEFILE);
|
||||||
return;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fopen(STATEFILE, "r");
|
f = fopen(STATEFILE, "r");
|
||||||
|
|
@ -3215,34 +3218,44 @@ void dump_state()
|
||||||
if (!config->save_state)
|
if (!config->save_state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (!(f = fopen(STATEFILE, "w")))
|
if (!(f = fopen(STATEFILE, "w")))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
log(1, 0, 0, 0, "Dumping state information\n");
|
log(1, 0, 0, 0, "Dumping state information\n");
|
||||||
|
|
||||||
if (fwrite(DUMP_MAGIC, sizeof(DUMP_MAGIC)-1, 1, f) != 1) break;
|
if (fwrite(DUMP_MAGIC, sizeof(DUMP_MAGIC) - 1, 1, f) != 1)
|
||||||
|
break;
|
||||||
|
|
||||||
log(2, 0, 0, 0, "Dumping %u ip addresses\n", ip_pool_size);
|
log(2, 0, 0, 0, "Dumping %u ip addresses\n", ip_pool_size);
|
||||||
buf[0] = ip_pool_size;
|
buf[0] = ip_pool_size;
|
||||||
buf[1] = sizeof(ippoolt);
|
buf[1] = sizeof(ippoolt);
|
||||||
if (fwrite(buf, sizeof(buf), 1, f) != 1) break;
|
if (fwrite(buf, sizeof(buf), 1, f) != 1)
|
||||||
if (fwrite(ip_address_pool, sizeof(ippoolt), ip_pool_size, f) != ip_pool_size) break;
|
break;
|
||||||
|
if (fwrite(ip_address_pool, sizeof(ippoolt), ip_pool_size, f) != ip_pool_size)
|
||||||
|
break;
|
||||||
|
|
||||||
log(2, 0, 0, 0, "Dumping %u tunnels\n", MAXTUNNEL);
|
log(2, 0, 0, 0, "Dumping %u tunnels\n", MAXTUNNEL);
|
||||||
buf[0] = MAXTUNNEL;
|
buf[0] = MAXTUNNEL;
|
||||||
buf[1] = sizeof(tunnelt);
|
buf[1] = sizeof(tunnelt);
|
||||||
if (fwrite(buf, sizeof(buf), 1, f) != 1) break;
|
if (fwrite(buf, sizeof(buf), 1, f) != 1)
|
||||||
if (fwrite(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL) break;
|
break;
|
||||||
|
if (fwrite(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL)
|
||||||
|
break;
|
||||||
|
|
||||||
log(2, 0, 0, 0, "Dumping %u sessions\n", MAXSESSION);
|
log(2, 0, 0, 0, "Dumping %u sessions\n", MAXSESSION);
|
||||||
buf[0] = MAXSESSION;
|
buf[0] = MAXSESSION;
|
||||||
buf[1] = sizeof(sessiont);
|
buf[1] = sizeof(sessiont);
|
||||||
if (fwrite(buf, sizeof(buf), 1, f) != 1) break;
|
if (fwrite(buf, sizeof(buf), 1, f) != 1)
|
||||||
if (fwrite(session, sizeof(sessiont), MAXSESSION, f) != MAXSESSION) break;
|
break;
|
||||||
|
if (fwrite(session, sizeof(sessiont), MAXSESSION, f) != MAXSESSION)
|
||||||
|
break;
|
||||||
|
|
||||||
if (fclose(f) == 0) return; // OK
|
if (fclose(f) == 0)
|
||||||
} while (0);
|
return ; // OK
|
||||||
|
}
|
||||||
|
while (0);
|
||||||
|
|
||||||
log(0, 0, 0, 0, "Can't write state information: %s\n", strerror(errno));
|
log(0, 0, 0, 0, "Can't write state information: %s\n", strerror(errno));
|
||||||
unlink(STATEFILE);
|
unlink(STATEFILE);
|
||||||
|
|
|
||||||
2
ll.c
2
ll.c
|
|
@ -1,6 +1,6 @@
|
||||||
// L2TPNS Linked List Stuff
|
// L2TPNS Linked List Stuff
|
||||||
|
|
||||||
char const *cvs_id_ll = "$Id: ll.c,v 1.4 2004-06-28 02:43:13 fred_nerk Exp $";
|
char const *cvs_id_ll = "$Id: ll.c,v 1.5 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
|
||||||
91
md5.c
91
md5.c
|
|
@ -1,7 +1,7 @@
|
||||||
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char const *cvs_id_md5 = "$Id: md5.c,v 1.2 2004-06-28 02:43:13 fred_nerk Exp $";
|
char const *cvs_id_md5 = "$Id: md5.c,v 1.3 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||||
rights reserved.
|
rights reserved.
|
||||||
|
|
@ -25,6 +25,7 @@ These notices must be retained in any copies of any part of this
|
||||||
documentation and/or software.
|
documentation and/or software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
|
||||||
/* Constants for MD5Transform routine.
|
/* Constants for MD5Transform routine.
|
||||||
|
|
@ -50,8 +51,6 @@ documentation and/or software.
|
||||||
static void MD5Transform PROTO_LIST((UINT4[4], unsigned char[64]));
|
static void MD5Transform PROTO_LIST((UINT4[4], unsigned char[64]));
|
||||||
static void Encode PROTO_LIST((unsigned char *, UINT4 *, unsigned int));
|
static void Encode PROTO_LIST((unsigned char *, UINT4 *, unsigned int));
|
||||||
static void Decode PROTO_LIST((UINT4 *, unsigned char *, unsigned int));
|
static void Decode PROTO_LIST((UINT4 *, unsigned char *, unsigned int));
|
||||||
static void MD5_memcpy PROTO_LIST((POINTER, POINTER, unsigned int));
|
|
||||||
static void MD5_memset PROTO_LIST((POINTER, int, unsigned int));
|
|
||||||
|
|
||||||
static unsigned char PADDING[64] = {
|
static unsigned char PADDING[64] = {
|
||||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
@ -96,13 +95,10 @@ Rotation is separate from addition to prevent recomputation.
|
||||||
|
|
||||||
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||||
*/
|
*/
|
||||||
void
|
void MD5Init(MD5_CTX *context)
|
||||||
MD5Init(context)
|
|
||||||
MD5_CTX *context; /* context */
|
|
||||||
{
|
{
|
||||||
context->count[0] = context->count[1] = 0;
|
context->count[0] = context->count[1] = 0;
|
||||||
/* Load magic initialization constants.
|
// Load magic initialization constants.
|
||||||
*/
|
|
||||||
context->state[0] = 0x67452301;
|
context->state[0] = 0x67452301;
|
||||||
context->state[1] = 0xefcdab89;
|
context->state[1] = 0xefcdab89;
|
||||||
context->state[2] = 0x98badcfe;
|
context->state[2] = 0x98badcfe;
|
||||||
|
|
@ -113,11 +109,8 @@ MD5Init(context)
|
||||||
operation, processing another message block, and updating the
|
operation, processing another message block, and updating the
|
||||||
context.
|
context.
|
||||||
*/
|
*/
|
||||||
void
|
void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen)
|
||||||
MD5Update(context, input, inputLen)
|
|
||||||
MD5_CTX *context; /* context */
|
|
||||||
unsigned char *input; /* input block */
|
|
||||||
unsigned int inputLen; /* length of input block */
|
|
||||||
{
|
{
|
||||||
unsigned int i,
|
unsigned int i,
|
||||||
index,
|
index,
|
||||||
|
|
@ -137,7 +130,7 @@ MD5Update(context, input, inputLen)
|
||||||
*/
|
*/
|
||||||
if (inputLen >= partLen)
|
if (inputLen >= partLen)
|
||||||
{
|
{
|
||||||
MD5_memcpy((POINTER) & context->buffer[index], (POINTER) input, partLen);
|
memcpy(&context->buffer[index], input, partLen);
|
||||||
MD5Transform(context->state, context->buffer);
|
MD5Transform(context->state, context->buffer);
|
||||||
|
|
||||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||||
|
|
@ -149,20 +142,16 @@ MD5Update(context, input, inputLen)
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
/* Buffer remaining input */
|
/* Buffer remaining input */
|
||||||
MD5_memcpy((POINTER) & context->buffer[index], (POINTER) & input[i], inputLen - i);
|
memcpy(&context->buffer[index], &input[i], inputLen - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||||
the message digest and zeroizing the context.
|
the message digest and zeroizing the context.
|
||||||
*/
|
*/
|
||||||
void
|
void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
||||||
MD5Final(digest, context)
|
|
||||||
unsigned char digest[16]; /* message digest */
|
|
||||||
MD5_CTX *context; /* context */
|
|
||||||
{
|
{
|
||||||
unsigned char bits[8];
|
unsigned char bits[8];
|
||||||
unsigned int index,
|
unsigned int index, padLen;
|
||||||
padLen;
|
|
||||||
|
|
||||||
/* Save number of bits */
|
/* Save number of bits */
|
||||||
Encode(bits, context->count, 8);
|
Encode(bits, context->count, 8);
|
||||||
|
|
@ -181,15 +170,12 @@ MD5Final(digest, context)
|
||||||
|
|
||||||
/* Zeroize sensitive information.
|
/* Zeroize sensitive information.
|
||||||
*/
|
*/
|
||||||
MD5_memset((POINTER) context, 0, sizeof(*context));
|
memset(context, 0, sizeof(*context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MD5 basic transformation. Transforms state based on block.
|
/* MD5 basic transformation. Transforms state based on block.
|
||||||
*/
|
*/
|
||||||
static void
|
static void MD5Transform(UINT4 state[4], unsigned char block[64])
|
||||||
MD5Transform(state, block)
|
|
||||||
UINT4 state[4];
|
|
||||||
unsigned char block[64];
|
|
||||||
{
|
{
|
||||||
UINT4 a = state[0],
|
UINT4 a = state[0],
|
||||||
b = state[1],
|
b = state[1],
|
||||||
|
|
@ -277,23 +263,16 @@ MD5Transform(state, block)
|
||||||
state[2] += c;
|
state[2] += c;
|
||||||
state[3] += d;
|
state[3] += d;
|
||||||
|
|
||||||
/* Zeroize sensitive information.
|
// Zeroize sensitive information.
|
||||||
|
memset(x, 0, sizeof(x));
|
||||||
*/
|
|
||||||
MD5_memset((POINTER) x, 0, sizeof(x));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
|
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
|
||||||
a multiple of 4.
|
a multiple of 4.
|
||||||
*/
|
*/
|
||||||
static void
|
static void Encode(unsigned char *output, UINT4 *input, unsigned int len)
|
||||||
Encode(output, input, len)
|
|
||||||
unsigned char *output;
|
|
||||||
UINT4 *input;
|
|
||||||
unsigned int len;
|
|
||||||
{
|
{
|
||||||
unsigned int i,
|
unsigned int i, j;
|
||||||
j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||||
{
|
{
|
||||||
|
|
@ -307,45 +286,11 @@ Encode(output, input, len)
|
||||||
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
|
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
|
||||||
a multiple of 4.
|
a multiple of 4.
|
||||||
*/
|
*/
|
||||||
static void
|
static void Decode(UINT4 *output, unsigned char *input, unsigned int len)
|
||||||
Decode(output, input, len)
|
|
||||||
UINT4 *output;
|
|
||||||
unsigned char *input;
|
|
||||||
unsigned int len;
|
|
||||||
{
|
{
|
||||||
unsigned int i,
|
unsigned int i, j;
|
||||||
j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||||
output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
|
output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: Replace "for loop" with standard memcpy if possible.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
MD5_memcpy(output, input, len)
|
|
||||||
POINTER output;
|
|
||||||
POINTER input;
|
|
||||||
unsigned int len;
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
|
|
||||||
output[i] = input[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note: Replace "for loop" with standard memset if possible.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
MD5_memset(output, value, len)
|
|
||||||
POINTER output;
|
|
||||||
int value;
|
|
||||||
unsigned int len;
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
((char *) output)[i] = (char) value;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
32
ppp.c
32
ppp.c
|
|
@ -1,6 +1,6 @@
|
||||||
// L2TPNS PPP Stuff
|
// L2TPNS PPP Stuff
|
||||||
|
|
||||||
char const *cvs_id_ppp = "$Id: ppp.c,v 1.11 2004-08-02 06:06:28 fred_nerk Exp $";
|
char const *cvs_id_ppp = "$Id: ppp.c,v 1.12 2004-08-13 00:02:50 fred_nerk Exp $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -95,7 +95,8 @@ void processpap(tunnelidt t, sessionidt s, u8 * p, u16 l)
|
||||||
tunnelsend(b, 5 + (p - b), t); // send it
|
tunnelsend(b, 5 + (p - b), t); // send it
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // set up RADIUS request
|
{
|
||||||
|
// set up RADIUS request
|
||||||
u16 r = session[s].radius;
|
u16 r = session[s].radius;
|
||||||
|
|
||||||
// Run PRE_AUTH plugins
|
// Run PRE_AUTH plugins
|
||||||
|
|
@ -410,15 +411,16 @@ void processlcp(tunnelidt t, sessionidt s, u8 * p, u16 l)
|
||||||
{
|
{
|
||||||
// Send back a ConfigAck
|
// Send back a ConfigAck
|
||||||
log(3, session[s].ip, s, t, "ConfigReq accepted, sending as Ack\n");
|
log(3, session[s].ip, s, t, "ConfigReq accepted, sending as Ack\n");
|
||||||
|
// for win2k L2TP clientis and LCP renegotiation of alive session
|
||||||
|
if (magicno || l == 4) initlcp(t, s);
|
||||||
q = makeppp(b, sizeof(b), p, l, t, s, PPPLCP);
|
q = makeppp(b, sizeof(b), p, l, t, s, PPPLCP);
|
||||||
if (!q) {
|
if (!q)
|
||||||
|
{
|
||||||
log(3, session[s].ip, s, t, " failed to create packet.\n");
|
log(3, session[s].ip, s, t, " failed to create packet.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*q = ConfigAck;
|
*q = ConfigAck;
|
||||||
tunnelsend(b, l + (q - b), t);
|
tunnelsend(b, l + (q - b), t);
|
||||||
// For win2k L2TP clients, LCP should be initiated by the LNS
|
|
||||||
if (magicno) initlcp(t, s);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -537,7 +539,7 @@ void processipcp(tunnelidt t, sessionidt s, u8 * p, u16 l)
|
||||||
if (!session[s].ip)
|
if (!session[s].ip)
|
||||||
{
|
{
|
||||||
log(3, 0, s, t, "Waiting on radius reply\n");
|
log(3, 0, s, t, "Waiting on radius reply\n");
|
||||||
return ; // have to wait on RADIUS reply
|
return; // have to wait on RADIUS reply
|
||||||
}
|
}
|
||||||
// form a config reply quoting the IP in the session
|
// form a config reply quoting the IP in the session
|
||||||
{
|
{
|
||||||
|
|
@ -775,7 +777,8 @@ void sendchap(tunnelidt t, sessionidt s)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
log(1, 0, s, t, "Send CHAP challenge\n");
|
log(1, 0, s, t, "Send CHAP challenge\n");
|
||||||
{ // new challenge
|
{
|
||||||
|
// new challenge
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < 15; n++)
|
for (n = 0; n < 15; n++)
|
||||||
radius[r].auth[n] = rand();
|
radius[r].auth[n] = rand();
|
||||||
|
|
@ -797,7 +800,7 @@ void sendchap(tunnelidt t, sessionidt s)
|
||||||
log(1, 0, s, t, "failed to send CHAP challenge.\n");
|
log(1, 0, s, t, "failed to send CHAP challenge.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*q = 1; // challenhe
|
*q = 1; // challenge
|
||||||
q[1] = radius[r].id; // ID
|
q[1] = radius[r].id; // ID
|
||||||
q[4] = 16; // length
|
q[4] = 16; // length
|
||||||
memcpy(q + 5, radius[r].auth, 16); // challenge
|
memcpy(q + 5, radius[r].auth, 16); // challenge
|
||||||
|
|
@ -874,11 +877,14 @@ void initlcp(tunnelidt t, sessionidt s)
|
||||||
log(4, 0, s, t, "Sending LCP ConfigReq for PAP\n");
|
log(4, 0, s, t, "Sending LCP ConfigReq for PAP\n");
|
||||||
*q = ConfigReq;
|
*q = ConfigReq;
|
||||||
*(u8 *)(q + 1) = (time_now % 255) + 1; // ID
|
*(u8 *)(q + 1) = (time_now % 255) + 1; // ID
|
||||||
*(u16 *)(q + 2) = htons(8); // Length
|
*(u16 *)(q + 2) = htons(14); // Length
|
||||||
*(u8 *)(q + 4) = 3;
|
*(u8 *)(q + 4) = 5;
|
||||||
*(u8 *)(q + 5) = 4;
|
*(u8 *)(q + 5) = 6;
|
||||||
*(u16 *)(q + 6) = htons(0xC023); // PAP
|
*(u32 *)(q + 6) = htonl(session[s].magic);
|
||||||
tunnelsend(b, 12 + 8, t);
|
*(u8 *)(q + 10) = 3;
|
||||||
|
*(u8 *)(q + 11) = 4;
|
||||||
|
*(u16 *)(q + 12) = htons(0xC023); // PAP
|
||||||
|
tunnelsend(b, 12 + 14, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send CCP reply
|
// Send CCP reply
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue