Changeset 15365 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Dec 12, 2008 1:47:38 PM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r15355 r15365 146 146 struct udphdr *udp; 147 147 struct tcphdr *tcp; 148 struct socket *head_socket, *so; 148 struct socket *head_socket; 149 struct socket *last_socket; 150 struct socket *so; 149 151 struct in_addr laddr, faddr; 150 152 u_int lport, fport; … … 191 193 laddr.s_addr = ip->ip_src.s_addr; 192 194 lport = udp->uh_sport; 195 last_socket = udp_last_so; 193 196 /* fall through */ 194 197 … … 202 205 laddr.s_addr = ip->ip_src.s_addr; 203 206 lport = tcp->th_sport; 207 last_socket = tcp_last_so; 204 208 } 205 for (so = head_socket->so_next; so != head_socket; so = so->so_next) 209 /* check last socket first */ 210 if ( last_socket->so_faddr.s_addr == faddr.s_addr 211 && last_socket->so_fport == fport 212 && last_socket->so_hlport == lport) 213 { 214 found = 1; 215 goto sofound; 216 } 217 for (so = head_socket->so_prev; so != head_socket; so = so->so_prev) 206 218 { 207 219 /* Should be reaplaced by hash here */ … … 209 221 if ( so->so_faddr.s_addr == faddr.s_addr 210 222 && so->so_fport == fport 211 #if 0212 && so->so_hladdr.s_addr == laddr.s_addr213 #endif214 223 && so->so_hlport == lport) 215 224 { 216 icm = malloc(sizeof(struct icmp_msg));217 icm->im_m = so->so_m;218 225 found = 1; 219 LogRel(("hit:%R[natsock]\n", so));220 /*XXX: this storage not very long,221 * better add flag if it should removed from lis222 */223 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list);224 226 break; 225 227 } … … 229 231 default: 230 232 LogRel(("%s:ICMP: unsupported protocol(%d)\n", __FUNCTION__, ip->ip_p)); 233 } 234 sofound: 235 if (found == 1 && icm == NULL) 236 { 237 icm = malloc(sizeof(struct icmp_msg)); 238 icm->im_m = so->so_m; 239 icm->im_so = so; 240 found = 1; 241 LogRel(("hit:%R[natsock]\n", so)); 242 /*XXX: this storage not very long, 243 * better add flag if it should removed from lis 244 */ 245 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list); 246 return (icm); 231 247 } 232 248 if (found == 1) -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.h
r15293 r15365 177 177 LIST_ENTRY(icmp_msg) im_list; 178 178 struct mbuf *im_m; 179 struct socket *im_so; 179 180 }; 180 181 -
trunk/src/VBox/Devices/Network/slirp/socket.c
r15355 r15365 794 794 struct mbuf *m; 795 795 struct icmp_msg *icm; 796 uint8_t proto; 796 797 797 798 ip = (struct ip *)buff; … … 821 822 822 823 ip = mtod(m, struct ip *); 824 proto = ip->ip_p; 823 825 /* Now ip is pointing on header we've sent from guest */ 824 826 if (icp->icmp_type == ICMP_TIMXCEED) … … 853 855 LIST_REMOVE(icm, im_list); 854 856 /* Don't call m_free here*/ 857 #if 0 858 if (icp->icmp_type == ICMP_TIMXCEED) 859 { 860 switch (proto) 861 { 862 case IPPROTO_UDP: 863 /*XXX: so->so_m already freed so we shouldn't call sofree */ 864 if (so == udp_last_so) 865 udp_last_so = &udb; 866 closesocket(icm->im_so->s); 867 icm->im_so->s = 1; 868 icm->im_so->so_state = SS_NOFDREF; 869 if(so->so_next && so->so_prev) { 870 remque(pData, so); 871 free(icm->im_so); 872 } 873 break; 874 case IPPROTO_TCP: 875 /*close tcp should be here */ 876 break; 877 default: 878 /* do nothing */ 879 break; 880 } 881 } 882 #endif 855 883 free(icm); 856 884 }
Note:
See TracChangeset
for help on using the changeset viewer.