Beispiel #1
0
import os, sys, warnings
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

try:
    import errno
except ImportError:
    errno = None

EBADF = getattr(errno, 'EBADF', 9)
EINTR = getattr(errno, 'EINTR', 4)
__all__ = ['getfqdn', 'create_connection']
__all__.extend(os._get_exports_list(_socket))
_realsocket = socket
if sys.platform.lower().startswith('win'):
    errorTab = {}
    errorTab[10004] = 'The operation was interrupted.'
    errorTab[10009] = 'A bad file handle was passed.'
    errorTab[10013] = 'Permission denied.'
    errorTab[10014] = 'A fault occurred on the network??'
    errorTab[10022] = 'An invalid operation was attempted.'
    errorTab[10035] = 'The socket operation would block'
    errorTab[10036] = 'A blocking operation is already in progress.'
    errorTab[10048] = 'The network address is in use.'
    errorTab[10054] = 'The connection has been reset.'
    errorTab[10058] = 'The network has been shut down.'
    errorTab[10060] = 'The operation timed out.'
    errorTab[10061] = 'Connection refused.'
Beispiel #2
0
import _socket
from _socket import *

import os, sys, io

try:
    import errno
except ImportError:
    errno = None
EBADF = getattr(errno, 'EBADF', 9)
EAGAIN = getattr(errno, 'EAGAIN', 11)
EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)

__all__ = ["getfqdn", "create_connection"]
__all__.extend(os._get_exports_list(_socket))


_realsocket = socket

# WSA error codes
if sys.platform.lower().startswith("win"):
    errorTab = {}
    errorTab[10004] = "The operation was interrupted."
    errorTab[10009] = "A bad file handle was passed."
    errorTab[10013] = "Permission denied."
    errorTab[10014] = "A fault occurred on the network??" # WSAEFAULT
    errorTab[10022] = "An invalid operation was attempted."
    errorTab[10035] = "The socket operation would block"
    errorTab[10036] = "A blocking operation is already in progress."
    errorTab[10048] = "The network address is in use."
Beispiel #3
0
from pf.queue import *
from pf.filter import *

import pf.lib


__all__ = ['PFError',
           'PFStatus',
           'PFIface',
           'PFUid',
           'PFGid',
           'PFAddr',
           'PFPort',
           'PFRuleAddr',
           'PFPool',
           'PFRule',
           'PFRuleset',
           'PFStatePeer',
           'PFStateKey',
           'PFState',
           'PFTableAddr',
           'PFTable',
           'PFTStats',
           'ServiceCurve',
           'PFQueue',
           'PacketFilter']

import pf.constants
__all__.extend(os._get_exports_list(pf.constants))
del pf.constants
Beispiel #4
0
UDT4 library and py-udt4 wrapper is licensed under BSD.

--------------------------------------------------------------------------------
"""

__author__ = 'Christopher J. Hanks <*****@*****.**>'
__date__ = '12/18/2012'
__license__ = 'GPLv3'

import os

import _udt4
from _udt4 import *
import pyudt

__all__ = os._get_exports_list(_udt4) + \
         ['UdtSocket', 'dump_perfmon', 'Epoll']


def dump_perfmon(perf):
    """
    Prints out all of the perfmon features
    """
    print('''
+ TRACEINFO ----------------- +
| msTimeStamp         %Li 
| pktSentTotal        %Li
| pktRecvTotal        %Li 
| pktSndLossTotal     %i 
| pktRcvLossTotal     %i 
| pktRetransTotal     %i 
Beispiel #5
0
import _common
from _common import *

import os, sys
import enum

__all__ = [
    'DecodeError',
    'ip4',
    'macaddr',
    'sockaddr',
    'enum_convert',
]

__all__.extend(os._get_exports_list(_common))


class DecodeError(Exception):
    def __init__(self, msg):
        self.mod = __name__
        self.msg = msg

    def __str__(self):
        return '%s: %s' % (self.mod, self.msg)


class ip4(int):
    def __new__(cls, v=0, off=0):
        if isinstance(v, str):
            if not v:
Beispiel #6
0
"""

import os

__author__ = "Daniele Mazzocchio <*****@*****.**>"
__version__ = "0.1.4"

__OBSD_VERSION__ = "5.7"

from pf.exceptions import PFError
from pf.constants import *
from pf.status import *
from pf.state import *
from pf.table import *
from pf.rule import *
from pf.queue import *
from pf.filter import *

import pf.lib

__all__ = [
    'PFError', 'PFStatus', 'PFIface', 'PFUid', 'PFGid', 'PFAddr', 'PFPort',
    'PFRuleAddr', 'PFPool', 'PFRule', 'PFRuleset', 'PFStatePeer', 'PFStateKey',
    'PFState', 'PFTableAddr', 'PFTable', 'PFTStats', 'ServiceCurve', 'PFQueue',
    'PacketFilter'
]

import pf.constants
__all__.extend(os._get_exports_list(pf.constants))
del pf.constants
Beispiel #7
0
--------------------------------------------------------------------------------
"""

__author__  = 'Christopher J. Hanks <*****@*****.**>'
__date__    = '12/18/2012' 
__license__ = 'GPLv3' 


import os 

import _udt4
from   _udt4 import *
import udt4.pyudt

__all__ = os._get_exports_list(_udt4) + \
         ['UdtSocket', 'dump_perfmon', 'Epoll'] 


def dump_perfmon(perf):
    """
    Prints out all of the perfmon features
    """
    print(
'''
+ TRACEINFO ----------------- +
| msTimeStamp         %Li 
| pktSentTotal        %Li
| pktRecvTotal        %Li 
| pktSndLossTotal     %i 
| pktRcvLossTotal     %i 
Beispiel #8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
"""
def _get_exports_list(module):
    try:
        return list(module.__all__)
    except AttributeError:
        return [n for n in dir(module) if n[0] != '_']
"""

print(os._get_exports_list(sys))
Beispiel #9
0
# Wrapper module for _socket, providing some additional facilities
# implemented in Python.
"""\
This module provides socket operations and some related functions.
On Unix, it supports IP (Internet Protocol) and Unix domain sockets.
On other systems, it only supports IP. Functions specific for a
socket are available as methods of the socket object.
Functions:
socket() -- create a new socket object
fromfd() -- create a socket object from an open file descriptor [*]
gethostname() -- return the current hostname
gethostbyname() -- map a hostname to its IP number
gethostbyaddr() -- map an IP number or hostname to DNS info
getservbyname() -- map a service name and a protocol name to a port number
getprotobyname() -- mape a protocol name (e.g. 'tcp') to a number
ntohs(), ntohl() -- convert 16, 32 bit int from network to host byte order
htons(), htonl() -- convert 16, 32 bit int from host to network byte order
inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format
inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89)
ssl() -- secure socket layer support (only available if configured)
 [*] not available on all platforms!
Special objects:
SocketType -- type object for socket objects
error -- exception raised for I/O errors
Integer constants:
AF_INET, AF_UNIX -- socket domains (first argument to socket() call)
SOCK_STREAM, SOCK_DGRAM, SOCK_RAW -- socket types (second argument)
Many other constants may be defined; these may be used in calls to
the setsockopt() and getsockopt() methods.
"""