Skip to content

IP_PKTINFO #519

Description

@kazu-yamamoto

On Unix:

data IPv4PktInfo = IPv4PktInfo Int HostAddress HostAddress deriving (Eq)

On Windows:

data IPv4PktInfo = IPv4PktInfo ULONG HostAddress deriving (Eq)

This difference makes cross-platform usage impossible.

On Unix, in_pktinfo is defined as follows:

struct in_pktinfo {
    unsigned int   ipi_ifindex;  /* Interface index */
    struct in_addr ipi_spec_dst; /* Local address */
    struct in_addr ipi_addr;     /* Header Destination address */
};

Activity

  1. kazu-yamamoto commented on Dec 24, 2021

    @kazu-yamamoto
    CollaboratorAuthor
    • Would you tell me the definition of struct in_pktinfo on Windows?
    • Can we replace ULONG with Int?
  2. Mistuke commented on Dec 24, 2021

    @Mistuke
    Collaborator
    • Would you tell me the definition of struct in_pktinfo on Windows?

    Definition is

    typedef struct in_pktinfo {
      IN_ADDR ipi_addr;
      ULONG   ipi_ifindex;
    } IN_PKTINFO, *PIN_PKTINFO;
    
    • Can we replace ULONG with Int?

    Windows is IL32P64 so this ULONG is 32-bits. however you have the signed vs unsigned mismatch here. I guess it could be Int as you probably won't have more than 2^30 interfaces assuming they are numbered sequentially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions