mbed OS5

Fork of UIPEthernet by Zoltan Hudak

Committer:
pilotak
Date:
Sun Aug 06 16:01:26 2017 +0000
Revision:
9:e55652bed36c
Parent:
8:4acb22344932
mBed OS5

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 3:5b17e4656dd0 10 } extern Serial pc;
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 3:5b17e4656dd0 22 pc.printf("connection[");
hudakz 3:5b17e4656dd0 23 pc.printf("%d", i);
hudakz 8:4acb22344932 24 pc.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 3:5b17e4656dd0 38 pc.printf(" ripaddr: ");
hudakz 3:5b17e4656dd0 39 uip_debug_printbytes((const uint8_t*)lhs->ripaddr, 4);
hudakz 3:5b17e4656dd0 40 pc.printf(" -> ");
hudakz 3:5b17e4656dd0 41 uip_debug_printbytes((const uint8_t*)rhs->ripaddr, 4);
hudakz 8:4acb22344932 42 pc.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 3:5b17e4656dd0 48 pc.printf(" lport: ");
hudakz 3:5b17e4656dd0 49 pc.printf("%d", htons(lhs->lport));
hudakz 3:5b17e4656dd0 50 pc.printf(" -> ");
hudakz 8:4acb22344932 51 pc.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 3:5b17e4656dd0 57 pc.printf(" rport: ");
hudakz 3:5b17e4656dd0 58 pc.printf("%d", htons(lhs->rport));
hudakz 3:5b17e4656dd0 59 pc.printf(" -> ");
hudakz 8:4acb22344932 60 pc.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 3:5b17e4656dd0 66 pc.printf(" rcv_nxt: ");
hudakz 3:5b17e4656dd0 67 uip_debug_printbytes(lhs->rcv_nxt, 4);
hudakz 3:5b17e4656dd0 68 pc.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 8:4acb22344932 71 pc.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 3:5b17e4656dd0 76 pc.printf(" snd_nxt: ");
hudakz 3:5b17e4656dd0 77 uip_debug_printbytes(lhs->snd_nxt, 4);
hudakz 3:5b17e4656dd0 78 pc.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 8:4acb22344932 81 pc.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 3:5b17e4656dd0 86 pc.printf(" len: ");
hudakz 3:5b17e4656dd0 87 pc.printf("%d", lhs->len);
hudakz 3:5b17e4656dd0 88 pc.printf(" -> ");
hudakz 8:4acb22344932 89 pc.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 3:5b17e4656dd0 95 pc.printf(" mss: ");
hudakz 3:5b17e4656dd0 96 pc.printf("%d", lhs->mss);
hudakz 3:5b17e4656dd0 97 pc.printf(" -> ");
hudakz 8:4acb22344932 98 pc.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 3:5b17e4656dd0 104 pc.printf(" initialmss: ");
hudakz 3:5b17e4656dd0 105 pc.printf("%d", lhs->initialmss);
hudakz 3:5b17e4656dd0 106 pc.printf(" -> ");
hudakz 8:4acb22344932 107 pc.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 3:5b17e4656dd0 113 pc.printf(" sa: ");
hudakz 3:5b17e4656dd0 114 pc.printf("%d", lhs->sa);
hudakz 3:5b17e4656dd0 115 pc.printf(" -> ");
hudakz 3:5b17e4656dd0 116 pc.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 3:5b17e4656dd0 122 pc.printf(" sv: ");
hudakz 3:5b17e4656dd0 123 pc.printf("%d", lhs->sv);
hudakz 3:5b17e4656dd0 124 pc.printf(" -> ");
hudakz 8:4acb22344932 125 pc.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 3:5b17e4656dd0 131 pc.printf(" rto: ");
hudakz 3:5b17e4656dd0 132 pc.printf("%d", lhs->rto);
hudakz 3:5b17e4656dd0 133 pc.printf(" -> ");
hudakz 8:4acb22344932 134 pc.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 3:5b17e4656dd0 140 pc.printf(" tcpstateflags: ");
hudakz 3:5b17e4656dd0 141 pc.printf("%d", lhs->tcpstateflags);
hudakz 3:5b17e4656dd0 142 pc.printf(" -> ");
hudakz 8:4acb22344932 143 pc.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 3:5b17e4656dd0 149 pc.printf(" timer: ");
hudakz 3:5b17e4656dd0 150 pc.printf("%d", lhs->timer);
hudakz 3:5b17e4656dd0 151 pc.printf(" -> ");
hudakz 8:4acb22344932 152 pc.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 3:5b17e4656dd0 158 pc.printf(" nrtx: ");
hudakz 3:5b17e4656dd0 159 pc.printf("%d", lhs->nrtx);
hudakz 3:5b17e4656dd0 160 pc.printf(" -> ");
hudakz 8:4acb22344932 161 pc.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 3:5b17e4656dd0 177 pc.printf("%d", data[i]);
hudakz 8:4acb22344932 178 if (i < len - 1)
hudakz 3:5b17e4656dd0 179 pc.printf(",");
hudakz 3:5b17e4656dd0 180 }
hudakz 3:5b17e4656dd0 181 }
hudakz 3:5b17e4656dd0 182 #endif