From 417b7f04afd6cf3642e6cb86df1e36a4ccafefbe Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Wed, 29 Sep 2010 14:28:21 +0000 Subject: [PATCH] Interface of the isc.net.check module git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac353@3068 e5f2f494-b856-4b98-b285-d166d9295462 --- configure.ac | 1 + src/lib/python/isc/Makefile.am | 2 +- src/lib/python/isc/net/Makefile.am | 5 +++++ src/lib/python/isc/net/__init__.py | 3 +++ src/lib/python/isc/net/check.py | 34 ++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/lib/python/isc/net/Makefile.am create mode 100644 src/lib/python/isc/net/__init__.py create mode 100644 src/lib/python/isc/net/check.py diff --git a/configure.ac b/configure.ac index a6bee26811..9b1fd1f50e 100644 --- a/configure.ac +++ b/configure.ac @@ -487,6 +487,7 @@ AC_CONFIG_FILES([Makefile src/lib/python/isc/config/tests/Makefile src/lib/python/isc/log/Makefile src/lib/python/isc/log/tests/Makefile + src/lib/python/isc/net/Makefile src/lib/python/isc/notify/Makefile src/lib/python/isc/notify/tests/Makefile src/lib/config/Makefile diff --git a/src/lib/python/isc/Makefile.am b/src/lib/python/isc/Makefile.am index 47927ce961..8035c20025 100644 --- a/src/lib/python/isc/Makefile.am +++ b/src/lib/python/isc/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = datasrc cc config log notify utils # Util +SUBDIRS = datasrc cc config log net notify utils # Util python_PYTHON = __init__.py diff --git a/src/lib/python/isc/net/Makefile.am b/src/lib/python/isc/net/Makefile.am new file mode 100644 index 0000000000..64705113fa --- /dev/null +++ b/src/lib/python/isc/net/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = tests + +python_PYTHON = __init__.py check.py + +pythondir = $(pyexecdir)/isc/net diff --git a/src/lib/python/isc/net/__init__.py b/src/lib/python/isc/net/__init__.py new file mode 100644 index 0000000000..223e9ea177 --- /dev/null +++ b/src/lib/python/isc/net/__init__.py @@ -0,0 +1,3 @@ +""" +Here are function and classes that are related to networking. +""" diff --git a/src/lib/python/isc/net/check.py b/src/lib/python/isc/net/check.py new file mode 100644 index 0000000000..c4f1aca0f8 --- /dev/null +++ b/src/lib/python/isc/net/check.py @@ -0,0 +1,34 @@ +# Copyright (C) 2010 CZ NIC +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM +# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL +# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING +# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" +Checking and parsing of ports and IP addresses. +""" + +def port_check(port): + """ + Takes a port as an int or string and checks if it is valid. It returns + the port as int. If it is not a valid port (the string doesn't contain + number or it is not in the valid range), it raises ValueError. + """ + pass + +def addr_check(addr): + """ + Checks and parses an IP address (either IPv4 or IPv6) and returns + the IPAddr object. It raises ValueError if the passed string is not + valid IP address. + """ + pass