VirtualBox

Ignore:
Timestamp:
Jan 27, 2009 10:09:55 AM (16 years ago)
Author:
vboxsync
Message:

NAT: clean up dhcp a bit, and fox the TFTP server address calculation

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/bootp.c

    r16249 r16254  
    215215        RTStrPrintf((char*)rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename);
    216216
    217     saddr.sin_addr.s_addr = pData->tftp_server.s_addr;
     217    /* Address/port of the DHCP server. */
     218    saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS);
    218219    saddr.sin_port = htons(BOOTP_SERVER);
    219220
     
    227228
    228229    rbp->bp_yiaddr = daddr.sin_addr; /* Client IP address */
    229     rbp->bp_siaddr = saddr.sin_addr; /* Server IP address */
    230 
    231     /*XXX: latter it used for initialization of gateway*/
    232     saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS);
     230    rbp->bp_siaddr = pData->tftp_server; /* Next Server IP address, i.e. TFTP */
    233231
    234232    q = rbp->bp_vend;
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r16249 r16254  
    204204    inet_aton("255.0.0.0", &local_mask);
    205205    inet_aton("127.0.0.0", &local_network);
    206     for (pIPAddr = &FixedInfo->DnsServerList; pIPAddr != NULL; pIPAddr = pIPAddr->Next) 
    207     {
    208         struct dns_entry *da = RTMemAllocZ(sizeof (struct dns_entry)); 
    209         if (da == NULL) 
     206    for (pIPAddr = &FixedInfo->DnsServerList; pIPAddr != NULL; pIPAddr = pIPAddr->Next)
     207    {
     208        struct dns_entry *da = RTMemAllocZ(sizeof (struct dns_entry));
     209        if (da == NULL)
    210210        {
    211211            LogRel(("can't alloc memory for DNS entry\n"));
     
    215215        inet_aton(pIPAddr->IpAddress.String, &da->de_addr);
    216216        if ((ntohl(da->de_addr.s_addr) & ntohl(local_mask.s_addr)) == ntohl(local_network.s_addr)) {
    217             da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 
     217            da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS);
    218218        }
    219219        LIST_INSERT_HEAD(&pData->dns_list_head, da, de_list);
     
    374374    bootp_filename = pszBootFile;
    375375    pData->netmask = u32Netmask;
    376     /* @todo: add ability to configurate this staff */
    377     pData->tftp_server.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_TFTP);
    378376
    379377#ifdef RT_OS_WINDOWS
     
    399397    inet_aton(pszNetAddr, &special_addr);
    400398    alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
     399    /* @todo: add ability to configure this staff */
     400    pData->tftp_server.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_TFTP);
    401401
    402402    /* set default addresses */
     
    747747    {
    748748#if defined(RT_OS_WINDOWS)
    749         /*XXX: before renaming please make see define 
     749        /*XXX: before renaming please make see define
    750750         * fIcmp in slirp_state.h
    751751         */
     
    10101010    eh = (struct ethhdr *)pkt;
    10111011#else
    1012     struct mbuf *mr; 
     1012    struct mbuf *mr;
    10131013    eh = mtod(m, struct ethhdr *);
    10141014#endif
     
    10571057                memcpy(rah->ar_sha, special_ethaddr, ETH_ALEN);
    10581058
    1059                 switch (htip & ~pData->netmask) 
     1059                switch (htip & ~pData->netmask)
    10601060                {
    10611061                    case CTL_DNS:
     
    10651065                    default:;
    10661066                }
    1067                
     1067
    10681068                memcpy(rah->ar_sip, ah->ar_tip, 4);
    10691069                memcpy(rah->ar_tha, ah->ar_sha, ETH_ALEN);
     
    10881088    static bool fWarnedIpv6;
    10891089
    1090     if (pkt_len < ETH_HLEN) 
     1090    if (pkt_len < ETH_HLEN)
    10911091    {
    10921092        LogRel(("NAT: packet having size %d has been ingnored\n", pkt_len));
    10931093        return;
    10941094    }
    1095    
     1095
    10961096    m = m_get(pData);
    10971097    if (!m)
     
    11571157    eh = mtod(m, struct ethhdr *);
    11581158#else
    1159     uint8_t buf[1600]; 
     1159    uint8_t buf[1600];
    11601160    struct ethhdr *eh = (struct ethhdr *)buf;
    11611161
    11621162    if (ip_data_len + ETH_HLEN > sizeof(buf))
    11631163        return;
    1164    
     1164
    11651165    memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len);
    11661166#endif
     
    11761176    slirp_output(pData->pvUser, m, mtod(m, uint8_t *), m->m_len);
    11771177#else
    1178     memcpy(buf, mtod(m, uint8_t *), m->m_len); 
     1178    memcpy(buf, mtod(m, uint8_t *), m->m_len);
    11791179    slirp_output(pData->pvUser, NULL, buf, m->m_len);
    11801180    m_free(pData, m);
     
    12441244void slirp_post_sent(PNATState pData, void *pvArg)
    12451245{
    1246     struct socket *so = 0; 
     1246    struct socket *so = 0;
    12471247    struct tcpcb *tp = 0;
    12481248    struct mbuf *m = (struct mbuf *)pvArg;
    1249     m_free(pData, m); 
    1250 }
     1249    m_free(pData, m);
     1250}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette