It looks like c_char_Array_4 should have a value and a raw argument
which should be str thought I dont know much about ctypes.

http://stackoverflow.com/questions/4101536/multi-dimensional-char-array-array-of-strings-in-python-ctypes


Jason

On 18 November 2015 at 13:48, Brian May <[email protected]> wrote:
> Hello,
>
> I had the following line of code contributed to an open source project I
> accidentally become the lead developer for:
>
> ip = socket.inet_ntop(
>     pnl.af, (c_char * length).from_address(addressof(pnl.rdaddr)))
>
> For full context see:
> https://github.com/sshuttle/sshuttle/blob/cleanup/sshuttle/methods/pf.py#L114
>
> The purpose of this function the code is part of is to get the original
> destination of a TCP connection after it was redirected to the local
> process by the PF firewall on Mac OSX.
>
> I am trying to understand the above ctype code, and not really
> understanding what it does.
>
> The reason I ask is because the travis-ci PyPI test is failing on this
> line:
>
> TypeError: expected string, got c_char_Array_4 object
> full log: https://travis-ci.org/sshuttle/sshuttle/jobs/91560720
>
> The problem as far as I can work out appears to the the 2nd argument to
> socket.inet_ntop() - however I am having difficulties understanding what
> this code does. Have have the following documentation for from_address,
> but this only mentions one arguement:
>
> https://docs.python.org/2/library/ctypes.html#ctypes._CData.from_address
>
> I tried wrapping the argument in str(...) only that gives me a
> ValueError instead.
>
> How do I fix this?
>
> Thanks
> --
> Brian May <[email protected]>
> https://linuxpenguins.xyz/brian/
> _______________________________________________
> melbourne-pug mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/melbourne-pug
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to