Revision 5fafdf24 slirp/bootp.c

b/slirp/bootp.c
1 1
/*
2 2
 * QEMU BOOTP/DHCP server
3
 * 
3
 *
4 4
 * Copyright (c) 2004 Fabrice Bellard
5
 * 
5
 *
6 6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 7
 * of this software and associated documentation files (the "Software"), to deal
8 8
 * in the Software without restriction, including without limitation the rights
......
89 89
    const uint8_t *p, *p_end;
90 90
    int len, tag;
91 91

  
92
    *pmsg_type = 0;    
92
    *pmsg_type = 0;   
93 93

  
94 94
    p = buf;
95 95
    p_end = buf + size;
......
101 101
    while (p < p_end) {
102 102
        tag = p[0];
103 103
        if (tag == RFC1533_PAD) {
104
            p++; 
104
            p++;
105 105
        } else if (tag == RFC1533_END) {
106 106
            break;
107 107
        } else {
......
137 137
    /* extract exact DHCP msg type */
138 138
    dhcp_decode(bp->bp_vend, DHCP_OPT_LEN, &dhcp_msg_type);
139 139
    dprintf("bootp packet op=%d msgtype=%d\n", bp->bp_op, dhcp_msg_type);
140
    
140
   
141 141
    if (dhcp_msg_type == 0)
142 142
        dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */
143
        
144
    if (dhcp_msg_type != DHCPDISCOVER && 
143
       
144
    if (dhcp_msg_type != DHCPDISCOVER &&
145 145
        dhcp_msg_type != DHCPREQUEST)
146 146
        return;
147 147
    /* XXX: this is a hack to get the client mac address */
148 148
    memcpy(client_ethaddr, bp->bp_hwaddr, 6);
149
    
149
   
150 150
    if ((m = m_get()) == NULL)
151 151
        return;
152 152
    m->m_data += if_maxlinkhdr;
......
203 203
        *q++ = 1;
204 204
        *q++ = DHCPACK;
205 205
    }
206
        
206
       
207 207
    if (dhcp_msg_type == DHCPDISCOVER ||
208 208
        dhcp_msg_type == DHCPREQUEST) {
209 209
        *q++ = RFC2132_SRV_ID;
......
217 217
        *q++ = 0xff;
218 218
        *q++ = 0xff;
219 219
        *q++ = 0x00;
220
        
220
       
221 221
        *q++ = RFC1533_GATEWAY;
222 222
        *q++ = 4;
223 223
        memcpy(q, &saddr.sin_addr, 4);
224 224
        q += 4;
225
        
225
       
226 226
        *q++ = RFC1533_DNS;
227 227
        *q++ = 4;
228 228
        dns_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS);
......
244 244
        }
245 245
    }
246 246
    *q++ = RFC1533_END;
247
    
248
    m->m_len = sizeof(struct bootp_t) - 
247
   
248
    m->m_len = sizeof(struct bootp_t) -
249 249
        sizeof(struct ip) - sizeof(struct udphdr);
250 250
    udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
251 251
}

Also available in: Unified diff