Changes in uspace/srv/net/inetsrv/icmp.c [9749e47:c0f3460] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/icmp.c
r9749e47 rc0f3460 40 40 #include <mem.h> 41 41 #include <stdlib.h> 42 #include < types/inetping.h>42 #include <net/socket_codes.h> 43 43 #include "icmp.h" 44 44 #include "icmp_std.h" … … 105 105 reply->checksum = host2uint16_t_be(checksum); 106 106 107 rdgram.iplink = 0;108 107 rdgram.src = dgram->dest; 109 108 rdgram.dest = dgram->src; … … 122 121 { 123 122 log_msg(LOG_DEFAULT, LVL_DEBUG, "icmp_recv_echo_reply()"); 124 123 125 124 if (dgram->size < sizeof(icmp_echo_t)) 126 125 return EINVAL; 127 126 128 127 icmp_echo_t *reply = (icmp_echo_t *) dgram->data; 129 128 130 129 inetping_sdu_t sdu; 131 132 sdu.src = dgram->src; 133 sdu.dest = dgram->dest; 130 131 uint16_t family = inet_addr_get(&dgram->src, &sdu.src, NULL); 132 if (family != AF_INET) 133 return EINVAL; 134 135 family = inet_addr_get(&dgram->dest, &sdu.dest, NULL); 136 if (family != AF_INET) 137 return EINVAL; 138 134 139 sdu.seq_no = uint16_t_be2host(reply->seq_no); 135 140 sdu.data = reply + sizeof(icmp_echo_t); 136 141 sdu.size = dgram->size - sizeof(icmp_echo_t); 137 142 138 143 uint16_t ident = uint16_t_be2host(reply->ident); 139 144 … … 147 152 if (rdata == NULL) 148 153 return ENOMEM; 149 154 150 155 icmp_echo_t *request = (icmp_echo_t *) rdata; 151 156 152 157 request->type = ICMP_ECHO_REQUEST; 153 158 request->code = 0; … … 155 160 request->ident = host2uint16_t_be(ident); 156 161 request->seq_no = host2uint16_t_be(sdu->seq_no); 157 162 158 163 memcpy(rdata + sizeof(icmp_echo_t), sdu->data, sdu->size); 159 164 160 165 uint16_t checksum = inet_checksum_calc(INET_CHECKSUM_INIT, rdata, rsize); 161 166 request->checksum = host2uint16_t_be(checksum); 162 167 163 168 inet_dgram_t dgram; 164 165 dgram.src = sdu->src;166 dgram.dest = sdu->dest;167 dgram.iplink = 0;169 170 inet_addr_set(sdu->src, &dgram.src); 171 inet_addr_set(sdu->dest, &dgram.dest); 172 168 173 dgram.tos = ICMP_TOS; 169 174 dgram.data = rdata; 170 175 dgram.size = rsize; 171 176 172 177 int rc = inet_route_packet(&dgram, IP_PROTO_ICMP, INET_TTL_MAX, 0); 173 178 174 179 free(rdata); 175 180 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.