Fork for fixes

Committer:
ivo_n
Date:
Sat Sep 26 08:31:41 2020 +0000
Revision:
22:a0b1d0e6d237
Parent:
9:a156d3de5647
Everything seems to work

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 8:4acb22344932 1 //#define UIPDEBUG
hudakz 8:4acb22344932 2
hudakz 3:5b17e4656dd0 3 #if defined(UIPDEBUG)
hudakz 8:4acb22344932 4 #include <inttypes.h>
hudakz 8:4acb22344932 5 #include "mbed.h"
hudakz 8:4acb22344932 6 #include "utility/uip_debug.h"
hudakz 3:5b17e4656dd0 7 extern "C"
hudakz 3:5b17e4656dd0 8 {
hudakz 8:4acb22344932 9 #include "uip.h"
hudakz 9:a156d3de5647 10 }
hudakz 3:5b17e4656dd0 11 struct uip_conn con[UIP_CONNS];
hudakz 3:5b17e4656dd0 12
hudakz 3:5b17e4656dd0 13 /**
hudakz 3:5b17e4656dd0 14 * @brief
hudakz 3:5b17e4656dd0 15 * @note
hudakz 3:5b17e4656dd0 16 * @param
hudakz 3:5b17e4656dd0 17 * @retval
hudakz 3:5b17e4656dd0 18 */
hudakz 3:5b17e4656dd0 19 void UIPDebug::uip_debug_printconns(void) {
hudakz 8:4acb22344932 20 for (uint8_t i = 0; i < UIP_CONNS; i++) {
hudakz 8:4acb22344932 21 if (uip_debug_printcon(&con[i], &uip_conns[i])) {
hudakz 9:a156d3de5647 22 printf("connection[");
hudakz 9:a156d3de5647 23 printf("%d", i);
hudakz 9:a156d3de5647 24 printf("] changed.\r\n");
hudakz 3:5b17e4656dd0 25 }
hudakz 3:5b17e4656dd0 26 }
hudakz 3:5b17e4656dd0 27 }
hudakz 3:5b17e4656dd0 28
hudakz 3:5b17e4656dd0 29 /**
hudakz 3:5b17e4656dd0 30 * @brief
hudakz 3:5b17e4656dd0 31 * @note
hudakz 3:5b17e4656dd0 32 * @param
hudakz 3:5b17e4656dd0 33 * @retval
hudakz 3:5b17e4656dd0 34 */
hudakz 3:5b17e4656dd0 35 bool UIPDebug::uip_debug_printcon(struct uip_conn* lhs, struct uip_conn* rhs) {
hudakz 3:5b17e4656dd0 36 bool changed = false;
hudakz 8:4acb22344932 37 if (!uip_ipaddr_cmp(lhs->ripaddr, rhs->ripaddr)) {
hudakz 9:a156d3de5647 38 printf(" ripaddr: ");
hudakz 3:5b17e4656dd0 39 uip_debug_printbytes((const uint8_t*)lhs->ripaddr, 4);
hudakz 9:a156d3de5647 40 printf(" -> ");
hudakz 3:5b17e4656dd0 41 uip_debug_printbytes((const uint8_t*)rhs->ripaddr, 4);
hudakz 9:a156d3de5647 42 printf("\r\n");
hudakz 3:5b17e4656dd0 43 uip_ipaddr_copy(lhs->ripaddr, rhs->ripaddr);
hudakz 3:5b17e4656dd0 44 changed = true;
hudakz 3:5b17e4656dd0 45 }
hudakz 3:5b17e4656dd0 46
hudakz 8:4acb22344932 47 if (lhs->lport != rhs->lport) {
hudakz 9:a156d3de5647 48 printf(" lport: ");
hudakz 9:a156d3de5647 49 printf("%d", htons(lhs->lport));
hudakz 9:a156d3de5647 50 printf(" -> ");
hudakz 9:a156d3de5647 51 printf("%d\r\n", htons(rhs->lport));
hudakz 3:5b17e4656dd0 52 lhs->lport = rhs->lport;
hudakz 3:5b17e4656dd0 53 changed = true;
hudakz 3:5b17e4656dd0 54 }
hudakz 3:5b17e4656dd0 55
hudakz 8:4acb22344932 56 if (lhs->rport != rhs->rport) {
hudakz 9:a156d3de5647 57 printf(" rport: ");
hudakz 9:a156d3de5647 58 printf("%d", htons(lhs->rport));
hudakz 9:a156d3de5647 59 printf(" -> ");
hudakz 9:a156d3de5647 60 printf("%d\r\n", htons(rhs->rport));
hudakz 3:5b17e4656dd0 61 lhs->rport = rhs->rport;
hudakz 3:5b17e4656dd0 62 changed = true;
hudakz 3:5b17e4656dd0 63 }
hudakz 3:5b17e4656dd0 64
hudakz 8:4acb22344932 65 if ((uint32_t) lhs->rcv_nxt[0] != (uint32_t) rhs->rcv_nxt[0]) {
hudakz 9:a156d3de5647 66 printf(" rcv_nxt: ");
hudakz 3:5b17e4656dd0 67 uip_debug_printbytes(lhs->rcv_nxt, 4);
hudakz 9:a156d3de5647 68 printf(" -> ");
hudakz 3:5b17e4656dd0 69 uip_debug_printbytes(rhs->rcv_nxt, 4);
hudakz 3:5b17e4656dd0 70 *((uint32_t*) &lhs->rcv_nxt[0]) = (uint32_t) rhs->rcv_nxt[0];
hudakz 9:a156d3de5647 71 printf("\r\n");
hudakz 3:5b17e4656dd0 72 changed = true;
hudakz 3:5b17e4656dd0 73 }
hudakz 3:5b17e4656dd0 74
hudakz 8:4acb22344932 75 if ((uint32_t) lhs->snd_nxt[0] != (uint32_t) rhs->snd_nxt[0]) {
hudakz 9:a156d3de5647 76 printf(" snd_nxt: ");
hudakz 3:5b17e4656dd0 77 uip_debug_printbytes(lhs->snd_nxt, 4);
hudakz 9:a156d3de5647 78 printf(" -> ");
hudakz 3:5b17e4656dd0 79 uip_debug_printbytes(rhs->snd_nxt, 4);
hudakz 3:5b17e4656dd0 80 *((uint32_t*) &lhs->snd_nxt[0]) = (uint32_t) rhs->snd_nxt[0];
hudakz 9:a156d3de5647 81 printf("\r\n");
hudakz 3:5b17e4656dd0 82 changed = true;
hudakz 3:5b17e4656dd0 83 }
hudakz 3:5b17e4656dd0 84
hudakz 8:4acb22344932 85 if (lhs->len != rhs->len) {
hudakz 9:a156d3de5647 86 printf(" len: ");
hudakz 9:a156d3de5647 87 printf("%d", lhs->len);
hudakz 9:a156d3de5647 88 printf(" -> ");
hudakz 9:a156d3de5647 89 printf("%d\r\n", rhs->len);
hudakz 3:5b17e4656dd0 90 lhs->len = rhs->len;
hudakz 3:5b17e4656dd0 91 changed = true;
hudakz 3:5b17e4656dd0 92 }
hudakz 3:5b17e4656dd0 93
hudakz 8:4acb22344932 94 if (lhs->mss != rhs->mss) {
hudakz 9:a156d3de5647 95 printf(" mss: ");
hudakz 9:a156d3de5647 96 printf("%d", lhs->mss);
hudakz 9:a156d3de5647 97 printf(" -> ");
hudakz 9:a156d3de5647 98 printf("%d\r\n", rhs->mss);
hudakz 3:5b17e4656dd0 99 lhs->mss = rhs->mss;
hudakz 3:5b17e4656dd0 100 changed = true;
hudakz 3:5b17e4656dd0 101 }
hudakz 3:5b17e4656dd0 102
hudakz 8:4acb22344932 103 if (lhs->initialmss != rhs->initialmss) {
hudakz 9:a156d3de5647 104 printf(" initialmss: ");
hudakz 9:a156d3de5647 105 printf("%d", lhs->initialmss);
hudakz 9:a156d3de5647 106 printf(" -> ");
hudakz 9:a156d3de5647 107 printf("%d\r\n", rhs->initialmss);
hudakz 3:5b17e4656dd0 108 lhs->initialmss = rhs->initialmss;
hudakz 3:5b17e4656dd0 109 changed = true;
hudakz 3:5b17e4656dd0 110 }
hudakz 3:5b17e4656dd0 111
hudakz 8:4acb22344932 112 if (lhs->sa != rhs->sa) {
hudakz 9:a156d3de5647 113 printf(" sa: ");
hudakz 9:a156d3de5647 114 printf("%d", lhs->sa);
hudakz 9:a156d3de5647 115 printf(" -> ");
hudakz 9:a156d3de5647 116 printf("%d", rhs->sa);
hudakz 3:5b17e4656dd0 117 lhs->sa = rhs->sa;
hudakz 3:5b17e4656dd0 118 changed = true;
hudakz 3:5b17e4656dd0 119 }
hudakz 3:5b17e4656dd0 120
hudakz 8:4acb22344932 121 if (lhs->sv != rhs->sv) {
hudakz 9:a156d3de5647 122 printf(" sv: ");
hudakz 9:a156d3de5647 123 printf("%d", lhs->sv);
hudakz 9:a156d3de5647 124 printf(" -> ");
hudakz 9:a156d3de5647 125 printf("%d\r\n", rhs->sv);
hudakz 3:5b17e4656dd0 126 lhs->sv = rhs->sv;
hudakz 3:5b17e4656dd0 127 changed = true;
hudakz 3:5b17e4656dd0 128 }
hudakz 3:5b17e4656dd0 129
hudakz 8:4acb22344932 130 if (lhs->rto != rhs->rto) {
hudakz 9:a156d3de5647 131 printf(" rto: ");
hudakz 9:a156d3de5647 132 printf("%d", lhs->rto);
hudakz 9:a156d3de5647 133 printf(" -> ");
hudakz 9:a156d3de5647 134 printf("%d\r\n", rhs->rto);
hudakz 3:5b17e4656dd0 135 lhs->rto = rhs->rto;
hudakz 3:5b17e4656dd0 136 changed = true;
hudakz 3:5b17e4656dd0 137 }
hudakz 3:5b17e4656dd0 138
hudakz 8:4acb22344932 139 if (lhs->tcpstateflags != rhs->tcpstateflags) {
hudakz 9:a156d3de5647 140 printf(" tcpstateflags: ");
hudakz 9:a156d3de5647 141 printf("%d", lhs->tcpstateflags);
hudakz 9:a156d3de5647 142 printf(" -> ");
hudakz 9:a156d3de5647 143 printf("%d\r\n", rhs->tcpstateflags);
hudakz 3:5b17e4656dd0 144 lhs->tcpstateflags = rhs->tcpstateflags;
hudakz 3:5b17e4656dd0 145 changed = true;
hudakz 3:5b17e4656dd0 146 }
hudakz 3:5b17e4656dd0 147
hudakz 8:4acb22344932 148 if (lhs->timer != rhs->timer) {
hudakz 9:a156d3de5647 149 printf(" timer: ");
hudakz 9:a156d3de5647 150 printf("%d", lhs->timer);
hudakz 9:a156d3de5647 151 printf(" -> ");
hudakz 9:a156d3de5647 152 printf("%d\r\n", rhs->timer);
hudakz 3:5b17e4656dd0 153 lhs->timer = rhs->timer;
hudakz 3:5b17e4656dd0 154 changed = true;
hudakz 3:5b17e4656dd0 155 }
hudakz 3:5b17e4656dd0 156
hudakz 8:4acb22344932 157 if (lhs->nrtx != rhs->nrtx) {
hudakz 9:a156d3de5647 158 printf(" nrtx: ");
hudakz 9:a156d3de5647 159 printf("%d", lhs->nrtx);
hudakz 9:a156d3de5647 160 printf(" -> ");
hudakz 9:a156d3de5647 161 printf("%d\r\n", rhs->nrtx);
hudakz 3:5b17e4656dd0 162 lhs->nrtx = rhs->nrtx;
hudakz 3:5b17e4656dd0 163 changed = true;
hudakz 3:5b17e4656dd0 164 }
hudakz 3:5b17e4656dd0 165
hudakz 3:5b17e4656dd0 166 return changed;
hudakz 3:5b17e4656dd0 167 }
hudakz 3:5b17e4656dd0 168
hudakz 3:5b17e4656dd0 169 /**
hudakz 3:5b17e4656dd0 170 * @brief
hudakz 3:5b17e4656dd0 171 * @note
hudakz 3:5b17e4656dd0 172 * @param
hudakz 3:5b17e4656dd0 173 * @retval
hudakz 3:5b17e4656dd0 174 */
hudakz 3:5b17e4656dd0 175 void UIPDebug::uip_debug_printbytes(const uint8_t* data, uint8_t len) {
hudakz 8:4acb22344932 176 for (uint8_t i = 0; i < len; i++) {
hudakz 9:a156d3de5647 177 printf("%d", data[i]);
hudakz 8:4acb22344932 178 if (i < len - 1)
hudakz 9:a156d3de5647 179 printf(",");
hudakz 3:5b17e4656dd0 180 }
hudakz 3:5b17e4656dd0 181 }
hudakz 3:5b17e4656dd0 182 #endif