Return a dict containing information on all of the running TCP connections (currently linux and solaris only)

    .. versionchanged:: 2015.8.4

        Added support for SunOS

    CLI Example:

    .. code-block:: bash

        salt '*' network.active_tcp

def active_tcp():
    '''
    Return a dict containing information on all of the running TCP connections (currently linux and solaris only)

    .. versionchanged:: 2015.8.4

        Added support for SunOS

    CLI Example:

    .. code-block:: bash

        salt '*' network.active_tcp
    '''
    if __grains__['kernel'] == 'Linux':
        return salt.utils.network.active_tcp()
    elif __grains__['kernel'] == 'SunOS':
        # lets use netstat to mimic linux as close as possible
        ret = {}
        for connection in _netstat_sunos():
            if not connection['proto'].startswith('tcp'):
                continue
            if connection['state'] != 'ESTABLISHED':
                continue
            ret[len(ret)+1] = {
                'local_addr': '.'.join(connection['local-address'].split('.')[:-1]),
                'local_port': '.'.join(connection['local-address'].split('.')[-1:]),
                'remote_addr': '.'.join(connection['remote-address'].split('.')[:-1]),
                'remote_port': '.'.join(connection['remote-address'].split('.')[-1:])
            }
        return ret
    elif __grains__['kernel'] == 'AIX':
        # lets use netstat to mimic linux as close as possible
        ret = {}
        for connection in _netstat_aix():
            if not connection['proto'].startswith('tcp'):
                continue
            if connection['state'] != 'ESTABLISHED':
                continue
            ret[len(ret)+1] = {
                'local_addr': '.'.join(connection['local-address'].split('.')[:-1]),
                'local_port': '.'.join(connection['local-address'].split('.')[-1:]),
                'remote_addr': '.'.join(connection['remote-address'].split('.')[:-1]),
                'remote_port': '.'.join(connection['remote-address'].split('.')[-1:])
            }
        return ret
    else:
        return {}