Commit cd6b0ee0 by xiongguangjie

fix peer ip error

parent af9bd2dd
......@@ -419,9 +419,15 @@ void HandshakePacket::assignPeerIP(struct sockaddr_storage* addr){
struct sockaddr_in * ipv4 = (struct sockaddr_in *)addr;
//抓包 奇怪好像是小头端???
storeUint32LE(peer_ip_addr,ipv4->sin_addr.s_addr);
}else{
const sockaddr_in6* ipv6 = (struct sockaddr_in6 *)addr;
memcpy(peer_ip_addr,ipv6->sin6_addr.s6_addr,sizeof(peer_ip_addr)*sizeof(peer_ip_addr[0]));
}else if(addr->ss_family == AF_INET6){
if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr)->sin6_addr)) {
struct in_addr addr4;
memcpy(&addr4, 12 + (char *)&(((struct sockaddr_in6 *)addr)->sin6_addr), 4);
storeUint32LE(peer_ip_addr,addr4.s_addr);
}else{
const sockaddr_in6* ipv6 = (struct sockaddr_in6 *)addr;
memcpy(peer_ip_addr,ipv6->sin6_addr.s6_addr,sizeof(peer_ip_addr)*sizeof(peer_ip_addr[0]));
}
}
}
uint32_t HandshakePacket::generateSynCookie(struct sockaddr_storage* addr,TimePoint ts,uint32_t current_cookie, int correction ){
......
......@@ -11,9 +11,9 @@ SrtSession::SrtSession(const Socket::Ptr &sock)
: UdpSession(sock) {
socklen_t addr_len = sizeof(_peer_addr);
memset(&_peer_addr,0,addr_len);
TraceL<<"before addr len "<<addr_len;
//TraceL<<"before addr len "<<addr_len;
getpeername(sock->rawFD(), (struct sockaddr *)&_peer_addr, &addr_len);
TraceL<<"after addr len "<<addr_len<<" family "<<_peer_addr.ss_family;
//TraceL<<"after addr len "<<addr_len<<" family "<<_peer_addr.ss_family;
}
SrtSession::~SrtSession() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论