Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
L
libnice
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 27
    • Issues 27
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 3
    • Merge Requests 3
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Registry
    • Registry
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • libnice
  • libnice
  • Issues
  • #67

Closed
Open
Opened Jan 30, 2019 by HarlanC@harlanc
  • Report abuse
  • New issue
Report abuse New issue

the nice_interfaces_is_private_ip function is not correct

input 192.168.15.69 output false

BUT the result should be true.

the value of sa.in->sin_addr.s_addr is 0x450FA8C0

My environment is OSX ,it is little end.And the following implementation is good for the IP 192.168.15.69:

static gboolean nice_interfaces_is_private_ip (const struct sockaddr *_sa)
{
  union {
    const struct sockaddr *addr;
    const struct sockaddr_in *in;
  } sa;

  sa.addr = _sa;

  if (sa.addr->sa_family == AF_INET) {
    /* 10.x.x.x/8 */
    if (sa.in->sin_addr.s_addr >> 24 == 0x0A)
      return TRUE;

    /* 172.16.0.0 - 172.31.255.255 = 172.16.0.0/10 */
    if (sa.in->sin_addr.s_addr >> 20 == 0xAC1)
      return TRUE;

    /* 192.168.x.x/16 */
    if ((sa.in->sin_addr.s_addr & 0xFFFF) == 0xA8C0)
      return TRUE;

    /* 169.254.x.x/16  (for APIPA) */
    if (sa.in->sin_addr.s_addr >> 16 == 0xA9FE)
      return TRUE;
  }
  
  return FALSE;
}
Edited Jan 30, 2019 by HarlanC
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
No due date
0
Labels
None
Assign labels
  • View project labels
Reference: libnice/libnice#67