rase_sniff_demo.py

#!/usr/bin/python
#
# Copyright (C) 2009 rambla.be
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import rawsc
import rawsc.service
from rawsc import rase
import rawsc.rase.service
try:
  from xml.etree import cElementTree as ElementTree
except ImportError:
  try:
    import cElementTree as ElementTree
  except ImportError:
    from elementtree import ElementTree

USER = "XXX" # your username
PWD = "XXX" # your pwd
SERVER = "rase.str01.rambla.be"

try:
    # THIS DEMO retrieves a single 'sniff' feed for a given wowsdp resource
    client = rawsc.rase.service.RaseService(username=USER, password=PWD, server=SERVER)
#    feed = client.getSniffFeed(uri = "http://rase.str01.rambla.be/sniff/wowsdp/222"), or
    feed = client.getSniffFeedForWowsdp(id = "222")
    for e in feed.entry:
        print e.id.text
        print e.content.params.id.text
        print e.content.params.type.text
        print e.content.params.bytes.text
        print e.content.params.sniffed_bytes.text
        print e.content.params.src_ip.text
        print e.content.params.tgt_ip.text
        print e.content.params.src_port.text
        print e.content.params.tgt_port.text
        print e.content.params.protocol.text
        print e.content.params.datetime.text

except rawsc.service.Error, e:
    print "Error Response from server, contents = %s.\n" % str(e)
    error_dict = e[0] # error dict inside the first tuple elem
    print "status code : " + str(error_dict["status"]) + "\n"
    if error_dict.has_key("body"):
        print "error body : " + error_dict["body"] + "\n"
except rawsc.RawscException, e:
    print "RawscException caught, reason = %s.\n" % str(e)
except StandardError, e:
    print "StandardError caught, reason = %s.\n" % str(e)
except:
    print "unhandled exception caught\n"


Generated on Mon Mar 28 15:03:38 2011 for rawsc by  doxygen 1.5.3