Beispiel #1
0
void
packetio_send_discover(uint16_t thisSeqNum, bool_t sendAck)
{
    size_t			nbytes;
    topo_discover_header_t*	dhdr;

//                   buf,     src-addr,      dst-addr,            service-type,        g_opcode,         seq,       B'cast
    dhdr = fmt_base(g_txbuf, &g_hwaddr, &Etheraddr_broadcast, ToS_TopologyDiscovery, Opcode_Discover, thisSeqNum, TRUE);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t);

    dhdr->mh_gen = 0;
    if (sendAck)
    {
        dhdr->mh_numstations = htons(1);
        memcpy((void*)(dhdr+1),&uutMAC,sizeof(etheraddr_t));
        nbytes += sizeof(etheraddr_t);
    } else {
        dhdr->mh_numstations = 0;
    }

    nbytes += sizeof(topo_discover_header_t);

    tx_sendpacket(nbytes, thisSeqNum);

    IF_TRACED(TRC_PACKET)
        dbgprintf("tx_discover: seqnum = %d\n", thisSeqNum);
    END_TRACE
}
Beispiel #2
0
void
packetio_send_emit(uint16_t thisSeqNum, etheraddr_t* pDst, uint16_t emiteeCnt)
{
    size_t			nbytes;
    topo_emit_header_t	       *emithdr;
    topo_emitee_desc_t	       *pEmitee;
    topo_emitee_desc_t		emitee;
    etheraddr_t			OUI_hwaddr = {{0x00,0x0d,0x3a,0xd7,0xf1,0x50}};

    uint	count = emiteeCnt;

    IF_TRACED(TRC_PACKET)
        dbgprintf("tx_emit: seqnum = %d, dst= " ETHERADDR_FMT ", numEmitees=%d\n",
                   thisSeqNum, ETHERADDR_PRINT(pDst), count);
    END_TRACE

//					    buf,    src-addr, dst,  service-type,        g_opcode,       seq,     B'cast
    emithdr = (topo_emit_header_t*)fmt_base(g_txbuf,&g_hwaddr,pDst,ToS_TopologyDiscovery,Opcode_Emit,thisSeqNum,FALSE);
    emithdr->eh_numdescs = htons(emiteeCnt);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t) + sizeof(topo_emit_header_t);

    pEmitee = (topo_emitee_desc_t*)(emithdr+1);
    emitee.ed_type  = 0;
    emitee.ed_pause = 3;
    memcpy(&emitee.ed_src,&OUI_hwaddr,sizeof(etheraddr_t));
    memcpy(&emitee.ed_dst,&OUI_hwaddr,sizeof(etheraddr_t));

    for (; emiteeCnt>0; emiteeCnt--)
    {
        memcpy(pEmitee,&emitee,sizeof(topo_emitee_desc_t));
        pEmitee++;
        nbytes += sizeof(topo_emitee_desc_t);
    }
    tx_sendpacket(nbytes, thisSeqNum);
}
Beispiel #3
0
void
packetio_tx_qltlvResp(uint16_t thisSeqNum, tlv_desc_t *tlvDescr, size_t LtlvOffset)
{
    size_t      nbytes, sz_ltlv;

    if (g_topo_session == NULL)
    {
        warn("packetio_tx_qltlvResp: no mapping session when qLTLV was received. No response is being sent.\n");
        return;
    }
    fmt_base(g_txbuf, &g_hwaddr, &g_topo_session->ssn_mapper_real, ToS_TopologyDiscovery,
             Opcode_QueryLargeTlvResp, thisSeqNum, FALSE);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t);

    /* write the TLV, starting at the indicated offset */
    sz_ltlv = tlv_write_tlv( tlvDescr, &g_txbuf[nbytes], TOPO_MAX_FRAMESZ - nbytes, FALSE, LtlvOffset);
    if (sz_ltlv == 0)
    {   /* there was an error - the TLV could not be written for some reason  */
        g_txbuf[nbytes++] = 0; /* zero the two bytes of LTLV length and flag, */
        g_txbuf[nbytes++] = 0; /*  which will be the only things sent.        */
    }
    nbytes += sz_ltlv;

    tx_sendpacket(nbytes, thisSeqNum);

    IF_TRACED(TRC_PACKET)
        dbgprintf("tx_ack: %d -> " ETHERADDR_FMT "\n",
		thisSeqNum, ETHERADDR_PRINT(&g_topo_session->ssn_mapper_real));
    END_TRACE
}
Beispiel #4
0
void
packetio_tx_flat(void)
{
    topo_flat_header_t *fh;
    size_t nbytes;

    fh = fmt_base(g_txbuf, &g_hwaddr, &g_topo_session->ssn_mapper_real, ToS_TopologyDiscovery, Opcode_Flat,
		  g_sequencenum, FALSE /*g_topo_session->ssn_use_broadcast*/);

    fh->fh_ctc_bytes = htonl(g_ctc_bytes);
    fh->fh_ctc_packets = htons((uint16_t)g_ctc_packets);

                                          /*(doesn't work! padded to 8!)   sizeof(topo_flat_header_t)*/;
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t) + sizeof(uint32_t) + sizeof(uint16_t);

    tx_sendpacket(nbytes, g_sequencenum);

    IF_TRACED(TRC_PACKET)
	dbgprintf("tx_flat(len:" FMT_SIZET "+" FMT_SIZET "+" FMT_SIZET "): " FMT_UINT32 " bytes, " FMT_UINT32 \
	          " packets -> " ETHERADDR_FMT "\n",
                  sizeof(topo_ether_header_t),sizeof(topo_base_header_t),sizeof(topo_flat_header_t),
		  g_ctc_bytes, g_ctc_packets,
		  ETHERADDR_PRINT(&g_topo_session->ssn_mapper_real));
    END_TRACE
}
Beispiel #5
0
void
packetio_tx_hello(void)
{
    topo_hello_header_t *tx_hh;
    size_t nbytes;

    tx_hh = fmt_base(g_txbuf, &g_hwaddr, &Etheraddr_broadcast, ToS_TopologyDiscovery, Opcode_Hello, 0, TRUE);
    tx_hh->hh_gen = htons(g_generation);
    if (g_topo_session != NULL && g_topo_session->ssn_is_valid)
    {
        tx_hh->hh_curmapraddr = g_topo_session->ssn_mapper_real;
        tx_hh->hh_aprmapraddr = g_topo_session->ssn_mapper_current;
    } else {
        memset(&tx_hh->hh_curmapraddr, 0, sizeof(etheraddr_t));
        memset(&tx_hh->hh_aprmapraddr, 0, sizeof(etheraddr_t));
    }
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t) + sizeof(topo_hello_header_t);

    /* write the TLVs (reserving room for the EOP byte) */
    nbytes += tlv_write_info(&g_txbuf[nbytes], TOPO_MAX_FRAMESZ - nbytes - 1);

    /* now add the EOP */
    g_txbuf[nbytes] = 0;
    nbytes++;

    tx_sendpacket(nbytes, 0);

    IF_TRACED(TRC_PACKET)
	dbgprintf("tx_hello (%s): topo-ssn=%p gen=%d\n",
	          (g_topo_session && g_topo_session->ssn_is_valid)?"topo":"quick",
	          g_topo_session, ntohs(tx_hh->hh_gen));
    END_TRACE
}
Beispiel #6
0
void
packetio_send_reset(etheraddr_t* pDst)
{
    size_t			nbytes;

//             buf,    src-addr, dst-addr,      service-type,        g_opcode,   seq,  B'cast
    fmt_base(g_txbuf, &g_hwaddr, pDst,    ToS_TopologyDiscovery, Opcode_Reset,  0,   FALSE);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t);

    tx_sendpacket(nbytes, 0);

    IF_TRACED(TRC_PACKET)
        dbgprintf("tx_reset: dst= " ETHERADDR_FMT "\n", ETHERADDR_PRINT(pDst));
    END_TRACE
}
Beispiel #7
0
void
packetio_send_charge(uint16_t thisSeqNum, etheraddr_t* pDst)
{
    size_t			nbytes;

//             buf,    src-addr, dst-addr,      service-type,        g_opcode,     seq,      B'cast
    fmt_base(g_txbuf, &g_hwaddr, pDst,    ToS_TopologyDiscovery, Opcode_Charge, thisSeqNum, FALSE);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t);

    tx_sendpacket(nbytes, thisSeqNum);

    IF_TRACED(TRC_PACKET)
        dbgprintf("tx_charge: seqnum = %d, dst= " ETHERADDR_FMT "\n",
                   thisSeqNum, ETHERADDR_PRINT(pDst));
    END_TRACE
}
Beispiel #8
0
void
packetio_tx_ack(uint16_t thisSeqNum)
{
    size_t nbytes;

    fmt_base(g_txbuf, &g_hwaddr, &g_topo_session->ssn_mapper_real, ToS_TopologyDiscovery,
             Opcode_ACK, thisSeqNum, FALSE /*g_topo_session->ssn_use_broadcast*/);
    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t);

    tx_sendpacket(nbytes, thisSeqNum);

    IF_TRACED(TRC_PACKET)
	dbgprintf("tx_ack: %d -> " ETHERADDR_FMT "\n",
		thisSeqNum, ETHERADDR_PRINT(&g_topo_session->ssn_mapper_real));
    END_TRACE
}
Beispiel #9
0
void
packetio_tx_queryresp(void)
{
    topo_queryresp_header_t *qr;
    topo_recvee_desc_t *p;
    size_t nbytes, bytes_left;

    qr = fmt_base(g_txbuf, &g_hwaddr, &g_topo_session->ssn_mapper_real, ToS_TopologyDiscovery, Opcode_QueryResp,
		  g_sequencenum, FALSE /*g_topo_session->ssn_use_broadcast*/);

    nbytes = sizeof(topo_ether_header_t) + sizeof(topo_base_header_t) +
	sizeof(topo_queryresp_header_t);
    bytes_left = TOPO_MAX_FRAMESZ - nbytes;
    qr->qr_numdescs = 0;
    p = (topo_recvee_desc_t*)(qr + 1);

    while ((bytes_left >= sizeof(topo_recvee_desc_t)) &&
	   seeslist_dequeue(p))
    {
	p++;
	bytes_left -= sizeof(topo_recvee_desc_t);
	nbytes += sizeof(topo_recvee_desc_t);
	qr->qr_numdescs++;
    }

    /* any more to follow? */
    if (!seeslist_is_empty())
	qr->qr_numdescs |= 0x8000; /* set the M (more) bit */

    qr->qr_numdescs = htons(qr->qr_numdescs);

    tx_sendpacket(nbytes, g_sequencenum);

#ifdef  __DEBUG__
    IF_TRACED(TRC_PACKET)
	dbgprintf("tx_queryresp: -> " ETHERADDR_FMT "\n", ETHERADDR_PRINT(&g_topo_session->ssn_mapper_real));
    END_TRACE
#endif
}