 $$ LANGUAGE sql VOLATILE STRICT;
 
 -- STR2something
+CREATE OR REPLACE FUNCTION str2inet (a text) RETURNS inet AS $$
+DECLARE
+	r inet;
+BEGIN
+	BEGIN
+		RETURN a::inet;
+	EXCEPTION WHEN OTHERS THEN
+        RETURN NULL;
+	END;
+END;
+$$ LANGUAGE plpgsql IMMUTABLE STRICT;
 CREATE OR REPLACE FUNCTION str2boolean (a text) RETURNS boolean AS $$
 BEGIN
 	BEGIN

CREATE OR REPLACE FUNCTION cjoin (a_strs text[],a_delimiter text) RETURNS text AS $$
	SELECT array_to_string($1,$2);
$$ LANGUAGE sql IMMUTABLE STRICT;

-- LANG
CREATE OR REPLACE FUNCTION unlang (a_str text) RETURNS text AS $$

$$ LANGUAGE sql IMMUTABLE STRICT;

----------------------------
-- GET OBJ CLASS/STATE
----------------------------
CREATE OR REPLACE FUNCTION get_obj_class_id (a_obj_id integer) RETURNS integer AS $$
	SELECT class_id FROM obj WHERE obj_id=$1;
$$ LANGUAGE sql IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION get_obj_class (a_obj_id integer) RETURNS text AS $$
	SELECT name FROM ref WHERE obj_id=(SELECT class_id FROM obj WHERE obj_id=$1);
$$ LANGUAGE sql STABLE STRICT;
CREATE OR REPLACE FUNCTION get_obj_state_id (a_obj_id integer) RETURNS integer AS $$
DECLARE
	res integer;
BEGIN
