[MPlayer-dev-eng] [PATCH] ipv6 TCP support

Dave Lambley mplayer-dev-eng at dlambley.freeserve.co.uk
Mon Mar 24 17:20:35 CET 2003


Hi,

I have a patch that modifies network.c to support ipv6 connections.
connect2Server() has been modified to add an address family argument and
is renamed to connect2Server_with_af.

A wrapper function, connect2Server() has been added. It tries to connect
with IPv6 first, then IPv4. If both fail it returns the least worst
error code.

I've also added a function af2String(), to look up what address family
numbers really are, for printing status messages.

It doesn't change http proxying behaviour, so unless your proxy supports
IPv6, you'll want to turn it off.

There's not a lot round ATM to test it with. I've only tested it with
http. There was an mms server at

mms://media6.v6testbed.net/bbc1 

which used to work with a version of mplayer I hacked, but doesn't seem
to any more. I don't have a copy of Windows with IPv6 to try it with.

You can't give at an IPv6 address, only a name, as part of a URL. The
URL code will get confused by all the colons. I don't know if there is a
way round this, unless you assume there aren't port numbers in the URL.

IPv4's is fine if you were wondering.

It should work on machines without IPv6, so long as they have the header
files. I haven't made it provide wrapper code and #defines for those
without, but I'm a bit scared of configure! I've tested the code on
FreeBSD and Linux x86.

Cheers,
Dave

-------------- next part --------------
PyBmZm1wZWcKSW5kZXg6IGxpYm1wZGVtdXgvbmV0d29yay5jCj09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNT
IGZpbGU6IC9jdnNyb290L21wbGF5ZXIvbWFpbi9saWJtcGRlbXV4L25ldHdvcmsuYyx2CnJl
dHJpZXZpbmcgcmV2aXNpb24gMS43MQpkaWZmIC11IC1yMS43MSBuZXR3b3JrLmMKLS0tIGxp
Ym1wZGVtdXgvbmV0d29yay5jCTEzIEphbiAyMDAzIDAzOjEwOjE5IC0wMDAwCTEuNzEKKysr
IGxpYm1wZGVtdXgvbmV0d29yay5jCTI0IE1hciAyMDAzIDEwOjUzOjA2IC0wMDAwCkBAIC0x
NTEsNDkgKzE1MSw5MiBAQAogfQogI2VuZGlmCiAKLS8vIENvbm5lY3QgdG8gYSB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ogCQkJcmV0dXJuIC0xOwog
CQl9CkBAIC0yMzMsNyArMjc2LDI2IEBACiAJCW1wX21zZyhNU0dUX05FVFdPUkssTVNHTF9F
UlIsIkNvbm5lY3QgZXJyb3IgOiAlc1xuIixzdHJlcnJvcihlcnIpKTsKIAkJcmV0dXJuIC0x
OwogCX0KKwkKIAlyZXR1cm4gc29ja2V0X3NlcnZlcl9mZDsKK30KKworLy8gQ29ubmVjdCB0
byBhIHNlcnZlciB1c2luZyBhIFRDUCBjb25uZWN0aW9uCisvLyByZXR1cm4gLTIgZm9yIGZh
dGFsIGVycm9yLCBsaWtlIHVuYWJsZSB0byByZXNvbHZlIG5hbWUsIGNvbm5lY3Rpb24gdGlt
ZW91dC4uLgorLy8gcmV0dXJuIC0xIGlzIHVuYWJsZSB0byBjb25uZWN0IHRvIGEgcGFydGlj
dWxhciBwb3J0CisKKworaW50Citjb25uZWN0MlNlcnZlcihjaGFyICpob3N0LCBpbnQgIHBv
cnQpIHsKKwlpbnQgciwgczsKKwkKKwlyID0gY29ubmVjdDJTZXJ2ZXJfd2l0aF9hZihob3N0
LCBwb3J0LCBBRl9JTkVUNik7CQorCWlmIChyID4gLTEpIHJldHVybiByOworCQorCXMgPSBj
b25uZWN0MlNlcnZlcl93aXRoX2FmKGhvc3QsIHBvcnQsIEFGX0lORVQpOworCWlmIChzID09
IC0yKSByZXR1cm4gcjsKKwlyZXR1cm4gczsKKwkKIH0KIAogVVJMX3QqCg==


More information about the MPlayer-dev-eng mailing list