/*****************************************************************//**
 * \brief Send a packet on the specified port
 *
 * \param unit	[IN]	Unit number.
 * \param port	[IN]	Port number.
 * \param data	[IN]	Pointer to packet data.
 * \param len 	[IN]	Size of the packet data.
 *
 * \return OPENNSL_E_XXX     OpenNSL API return code
 ********************************************************************/
int example_pkt_send(int unit, int port, char *data, int len)
{
  opennsl_pkt_t *pkt;
  int rv;

  rv = opennsl_pkt_alloc(unit, len, 0, &pkt);

  if (OPENNSL_SUCCESS(rv))
  {
    rv = opennsl_pkt_memcpy(pkt, 0, data, len);
    if (!OPENNSL_SUCCESS(rv))
    {
      opennsl_pkt_free(unit, pkt);
      return rv;
    }

    OPENNSL_PBMP_PORT_SET(pkt->tx_pbmp, port);

    rv = opennsl_tx(unit, pkt, NULL);
    if (!OPENNSL_SUCCESS(rv))
    {
      opennsl_pkt_free(unit, pkt);
      return rv;
    }
  }
  opennsl_pkt_free(unit, pkt);
  return rv;
}
Beispiel #2
0
opennsl_pbmp_t BcmPort::getPbmp() {
  opennsl_pbmp_t pbmp;
  OPENNSL_PBMP_PORT_SET(pbmp, port_);
  return pbmp;
}