ip_dummynet.c (46385) | ip_dummynet.c (46420) |
---|---|
1/* 2 * Copyright (c) 1998 Luigi Rizzo 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * | 1/* 2 * Copyright (c) 1998 Luigi Rizzo 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * |
13 * $Id: ip_dummynet.c,v 1.12 1999/04/20 13:32:04 peter Exp $ | 13 * $Id: ip_dummynet.c,v 1.13 1999/05/04 07:30:07 luigi Exp $ |
14 */ 15 16/* 17 * This module implements IP dummynet, a bandwidth limiter/delay emulator 18 * used in conjunction with the ipfw package. 19 * 20 * Changes: 21 * --- 184 unchanged lines hidden (view full) --- 206 207 /* 208 * the trick to avoid flow-id settings here is to prepend a 209 * vestigial mbuf to the packet, with the following values: 210 * m_type = MT_DUMMYNET 211 * m_next = the actual mbuf to be processed by ip_input/output 212 * m_data = the matching rule 213 * The vestigial element is the same memory area used by | 14 */ 15 16/* 17 * This module implements IP dummynet, a bandwidth limiter/delay emulator 18 * used in conjunction with the ipfw package. 19 * 20 * Changes: 21 * --- 184 unchanged lines hidden (view full) --- 206 207 /* 208 * the trick to avoid flow-id settings here is to prepend a 209 * vestigial mbuf to the packet, with the following values: 210 * m_type = MT_DUMMYNET 211 * m_next = the actual mbuf to be processed by ip_input/output 212 * m_data = the matching rule 213 * The vestigial element is the same memory area used by |
214 * the dn_pkt, and IS FREED IN ip_input/ip_output. IT IS 215 * NOT A REAL MBUF, just a block of memory acquired with malloc(). | 214 * the dn_pkt, and IS FREED HERE because it can contain 215 * parameters passed to the called routine. The buffer IS NOT 216 * A REAL MBUF, just a block of memory acquired with malloc(). |
216 */ 217 switch (pkt->dn_dir) { 218 case DN_TO_IP_OUT: { 219 struct rtentry *tmp_rt = pkt->ro.ro_rt ; 220 221 (void)ip_output((struct mbuf *)pkt, (struct mbuf *)pkt->ifp, 222 &(pkt->ro), pkt->dn_dst, NULL); 223 rt_unref (tmp_rt) ; --- 10 unchanged lines hidden (view full) --- 234 if (m) 235 m_freem(m); 236 } 237 break ; 238#endif 239 default: 240 printf("dummynet: bad switch %d!\n", pkt->dn_dir); 241 m_freem(pkt->dn_m); | 217 */ 218 switch (pkt->dn_dir) { 219 case DN_TO_IP_OUT: { 220 struct rtentry *tmp_rt = pkt->ro.ro_rt ; 221 222 (void)ip_output((struct mbuf *)pkt, (struct mbuf *)pkt->ifp, 223 &(pkt->ro), pkt->dn_dst, NULL); 224 rt_unref (tmp_rt) ; --- 10 unchanged lines hidden (view full) --- 235 if (m) 236 m_freem(m); 237 } 238 break ; 239#endif 240 default: 241 printf("dummynet: bad switch %d!\n", pkt->dn_dir); 242 m_freem(pkt->dn_m); |
242 FREE(pkt, M_IPFW); | |
243 break ; 244 } | 243 break ; 244 } |
245 FREE(pkt, M_IPFW); |
|
245 } 246} 247/* 248 * this is the periodic task that moves packets between the R- 249 * and the P- queue 250 */ 251/*ARGSUSED*/ 252void --- 389 unchanged lines hidden --- | 246 } 247} 248/* 249 * this is the periodic task that moves packets between the R- 250 * and the P- queue 251 */ 252/*ARGSUSED*/ 253void --- 389 unchanged lines hidden --- |