static void send_snm_req(n2n_sn_t *sss, n2n_sock_t *sn, int req_communities, snm_comm_name_t *communities, int communities_num) { uint8_t pktbuf[N2N_PKT_BUF_SIZE]; size_t idx; n2n_sock_str_t sockbuf; snm_hdr_t hdr = { SNM_TYPE_REQ_LIST_MSG, 0, ++sss->seq_num }; n2n_SNM_REQ_t req = { 0, NULL }; if (sn_is_loopback(sn, sss->sn_port)) return; SET_S(hdr.flags); if (req_communities) { SET_C(hdr.flags); } else if (communities) { SET_N(hdr.flags); req.comm_num = communities_num & 0xFFFF; req.comm_ptr = communities; } idx = 0; encode_SNM_REQ(pktbuf, &idx, &hdr, &req); traceEvent(TRACE_INFO, "send SNM_REQ to %s", sock_to_cstr(sockbuf, sn)); sendto_sock(sss->sn_sock, sn, pktbuf, idx); }
/* We should cache the coefficients with the ctm.... */ int gx_matrix_to_fixed_coeff(const gs_matrix * pmat, register fixed_coeff * pfc, int max_bits) { gs_matrix ctm; int scale = -10000; int expt, shift; ctm = *pmat; pfc->skewed = 0; if (!is_fzero(ctm.xx)) { discard(frexp(ctm.xx, &scale)); } if (!is_fzero(ctm.xy)) { discard(frexp(ctm.xy, &expt)); if (expt > scale) scale = expt; pfc->skewed = 1; } if (!is_fzero(ctm.yx)) { discard(frexp(ctm.yx, &expt)); if (expt > scale) scale = expt; pfc->skewed = 1; } if (!is_fzero(ctm.yy)) { discard(frexp(ctm.yy, &expt)); if (expt > scale) scale = expt; } /* * There are two multiplications in fixed_coeff_mult: one involves a * factor that may have max_bits significant bits, the other may have * fixed_fraction_bits (_fixed_shift) bits. Ensure that neither one * will overflow. */ if (max_bits < fixed_fraction_bits) max_bits = fixed_fraction_bits; scale = sizeof(long) * 8 - 1 - max_bits - scale; shift = scale - _fixed_shift; if (shift > 0) { pfc->shift = shift; pfc->round = (fixed) 1 << (shift - 1); } else { pfc->shift = 0; pfc->round = 0; scale -= shift; } #define SET_C(c)\ if ( is_fzero(ctm.c) ) pfc->c = 0;\ else pfc->c = (long)ldexp(ctm.c, scale) SET_C(xx); SET_C(xy); SET_C(yx); SET_C(yy); #undef SET_C #ifdef DEBUG if (gs_debug_c('x')) { dlprintf6("[x]ctm: [%6g %6g %6g %6g %6g %6g]\n", ctm.xx, ctm.xy, ctm.yx, ctm.yy, ctm.tx, ctm.ty); dlprintf6(" scale=%d fc: [0x%lx 0x%lx 0x%lx 0x%lx] shift=%d\n", scale, pfc->xx, pfc->xy, pfc->yx, pfc->yy, pfc->shift); } #endif pfc->max_bits = max_bits; return 0; }