Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 275:bb2d582c20d6, committed 2020-10-18
- Comitter:
- nixnax
- Date:
- Sun Oct 18 17:30:29 2020 +0000
- Parent:
- 274:b1bc40deb637
- Commit message:
- Formatting
Changed in this revision
PPP-Blinky/ppp-blinky.cpp | Show annotated file Show diff for this revision Revisions of this file |
PPP-Blinky/ppp-blinky.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r b1bc40deb637 -r bb2d582c20d6 PPP-Blinky/ppp-blinky.cpp --- a/PPP-Blinky/ppp-blinky.cpp Thu Sep 17 14:07:15 2020 +0000 +++ b/PPP-Blinky/ppp-blinky.cpp Sun Oct 18 17:30:29 2020 +0000 @@ -197,7 +197,7 @@ ppp.ip = (ipHeaderType *)(ppp.pkt.buf+4); // pointer to IP header } -/// Toggle the LED +/// Toggle the LED void led1Toggle() { led1 = (ppp.ledState >> 0) & 1; // use first bit, in other words toggle LED only every packet @@ -910,7 +910,7 @@ #define SHOWSERVERNAME_NO #ifdef SHOWSERVERNAME_YES n=n+sprintf(n+dataStart,"Server: mbed PPP-Blinky\r\n"); // Server in response header -#endif +#endif #define SHOWMAXBUFLEVEL_NO #ifdef SHOWMAXBUFLEVEL_YES // if this is enabled then the maximum value of the serial port receive buffer will show up in the http headers of your browser - nice for debugging @@ -960,7 +960,7 @@ n=n+sprintf(n+dataStart, "<meta http-equiv=\"refresh\" content=\"0\">"); // reload loop - handy for benchmarking // /x is a very short page, in fact, it is only a decimal number showing the http Page count if (httpGet6 == 't' ) // if the fetched pages is "xt" toggle the LEd - led1Toggle(); + led1Toggle(); #ifdef W3C_COMPLIANT_RESPONSE_YES n=n+sprintf(n+dataStart,"<body>%d</body>",ppp.responseCounter); // body = the http frame count #else @@ -1281,8 +1281,7 @@ { uint32_t a, b, c, d, e; - typedef union - { + typedef union { unsigned char c[64]; uint32_t l[16]; } CHAR64LONG16; @@ -1433,17 +1432,14 @@ context->count[1]++; context->count[1] += (len >> 29); j = (j >> 3) & 63; - if ((j + len) > 63) - { + if ((j + len) > 63) { memcpy(&context->buffer[j], data, (i = 64 - j)); SHA1Transform(context->state, context->buffer); - for (; i + 63 < len; i += 64) - { + for (; i + 63 < len; i += 64) { SHA1Transform(context->state, &data[i]); } j = 0; - } - else + } else i = 0; memcpy(&context->buffer[j], &data[i], len - i); } @@ -1462,23 +1458,20 @@ unsigned char c; - for (i = 0; i < 8; i++) - { + for (i = 0; i < 8; i++) { finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */ } c = 0200; SHA1Update(context, &c, 1); - while ((context->count[0] & 504) != 448) - { + while ((context->count[0] & 504) != 448) { c = 0000; SHA1Update(context, &c, 1); } SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ - for (i = 0; i < 20; i++) - { + for (i = 0; i < 20; i++) { digest[i] = (unsigned char) - ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); + ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); } /* Wipe variables */ memset(context, '\0', sizeof(*context));
diff -r b1bc40deb637 -r bb2d582c20d6 PPP-Blinky/ppp-blinky.h --- a/PPP-Blinky/ppp-blinky.h Thu Sep 17 14:07:15 2020 +0000 +++ b/PPP-Blinky/ppp-blinky.h Sun Oct 18 17:30:29 2020 +0000 @@ -179,8 +179,7 @@ 100% Public Domain */ -typedef struct -{ +typedef struct { uint32_t state[5]; uint32_t count[2]; unsigned char buffer[64]; @@ -189,22 +188,22 @@ void SHA1Transform( uint32_t state[5], const unsigned char buffer[64] - ); +); void SHA1Init( SHA1_CTX * context - ); +); void SHA1Update( SHA1_CTX * context, const unsigned char *data, uint32_t len - ); +); void SHA1Final( unsigned char digest[20], SHA1_CTX * context - ); +); void sha1( char *hash_out,