- Fixing little things

- Two tinc daemons can connect to eachother now (but they disconnect right
  after the ACKs).
This commit is contained in:
Guus Sliepen 2000-10-16 16:33:30 +00:00
parent 6e32b870ee
commit bb3d18d56f
5 changed files with 74 additions and 46 deletions

View file

@ -20,6 +20,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include "config.h"
@ -30,21 +31,22 @@ volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
volatile int cp_index = 0;
char *charbin2hex = "0123456789ABCDEF";
char *hexadecimals = "0123456789ABCDEF";
int charhex2bin(char c)
{
if(isdigit(c))
return c - '0';
else
return tolower(c) - 'a' + 10;
return toupper(c) - 'A' + 10;
}
void hex2bin(char *src, char *dst, int length)
{
int i;
for(i=0; i<length; i++)
dst[i] = charhex2bin(src[i*2])<<4 || charhex2bin(src[i*2+1]);
dst[i] = charhex2bin(src[i*2])*16 + charhex2bin(src[i*2+1]);
}
void bin2hex(char *src, char *dst, int length)
@ -52,8 +54,8 @@ void bin2hex(char *src, char *dst, int length)
int i;
for(i=length-1; i>=0; i--)
{
dst[i*2+1] = charbin2hex[(unsigned char)src[i] & 15];
dst[i*2] = charbin2hex[(unsigned char)src[i]>>4];
dst[i*2+1] = hexadecimals[(unsigned char)src[i] & 15];
dst[i*2] = hexadecimals[(unsigned char)src[i]>>4];
}
}