Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicast support #251

Open
rorschach-py opened this issue Sep 3, 2022 · 1 comment
Open

multicast support #251

rorschach-py opened this issue Sep 3, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@rorschach-py
Copy link

请添加组播功能支持

please add support to multicast utility func like this

bool is_multicast_addr(const char* addr)
{   
    //ipv4 only
    addr = ntohl(inet_addr(addr));
    return (addr >> 28) == 0xE;
}

// IP_MULTICAST_IF
HV_INLINE int set_ip_multicast_if(SOCKET sock, const char* ifaddr)
{
    struct in_addr addr;
    addr.s_addr = inet_addr(ifaddr);
    return setsockopt(sock, IPPROTO_IP,IP_MULTICAST_IF,(void *)&addr,sizeof(addr));
}

// IP_ADD_MEMBERSHIP
HV_INLINE int join_group(SOCKET sock, const char* gaddr, const char* ifaddr)
{
    struct ip_mreq mreq= {0};
    mreq.imr_multiaddr.s_addr = inet_addr(gaddr);
    mreq.imr_interface.s_addr = inet_addr(ifaddr);
    return setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq));
}

also IP_DROP_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, IP_MULTICAST_TTL, IP_MULTICAST_LOOP

@ithewei
Copy link
Owner

ithewei commented Sep 4, 2022

我没有开发过组播相关的业务,对这块不是很熟,如果你需要的话,可以提PR

@ithewei ithewei added the help wanted Extra attention is needed label Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants