Compare Revisions

The credentials to download the source code are:
 Username: svnusers
 Password: svnusers

Ignore whitespace Rev 3316 → Rev 3317

/branches/STF525/ccsrc/Protocols/GeoNetworking/geonetworking_layer.cc
599,7 → 599,7
4,
LtBase(LtBase::e__50ms)
),
5
1
);
_beacon->gnPacket().packet() = GnNonSecuredPacket(
CommonHeader(
/branches/STF525/ccsrc/Protocols/UDP/udp_layer.cc
32,8 → 32,8
 
// Initialize the socket
_saddr.sin_family = AF_INET;
_saddr.sin_addr.s_addr = htonl(INADDR_ANY);
_saddr.sin_port = htons(std::atoi(_params["src_port"].c_str()));
_saddr.sin_addr.s_addr = INADDR_ANY;
_saddr.sin_port = ::htons(std::atoi(_params["src_port"].c_str()));
// Create socket
_fd = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (_fd == -1) {
52,8 → 52,8
Handler_Add_Fd_Read(_fd);
_daddr.sin_family = AF_INET;
_daddr.sin_addr.s_addr = htonl(get_host_id(_params["dsp_ip"]));
_daddr.sin_port = htons(std::atoi(_params["dst_port"].c_str()));
_daddr.sin_addr.s_addr = ::htonl(get_host_id(_params["dst_ip"]));
_daddr.sin_port = ::htons(std::atoi(_params["dst_port"].c_str()));
}
 
76,7 → 76,7
loggers::get_instance().log_msg(">>> udp_layer::send_data: ", data);
int result = ::sendto(_fd, (const char*)static_cast<const unsigned char*>(data), data.lengthof(), 0, (struct sockaddr*)&_daddr, sizeof(_daddr));
loggers::get_instance().log("udp_layer::send_data: #bytes sent: %d", result);
loggers::get_instance().log("udp_layer::send_data: #bytes sent: %d to %s:%d", result, ::inet_ntoa(_daddr.sin_addr), ntohs(_daddr.sin_port));
}
 
void udp_layer::receive_data(OCTETSTRING& data, params& params) {
111,15 → 111,17
loggers::get_instance().log(">>> udp_layer::get_host_id");
 
if (p_host_name.empty()) {
loggers::get_instance().warning("udp_layer::get_host_id: Wrong parameter");
return INADDR_ANY;
}
unsigned long ip_addr = 0;
if(p_host_name.compare("255.255.255.255") == 0) {
loggers::get_instance().warning("udp_layer::get_host_id: Host ip is 255.255.255.255");
ip_addr = 0xffffffff;
} else {
in_addr_t addr = ::inet_addr(p_host_name.c_str());
if (addr != (in_addr_t) - 1) { // host name in XX:XX:XX:XX form
if (addr != (in_addr_t)-1) { // host name in XX:XX:XX:XX form
ip_addr = addr;
} else { // host name in domain.com form
struct hostent* hptr;
133,7 → 135,7
loggers::get_instance().log("udp_layer::get_host_id: Host name: %s, Host address: %u", p_host_name.c_str(), ip_addr);
return ip_addr;
return ::htonl(ip_addr);
}
 
udp_layer_factory udp_layer_factory::_f;