Giter Site home page Giter Site logo

wrapper ip format about udp-connect HOT 6 CLOSED

kyy13 avatar kyy13 commented on June 24, 2024
wrapper ip format

from udp-connect.

Comments (6)

kyy13 avatar kyy13 commented on June 24, 2024

Note that format needs to he exposed to main API as well

from udp-connect.

kyy13 avatar kyy13 commented on June 24, 2024
struct IPv4Address
{
    uint8_t octets[4];
};

struct IPv6Address
{
    uint16_t segments[8];
};

from udp-connect.

kyy13 avatar kyy13 commented on June 24, 2024
enum IpVersion : uint8_t
{
    IP_V4,
    IP_V6,
};

// IP represented in bytes
// IPv4 readable format by byte number is
//   [0].[1].[2].[3]
// IPv6 readable format by byte number is
//   [0][1]:[2][3]:[4][5]:[6][7]:[8][9]:[10][11]:[12][13]:[14][15]
//   NOTE: Byte pairs (e.g. [0][1]) in Big Endian byte order
union IpAddress
{
    uint8_t ip_v4[4];
    uint8_t ip_v6[16];
};

from udp-connect.

kyy13 avatar kyy13 commented on June 24, 2024
void udcConvertStringToIp(const char* str, IpVersion* version, IpAddress* address);

void udcConvertIpToString(IpVersion version, IpAddress address, char* str);

from udp-connect.

kyy13 avatar kyy13 commented on June 24, 2024

needs to be typedef uint8_t[16] IpAddress;
because no unions in C

from udp-connect.

kyy13 avatar kyy13 commented on June 24, 2024
enum UdcAddressFamily
{
    UDC_IPV4,
    UDC_IPV6,
};

struct UdcAddress
{
    uint8_t bytes[16];
};

struct UdcAddressIPv4
{
    uint8_t bytes[4];
};

struct UdcAddressIPv6
{
    uint8_t bytes[16];
};

UdcAddressIPv4 udcConvertToIPv4(UdcAddress);

UdcAddressIPv6 udcConvertToIPv6(UdcAddress);

from udp-connect.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.