Exemplo n.º 1
0
MMD_Polynomial::MMD_Polynomial( CParseDsrSymbolTable& _smbtable,
								enum CDsrDataTypes nested_type, 
								long term_c ) :
	MMD_Object( 
		_smbtable, 
		_smbtable.getTypeTable().makeDataTypeNode( 
			new CDsrDataType_Polynomial( 
				_smbtable.getTypeTable().makeDataTypeNode( nested_type ) 
			) ) ),
	term_pow( 8, 0, 8 ), term_coef( 8, 0, 8 )
{
	var_name = _T("");
	if( term_c > 0 )
	{
		long i;
		CDSRInteger iV( 0 );
		CDSRReal rV( 0 );
		CDSRComplex cV( 0 );
		switch( getType() )
		{
		case DSRDATA_TYPE_INTEGER:
			for( i = 0; i < term_c; i++ )
			{
				UniWord uw( iV );
				term_pow.Add( uw );
				term_coef.Add( uw );
			}
			break;
		case DSRDATA_TYPE_REAL:
			for( i = 0; i < term_c; i++ )
			{
				UniWord uw1( iV );
				UniWord uw2( rV );
				term_pow.Add( uw1 );
				term_coef.Add( uw2 );
			}
			break;
		case DSRDATA_TYPE_COMPLEX:
			for( i = 0; i < term_c; i++ )
			{
				UniWord uw1( iV );
				UniWord uw2( cV );
				term_pow.Add( uw1 );
				term_coef.Add( uw2 );
			}
			break;
		default:
			break;
		}
	}
	max_pow = -1;
	is_normal = 0;
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////
// find the edge with the highest weight in the path between
// u and v
//////////////////////////////////////////////////////////////
bin_data pathQuery(node* v, node* u)
{
  cluster *clv,*clvp;//cluster for v, and parent cluster for v
  cluster *clu,*clup;//cluster for u, and parent cluster for u
  
  result rU(&emptyDat);
  result rV(&emptyDat);

  clv = v->data;
  clu = u->data;

  clvp = clv->parent;
  clup = clu->parent;

  while(clup != clvp)  {
      // Base case. 
      deprintf(".");
      deprintf("clvp = %d\n", clvp->id);
      deprintf("clup = %d\n", clup->id);

      // "Recursive" (loopersive) case
      if(clvp->height <= clup->height) {
	processCluster(clvp,clv,&rV);
	clv  = clvp;
	clvp = clvp->parent;      
	if(!clvp) return emptyDat;
      }
      else {
	processCluster(clup,clu,&rU);
	clu  = clup;
	clup = clup->parent;	
	if(!clup) return emptyDat;
      }
    }//while
 
  int van = clu -> getVanishing(); 

  return *(compare (rU.find (van), rV.find (van)));

}
Exemplo n.º 3
0
/* UA/UDP DISSECTOR */
static void _dissect_uaudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                           e_ua_direction direction)
{
    gint        offset = 0;
    guint8      opcode;
    proto_item *uaudp_item;
    proto_tree *uaudp_tree;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "UAUDP");

    /* get the identifier; it means operation code */
    opcode = tvb_get_guint8(tvb, offset);
    offset += 1;

    ua_tap_info.opcode = opcode;
    ua_tap_info.expseq = 0;
    ua_tap_info.sntseq = 0;

    /* print in "INFO" column the type of UAUDP message */
    col_add_fstr(pinfo->cinfo,
                COL_INFO,
                "%s",
                val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_item = proto_tree_add_protocol_format(tree, proto_uaudp, tvb, 0, 5,
                            "Universal Alcatel/UDP Encapsulation Protocol, %s",
                            val_to_str_ext(opcode, &uaudp_opcode_str_ext, "unknown (0x%02x)"));

    uaudp_tree = proto_item_add_subtree(uaudp_item, ett_uaudp);

    /* print the identifier */
    proto_tree_add_uint(uaudp_tree, hf_uaudp_opcode, tvb, 0, 1, opcode);

    switch(opcode)
    {
    case UAUDP_CONNECT:
    {
        if (!tree)
            break;
        while (tvb_offset_exists(tvb, offset))
        {
            guint8 T = tvb_get_guint8(tvb, offset+0);
            guint8 L = tvb_get_guint8(tvb, offset+1);

            switch(T)
            {
            case UAUDP_CONNECT_VERSION:
                rV(uaudp_tree, &hf_uaudp_version        , tvb, offset, L);
                break;
            case UAUDP_CONNECT_WINDOW_SIZE:
                rV(uaudp_tree, &hf_uaudp_window_size    , tvb, offset, L);
                break;
            case UAUDP_CONNECT_MTU:
                rV(uaudp_tree, &hf_uaudp_mtu            , tvb, offset, L);
                break;
            case UAUDP_CONNECT_UDP_LOST:
                rV(uaudp_tree, &hf_uaudp_udp_lost       , tvb, offset, L);
                break;
            case UAUDP_CONNECT_UDP_LOST_REINIT:
                rV(uaudp_tree, &hf_uaudp_udp_lost_reinit, tvb, offset, L);
                break;
            case UAUDP_CONNECT_KEEPALIVE:
                rV(uaudp_tree, &hf_uaudp_keepalive      , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_IP_TOS:
                rV(uaudp_tree, &hf_uaudp_qos_ip_tos     , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_8021_VLID:
                rV(uaudp_tree, &hf_uaudp_qos_8021_vlid  , tvb, offset, L);
                break;
            case UAUDP_CONNECT_QOS_8021_PRI:
                rV(uaudp_tree, &hf_uaudp_qos_8021_pri   , tvb, offset, L);
                break;
            }
            offset += (2 + L);
        }
        break;
    }

    case UAUDP_NACK:
    {
        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset,
                    2,
                    tvb_get_ntohs(tvb, offset));
        break;
    }

    case UAUDP_DATA:
    {
        int datalen;

        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_expseq,
                    tvb,
                    offset+0,
                    2,
                    tvb_get_ntohs(tvb, offset+0));

        proto_tree_add_uint(uaudp_tree,
                    hf_uaudp_sntseq,
                    tvb,
                    offset+2,
                    2,
                    tvb_get_ntohs(tvb, offset+2));

        ua_tap_info.expseq = hf_uaudp_expseq;
        ua_tap_info.sntseq = hf_uaudp_sntseq;

        offset  += 4;
        datalen  = tvb_reported_length(tvb) - offset;

        /* if there is remaining data, call the UA dissector */
        if (datalen > 0)
        {
            if (direction == SYS_TO_TERM)
                call_dissector(ua_sys_to_term_handle,
                           tvb_new_subset(tvb, offset, datalen, datalen),
                           pinfo,
                           tree);
            else if (direction == TERM_TO_SYS)
                call_dissector(ua_term_to_sys_handle,
                           tvb_new_subset(tvb, offset, datalen, datalen),
                           pinfo,
                           tree);
            else {
                /* XXX: expert ?? */
                col_set_str(pinfo->cinfo,
                            COL_INFO,
                            "Data - Couldn't resolve direction. Check UAUDP Preferences.");
            }
            ua_tap_info.expseq = hf_uaudp_expseq;
        }
        else {
            /* print in "INFO" column */
            col_set_str(pinfo->cinfo,
                        COL_INFO,
                        "Data ACK");
        }
        break;
    }
    default:
        break;
    }
#if 0
    tap_queue_packet(uaudp_tap, pinfo, &ua_tap_info);
#endif
}