2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00

Add IPv6 support for OpenFlow, OVSDB, NetFlow, and sFlow.

Does not add IPv6 support for in-band control.

Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Nandan Nivgune <nandan.nivgune@calsoftinc.com>
Signed-off-by: Abhijit Bhopatkar <abhijit.bhopatkar@calsoftinc.com>
Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Arun Sharma
2014-02-06 16:04:05 -08:00
committed by Ben Pfaff
parent 978188b242
commit e731d71bf4
26 changed files with 773 additions and 443 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2010, 2012 Nicira, Inc.
# Copyright (c) 2010, 2012, 2014 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -177,24 +177,44 @@ def check_connection_completion(sock):
return errno.EAGAIN
def is_valid_ipv4_address(address):
try:
socket.inet_pton(socket.AF_INET, address)
except AttributeError:
try:
socket.inet_aton(address)
except socket.error:
return False
except socket.error:
return False
return True
def inet_parse_active(target, default_port):
address = target.split(":")
host_name = address[0]
if len(address) >= 2:
host_name = ":".join(address[0:-1]).lstrip('[').rstrip(']')
port = int(address[-1])
else:
if default_port:
port = default_port
else:
raise ValueError("%s: port number must be specified" % target)
host_name = address[0]
if not host_name:
raise ValueError("%s: bad peer name format" % target)
if len(address) >= 2:
port = int(address[1])
elif default_port:
port = default_port
else:
raise ValueError("%s: port number must be specified" % target)
return (host_name, port)
def inet_open_active(style, target, default_port, dscp):
address = inet_parse_active(target, default_port)
try:
sock = socket.socket(socket.AF_INET, style, 0)
is_addr_inet = is_valid_ipv4_address(address[0])
if is_addr_inet:
sock = socket.socket(socket.AF_INET, style, 0)
else:
sock = socket.socket(socket.AF_INET6, style, 0)
except socket.error, e:
return get_exception_errno(e), None