Commit 0969cec8 authored by Sebastiaan Lokhorst's avatar Sebastiaan Lokhorst

sockaddr structs differ per platform, specify the macOS exception

parent d3a28240
......@@ -504,27 +504,38 @@ class DNSServiceRef(DNSRecordRef):
return fd
_sockaddr_fields = [('sa_family', _sa_family_t),
('sa_data', ctypes.c_void_p)]
_sockaddr_in_fields = [('sin_family', _sa_family_t),
('sin_port', _in_port_t),
('sin_addr', ctypes.c_byte * 4),
('__pad', ctypes.c_byte * 8)]
_sockaddr_in6_fields = [('sin6_family', _sa_family_t),
('sin6_port', _in_port_t),
('sin6_flowinfo', ctypes.c_uint32),
('sin6_addr', ctypes.c_byte * 16),
('sin6_scope_id', ctypes.c_uint32)]
# sockaddr structs on macOS start with a len field,
# while Linux and Windows do not
if sys.platform == 'darwin':
_sockaddr_fields.insert(0, ('sa_len', ctypes.c_uint8))
_sockaddr_in_fields.insert(0, ('sin_len', ctypes.c_uint8))
_sockaddr_in6_fields.insert(0, ('sin6_len', ctypes.c_uint8))
class sockaddr(ctypes.Structure):
_fields_ = [('sa_len', ctypes.c_uint8),
('sa_family', _sa_family_t),
('sa_data', ctypes.c_void_p)]
_fields_ = _sockaddr_fields
class sockaddr_in(ctypes.Structure):
_fields_ = [("sin_len", ctypes.c_uint8),
("sin_family", _sa_family_t),
("sin_port", _in_port_t),
("sin_addr", ctypes.c_byte * 4),
("__pad", ctypes.c_byte * 8)]
_fields_ = _sockaddr_in_fields
class sockaddr_in6(ctypes.Structure):
_fields_ = [("sin6_len", ctypes.c_uint8),
("sin6_family", _sa_family_t),
("sin6_port", _in_port_t),
("sin6_flowinfo", ctypes.c_uint32),
("sin6_addr", ctypes.c_byte * 16),
("sin6_scope_id", ctypes.c_uint32)]
_fields_ = _sockaddr_in6_fields
_DNSServiceDomainEnumReply = _CFunc(
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment