#!/usr/bin/env python

import socket
import sys
import os
import time

if len(sys.argv) != 7 and len(sys.argv) != 9:
	print "./iri.py POX B IPv4 127.0.0.1 MAC 00:11:22:33:44:55"
	sys.exit(1);

if sys.argv[2] == "B":
	iritype = "BEGIN"
	description = "Prihlasenie uzivatela"
elif sys.argv[2] == "C":
	iritype = "CONTINUE"
	description = "Aktivita uzivatela"
elif sys.argv[2] == "E":
	iritype = "END"
	description = "Odhlasenie uzivatela"
else:
	iritype = "REPORT"
	description = "Report"

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect('/tmp/iricol')

if len(sys.argv) == 7:
	s.send("('"+sys.argv[1]+"', " +  str(time.time()) + ", '" + iritype + "', '" + description + "', [('"+sys.argv[3]+"', '"+sys.argv[4]+"'), ('"+sys.argv[5]+"', '"+sys.argv[6]+"')])\n")
elif len(sys.argv) == 9:
	s.send("('"+sys.argv[1]+"', " +  str(time.time()) + ", '" + iritype + "', '" + description + "', [('"+sys.argv[3]+"', '"+sys.argv[4]+"'), ('"+sys.argv[5]+"', '"+sys.argv[6]+"'), ('"+sys.argv[7]+"', '"+sys.argv[8]+"')])\n")
#s.send("('WIS', " +  str(time.time()) + ", '" + iritype + "', '" + description + "', [('IPv4', '192.168.1.10'), ('MAC', '00:11:22:33:44:ff')])\n")
#time.sleep(3)
#s.send("('WIS', " +  str(time.time()) + ", '" + iritype + "', '" + description + "', [('IPv4', '" + sys.argv[2] + "'), ('WIS login', '" + sys.argv[3] + "')])\n")
#s.send("('WIS', " +  str(time.time()) + ", '" + iritype + "', '" + description + "', [('IPv4', '192.168.1.1'), ('MAC', '00:11:22:33:44:55')])\n")
s.close()
