Changeset 22905 in vbox
- Timestamp:
- Sep 10, 2009 11:13:49 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r22673 r22905 85 85 DEBUG_ARG("so = %lx", (long)so); 86 86 DEBUG_ARG("m0 = %lx", (long)m0); 87 88 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 87 89 if(m->m_data != (MBUF_HEAD(m) + if_maxlinkhdr)) 88 90 { … … 90 92 AssertMsgFailed(("!!Ethernet frame corrupted!!")); 91 93 } 94 #else 95 M_ASSERTPKTHDR(m); 96 Assert(m->m_pkthdr.header); 97 #endif 92 98 93 99 #if 0 /* We do no options */ … … 98 104 } 99 105 #endif 106 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 107 M_ASSERTPKTHDR(m); 108 Assert(m->m_pkthdr.header); 109 ip = (struct ip *)m->m_pkthdr.header; 110 #else 100 111 ip = mtod(m, struct ip *); 112 #endif 101 113 /* 102 114 * Fill in IP header. … … 122 134 * all so we need to calculate destination ethernet address 123 135 */ 136 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 124 137 eh = (struct ethhdr *)MBUF_HEAD(m); 138 #else 139 /*todo: make prepend */ 140 m = m_prepend(pData, m, ETH_HLEN, M_DONTWAIT); 141 Assert(m); 142 eh = mtod(m, struct ethhdr *); 143 m_adj(m, ETH_HLEN); /*let the rest of code do it job*/ 144 #endif 125 145 if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0) 126 146 { … … 150 170 { 151 171 STAM_PROFILE_START(&pData->StatALIAS_output, a); 172 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 152 173 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 153 174 mtod(m, char *), m->m_len); 154 175 Log2(("NAT: LibAlias return %d\n", rc)); 176 #else 177 struct m_tag *t; 178 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 179 { 180 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL)); 181 } 182 else 183 { 184 rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 185 m_length(m, NULL)); 186 } 187 if (rc == PKT_ALIAS_IGNORED) 188 { 189 Log(("NAT: packet was droppped\n")); 190 goto bad; 191 } 192 #endif 155 193 STAM_PROFILE_STOP(&pData->StatALIAS_output, a); 156 194 } … … 181 219 int mhlen, firstlen = len; 182 220 struct mbuf **mnext = &m->m_nextpkt; 221 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 222 uint8_t buf[len]; /* intermediate buffer we'll use for copy from orriginal packet*/ 223 #endif 183 224 184 225 /* … … 191 232 { 192 233 register struct ip *mhip; 234 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 193 235 m = m_get(pData); 236 #else 237 m = m_gethdr(pData, M_DONTWAIT, MT_HEADER); 238 #endif 194 239 if (m == 0) 195 240 { … … 198 243 goto sendorfree; 199 244 } 245 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 200 246 m->m_data += if_maxlinkhdr; 201 247 mhip = mtod(m, struct ip *); 202 248 *mhip = *ip; 249 #else 250 m_copyback(pData, m, 0, mhlen, ip); 251 m->m_pkthdr.header = mtod(m, void *); 252 mhip = mtod(m, struct ip *); 253 m_adj(m, mhlen); 254 #endif 203 255 /* we've calculated eth_dst for first packet */ 256 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 204 257 eh = (struct ethhdr *)MBUF_HEAD(m); 258 #else 259 m = m_prepend(pData, m, ETH_HLEN, M_DONTWAIT); 260 Assert(m); 261 eh = mtod(m, struct ethhdr *); 262 m_adj(m, ETH_HLEN); 263 #endif 205 264 Assert((rc == 0)); 206 265 … … 214 273 } 215 274 #endif 275 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 216 276 m->m_len = mhlen; 277 #endif 217 278 mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF); 218 279 if (ip->ip_off & IP_MF) … … 224 285 mhip->ip_len = htons((u_int16_t)(len + mhlen)); 225 286 287 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 226 288 if (m_copy(m, m0, off, len) < 0) 227 289 { … … 229 291 goto sendorfree; 230 292 } 293 #else 294 m_copydata(m0, off, len, buf); /* copy to buffer */ 295 m_append(pData, m, len, buf); /* copy from buffer */ 296 #endif 231 297 232 298 mhip->ip_off = htons((u_int16_t)mhip->ip_off); … … 250 316 { 251 317 STAM_PROFILE_START(&pData->StatALIAS_output, a); 318 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 252 319 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 253 320 mtod(m, char *), m->m_len); 321 #else 322 struct m_tag *t; 323 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 324 { 325 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL)); 326 } 327 else 328 { 329 rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 330 m_length(m, NULL)); 331 } 332 if (rc == PKT_ALIAS_IGNORED) 333 { 334 Log(("NAT: packet was droppped\n")); 335 goto bad; 336 } 337 #endif 254 338 Log2(("NAT: LibAlias return %d\n", rc)); 255 339 STAM_PROFILE_STOP(&pData->StatALIAS_output, a); … … 264 348 { 265 349 int rc; 350 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 266 351 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 267 352 mtod(m, char *), m->m_len); 353 #else 354 struct m_tag *t; 355 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 356 { 357 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL)); 358 } 359 else 360 { 361 rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 362 m_length(m, NULL)); 363 } 364 if (rc == PKT_ALIAS_IGNORED) 365 { 366 Log(("NAT: packet was droppped\n")); 367 goto bad; 368 } 369 #endif 268 370 Log2(("NAT: LibAlias return %d\n", rc)); 269 371 if_output(pData, so, m);
Note:
See TracChangeset
for help on using the changeset viewer.