Revision 1fef438d

b/host/include/uhd/transport/udp_simple.hpp
85 85
     * \return the number of bytes received or zero on timeout
86 86
     */
87 87
    virtual size_t recv(const boost::asio::mutable_buffer &buff, double timeout = 0.1) = 0;
88

  
89
    /*!
90
     * Get the last IP address as seen by recv().
91
     * Only use this with the broadcast socket.
92
     */
93
    virtual std::string get_recv_addr(void) = 0;
88 94
};
89 95

  
90 96
}} //namespace
b/host/lib/transport/udp_simple.cpp
36 36
        //resolve the address
37 37
        asio::ip::udp::resolver resolver(_io_service);
38 38
        asio::ip::udp::resolver::query query(asio::ip::udp::v4(), addr, port);
39
        _receiver_endpoint = *resolver.resolve(query);
39
        _send_endpoint = *resolver.resolve(query);
40 40

  
41 41
        //create and open the socket
42 42
        _socket = socket_sptr(new asio::ip::udp::socket(_io_service));
......
46 46
        _socket->set_option(asio::socket_base::broadcast(bcast));
47 47

  
48 48
        //connect the socket
49
        if (connect) _socket->connect(_receiver_endpoint);
49
        if (connect) _socket->connect(_send_endpoint);
50 50

  
51 51
    }
52 52

  
53 53
    size_t send(const asio::const_buffer &buff){
54 54
        if (_connected) return _socket->send(asio::buffer(buff));
55
        return _socket->send_to(asio::buffer(buff), _receiver_endpoint);
55
        return _socket->send_to(asio::buffer(buff), _send_endpoint);
56 56
    }
57 57

  
58 58
    size_t recv(const asio::mutable_buffer &buff, double timeout){
59 59
        if (not wait_for_recv_ready(_socket->native(), timeout)) return 0;
60
        return _socket->receive(asio::buffer(buff));
60
        return _socket->receive_from(asio::buffer(buff), _recv_endpoint);
61
    }
62

  
63
    std::string get_recv_addr(void){
64
        return _recv_endpoint.address().to_string();
61 65
    }
62 66

  
63 67
private:
64 68
    bool                    _connected;
65 69
    asio::io_service        _io_service;
66 70
    socket_sptr             _socket;
67
    asio::ip::udp::endpoint _receiver_endpoint;
71
    asio::ip::udp::endpoint _send_endpoint;
72
    asio::ip::udp::endpoint _recv_endpoint;
68 73
};
69 74

  
70 75
/***********************************************************************
b/host/lib/usrp/usrp2/fw_common.h
88 88
    USRP2_CTRL_ID_GET_THIS_REGISTER_FOR_ME_BRO = 'r',
89 89
    USRP2_CTRL_ID_OMG_GOT_REGISTER_SO_BAD_DUDE = 'R',
90 90

  
91
    USRP2_CTRL_ID_HEY_WRITE_THIS_UART_FOR_ME_BRO = 'u',
92
    USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE = 'U',
93

  
94 91
    USRP2_CTRL_ID_HOLLER_AT_ME_BRO = 'l',
95 92
    USRP2_CTRL_ID_HOLLER_BACK_DUDE = 'L',
96 93

  
b/host/lib/usrp/usrp2/usrp2_impl.cpp
113 113
        if (len > offsetof(usrp2_ctrl_data_t, data) and ntohl(ctrl_data_in->id) == USRP2_CTRL_ID_WAZZUP_DUDE){
114 114

  
115 115
            //make a boost asio ipv4 with the raw addr in host byte order
116
            boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
117 116
            device_addr_t new_addr;
118 117
            new_addr["type"] = "usrp2";
119
            new_addr["addr"] = ip_addr.to_string();
118
            //We used to get the address from the control packet.
119
            //Now now uses the socket itself to yield the address.
120
            //boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
121
            //new_addr["addr"] = ip_addr.to_string();
122
            new_addr["addr"] = udp_transport->get_recv_addr();
120 123

  
121 124
            //Attempt to read the name from the EEPROM and perform filtering.
122 125
            //This operation can throw due to compatibility mismatch.

Also available in: Unified diff