Port of LwIP performed by Ralf in 2010. Not recommended for use with recent mbed libraries, but good demos of raw LwIP possible

Dependents:   LwIP_raw_API_serverExample tiny-dtls

Committer:
RodColeman
Date:
Tue Sep 18 14:41:24 2012 +0000
Revision:
0:0791c1fece8e
[mbed] converted /Eth_TCP_Wei_Server/lwip

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RodColeman 0:0791c1fece8e 1 #include "iputil.h"
RodColeman 0:0791c1fece8e 2
RodColeman 0:0791c1fece8e 3 unsigned int base64enc_len(const char *str) {
RodColeman 0:0791c1fece8e 4 return (((strlen(str)-1)/3)+1)<<2;
RodColeman 0:0791c1fece8e 5 }
RodColeman 0:0791c1fece8e 6
RodColeman 0:0791c1fece8e 7 void base64enc(const char *input, unsigned int length, char *output) {
RodColeman 0:0791c1fece8e 8 static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
RodColeman 0:0791c1fece8e 9 unsigned int c, c1, c2, c3;
RodColeman 0:0791c1fece8e 10 for(unsigned int i = 0, j = 0; i<length; i+=3,j+=4) {
RodColeman 0:0791c1fece8e 11 c1 = ((((unsigned char)*((unsigned char *)&input[i]))));
RodColeman 0:0791c1fece8e 12 c2 = (length>i+1)?((((unsigned char)*((unsigned char *)&input[i+1])))):0;
RodColeman 0:0791c1fece8e 13 c3 = (length>i+2)?((((unsigned char)*((unsigned char *)&input[i+2])))):0;
RodColeman 0:0791c1fece8e 14
RodColeman 0:0791c1fece8e 15 c = ((c1 & 0xFC) >> 2);
RodColeman 0:0791c1fece8e 16 output[j+0] = base64[c];
RodColeman 0:0791c1fece8e 17 c = ((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4);
RodColeman 0:0791c1fece8e 18 output[j+1] = base64[c];
RodColeman 0:0791c1fece8e 19 c = ((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6);
RodColeman 0:0791c1fece8e 20 output[j+2] = (length>i+1)?base64[c]:'=';
RodColeman 0:0791c1fece8e 21 c = (c3 & 0x3F);
RodColeman 0:0791c1fece8e 22 output[j+3] = (length>i+2)?base64[c]:'=';
RodColeman 0:0791c1fece8e 23 }
RodColeman 0:0791c1fece8e 24 output[(((length-1)/3)+1)<<2] = '\0';
RodColeman 0:0791c1fece8e 25 }