Fork for fixes

Committer:
hudakz
Date:
Sat Dec 20 11:10:40 2014 +0000
Revision:
3:5b17e4656dd0
Child:
8:4acb22344932
02 Name clash with "Ethernet" fixed for LPC1768

Who changed what in which revision?

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