예제 #1
0
파일: options.py 프로젝트: pombreda/sock2
def Ipv6MreqOption(level, option, doc):
    format = "<16sI"
    size = struct.calcsize(format)
    @option_error_decorator
    def getter(self):
        mcast, iface = struct.unpack(format, self._sock.getsockopt(level,
            option, size))
        return _socket.inet6_ntoa(mcast), iface
    @option_error_decorator
    def setter(self, (mcast, iface)):
        raw = struct.pack(format, _socket.inet6_aton(mcast), iface)
        self._sock.setsockopt(level, option, raw)
예제 #2
0
파일: options.py 프로젝트: pombreda/sock2
def SockaddrIn6Option(level, option, doc):
    format = "<BBHL16s"
    size = struct.calcsize(format)
    @option_error_decorator
    def getter(self):
        len, fam, port, flow, addr = struct.unpack(format,
            self._sock.getsockopt(level, option, size))
        return port, flow, _socket.inet6_ntoa(addr)
    @option_error_decorator
    def setter(self, (port, flow, addr)):
        raw = struct.pack(format, size, consts.AddressFamily.IPv6, port, flow,
            _socket.inet6_aton(mcast))
        self._sock.setsockopt(level, option, raw)
예제 #3
0
def Ipv6MreqOption(level, option, doc):
    format = "<16sI"
    size = struct.calcsize(format)

    @option_error_decorator
    def getter(self):
        mcast, iface = struct.unpack(
            format, self._sock.getsockopt(level, option, size))
        return _socket.inet6_ntoa(mcast), iface

    @option_error_decorator
    def setter(self, (mcast, iface)):
        raw = struct.pack(format, _socket.inet6_aton(mcast), iface)
        self._sock.setsockopt(level, option, raw)
예제 #4
0
def SockaddrIn6Option(level, option, doc):
    format = "<BBHL16s"
    size = struct.calcsize(format)

    @option_error_decorator
    def getter(self):
        len, fam, port, flow, addr = struct.unpack(
            format, self._sock.getsockopt(level, option, size))
        return port, flow, _socket.inet6_ntoa(addr)

    @option_error_decorator
    def setter(self, (port, flow, addr)):
        raw = struct.pack(format, size, consts.AddressFamily.IPv6, port, flow,
                          _socket.inet6_aton(mcast))
        self._sock.setsockopt(level, option, raw)