~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to slirp/if.c

  • Committer: ths
  • Date: 2007-09-16 21:08:06 UTC
  • Revision ID: git-v1:5fafdf24ef2c090c164d4dc89684b3f379dbdd87
find -type f | xargs sed -i 's/[\t ]$//g' # on most files


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
#include <slirp.h>
9
9
 
 
10
int if_mtu, if_mru;
 
11
int if_comp;
 
12
int if_maxlinkhdr;
10
13
int     if_queued = 0;                  /* Number of packets queued so far */
 
14
int     if_thresh = 10;                 /* Number of packets queued before we start sending
 
15
                                         * (to prevent allocing too many mbufs) */
11
16
 
12
17
struct  mbuf if_fastq;                  /* fast queue (for interactive data) */
13
18
struct  mbuf if_batchq;                 /* queue for non-interactive data */
15
20
 
16
21
#define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
17
22
 
18
 
static void
19
 
ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead)
 
23
void
 
24
ifs_insque(ifm, ifmhead)
 
25
        struct mbuf *ifm, *ifmhead;
20
26
{
21
27
        ifm->ifs_next = ifmhead->ifs_next;
22
28
        ifmhead->ifs_next = ifm;
24
30
        ifm->ifs_next->ifs_prev = ifm;
25
31
}
26
32
 
27
 
static void
28
 
ifs_remque(struct mbuf *ifm)
 
33
void
 
34
ifs_remque(ifm)
 
35
        struct mbuf *ifm;
29
36
{
30
37
        ifm->ifs_prev->ifs_next = ifm->ifs_next;
31
38
        ifm->ifs_next->ifs_prev = ifm->ifs_prev;
34
41
void
35
42
if_init()
36
43
{
 
44
#if 0
 
45
        /*
 
46
         * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
 
47
         * and 8 bytes for PPP, but need to have it on an 8byte boundary
 
48
         */
 
49
#ifdef USE_PPP
 
50
        if_maxlinkhdr = 48;
 
51
#else
 
52
        if_maxlinkhdr = 40;
 
53
#endif
 
54
#else
 
55
        /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
 
56
        if_maxlinkhdr = 2 + 14 + 40;
 
57
#endif
 
58
        if_mtu = 1500;
 
59
        if_mru = 1500;
 
60
        if_comp = IF_AUTOCOMP;
37
61
        if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
38
62
        if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
39
63
        //      sl_compress_init(&comp_s);
155
179
        }
156
180
 
157
181
        /*
158
 
         * See if there's already a batchq list for this session.
 
182
         * See if there's already a batchq list for this session. 
159
183
         * This can include an interactive session, which should go on fastq,
160
184
         * but gets too greedy... hence it'll be downgraded from fastq to batchq.
161
185
         * We mustn't put this packet back on the fastq (or we'll send it out of order)
207
231
                 */
208
232
                if (on_fastq && ((so->so_nqueued >= 6) &&
209
233
                                 (so->so_nqueued - so->so_queued) >= 3)) {
210
 
 
 
234
                
211
235
                        /* Remove from current queue... */
212
236
                        remque(ifm->ifs_next);
213
 
 
 
237
                
214
238
                        /* ...And insert in the new.  That'll teach ya! */
215
239
                        insque(ifm->ifs_next, &if_batchq);
216
240
                }
266
290
                   ifm = next_m;
267
291
                else
268
292
                   ifm = if_batchq.ifq_next;
269
 
 
 
293
        
270
294
                /* Set which packet to send on next iteration */
271
295
                next_m = ifm->ifq_next;
272
296
        }
289
313
        }
290
314
 
291
315
        /* Encapsulate the packet for sending */
292
 
        if_encap((uint8_t *)ifm->m_data, ifm->m_len);
 
316
        if_encap(ifm->m_data, ifm->m_len);
293
317
 
294
318
        m_free(ifm);
295
319