(tm_, client, content_block, hostname, t_xml, dcn=None, eh=None,
             url="/inbox/", port=None)
Generate and send a TAXII message.

    :param tm_: The TAXII version imported that we should use.
    :type tm_: TAXII message class.
    :param client: The TAXII client to use.
    :type client: TAXII Client.
    :param content_block: The content block to use.
    :type content_block: TAXII Content Block
    :param hostname: The TAXII server hostname to connect to.
    :type hostname: str
    :param t_xml: The TAXII XML Schema version we used.
    :type t_xml: str
    :param dcn: Destination Collection Names we are using.
    :type dcn: list
    :param eh: Extended Headers to use.
    :type eh: dict
    :param url: The URL suffix to locate the inbox service.
    :type url: str
    :param port: The TAXII server port to connect to.
    :type port: str
    :returns: tuple (response, taxii_message) or (exception message)
Generate and send a TAXII message.
Generate and send a TAXII message .
def gen_send(tm_, client, content_block, hostname, t_xml, dcn=None, eh=None,
             url="/inbox/", port=None):
    """
    Generate and send a TAXII message.

    :param tm_: The TAXII version imported that we should use.
    :type tm_: TAXII message class.
    :param client: The TAXII client to use.
    :type client: TAXII Client.
    :param content_block: The content block to use.
    :type content_block: TAXII Content Block
    :param hostname: The TAXII server hostname to connect to.
    :type hostname: str
    :param t_xml: The TAXII XML Schema version we used.
    :type t_xml: str
    :param dcn: Destination Collection Names we are using.
    :type dcn: list
    :param eh: Extended Headers to use.
    :type eh: dict
    :param url: The URL suffix to locate the inbox service.
    :type url: str
    :param port: The TAXII server port to connect to.
    :type port: str
    :returns: tuple (response, taxii_message) or (exception message)
    """

    # Create inbox message
    if dcn:
        inbox_message = tm_.InboxMessage(
            message_id = tm_.generate_message_id(),
            content_blocks = [content_block],
            destination_collection_names = dcn
        )
    elif eh:
        inbox_message = tm.InboxMessage(
            message_id = tm.generate_message_id(),
            content_blocks = [content_block],
            extended_headers = eh
        )
    else:
        #TODO: return better
        return None

    # send inbox message via TAXII service
    try:
        response = client.callTaxiiService2(
            hostname,
            url,
            t_xml,
            inbox_message.to_xml(),
            port
        )
        taxii_message = t.get_message_from_http_response(response,
                                                         inbox_message.message_id)
        return (response, taxii_message)
    # can happen if 'hostname' is reachable, but is not a TAXII server, etc
    except Exception as e:
        return (str(e),)
def gen_send ( tm_ , client , content_block , hostname , t_xml , dcn = None , eh = None , url = "/inbox/" , port = None ) : # Create inbox message if dcn : inbox_message = tm_ . InboxMessage ( message_id = tm_ . generate_message_id ( ) , content_blocks = [ content_block ] , destination_collection_names = dcn ) elif eh : inbox_message = tm . InboxMessage ( message_id = tm . generate_message_id ( ) , content_blocks = [ content_block ] , extended_headers = eh ) else : #TODO: return better return None # send inbox message via TAXII service try : response = client . callTaxiiService2 ( hostname , url , t_xml , inbox_message . to_xml ( ) , port ) taxii_message = t . get_message_from_http_response ( response , inbox_message . message_id ) return ( response , taxii_message ) # can happen if 'hostname' is reachable, but is not a TAXII server, etc except Exception as e : return ( str ( e ) , )