static uint64_t udp_len(arguments_t args, struct sk_buff const *skb) { if (eth_hdr(skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; struct udphdr _udp; const struct udphdr *udp; ip = skb_header_pointer(skb, skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_TCP) return NOTHING; udp = skb_header_pointer(skb, skb->mac_len + (ip->ihl<<2), sizeof(_udp), &_udp); if (udp == NULL) return NOTHING; return JUST(ntohs(udp->len)); } return NOTHING; }
static uint64_t tcp_hdrlen_(arguments_t args, struct sk_buff const *skb) { if (eth_hdr(skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; struct tcphdr _tcp; const struct tcphdr *tcp; ip = skb_header_pointer(skb, skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_TCP) return NOTHING; tcp = skb_header_pointer(skb, skb->mac_len + (ip->ihl<<2), sizeof(_tcp), &_tcp); if (tcp == NULL) return NOTHING; return JUST(tcp->doff * 4); } return NOTHING; }
static uint64_t tcp_dest(arguments_t args, SkBuff b) { if (eth_hdr(b.skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; struct tcphdr _tcp; const struct tcphdr *tcp; ip = skb_header_pointer(b.skb, b.skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_TCP) return NOTHING; tcp = skb_header_pointer(b.skb, b.skb->mac_len + (ip->ihl<<2), sizeof(_tcp), &_tcp); if (tcp == NULL) return NOTHING; return JUST(ntohs(tcp->dest)); } return NOTHING; }
static uint64_t icmp_code(arguments_t args, struct sk_buff const *skb) { if (eth_hdr(skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; struct icmphdr _icmp; const struct icmphdr *icmp; ip = skb_header_pointer(skb, skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_ICMP) return NOTHING; icmp = skb_header_pointer(skb, skb->mac_len + (ip->ihl<<2), sizeof(_icmp), &_icmp); if (icmp == NULL) return NOTHING; return JUST(icmp->code); } return NOTHING; }
void test_signed(void) { long long int a = JUST('x'); long long int b = JUST(0); long long int c = JUST(-1); long long int d = JUST(-2); long long int e = NOTHING; long long int f = JUST(0LL); long long int g = JUST(1LL); long long int h = JUST(-1LL); long long int i = NOTHING; assert(IS_JUST(a)); assert(IS_JUST(b)); assert(IS_JUST(c)); assert(IS_JUST(d)); assert(IS_NOTHING(e)); assert(IS_JUST(f)); assert(IS_JUST(g)); assert(IS_JUST(h)); assert(IS_NOTHING(i)); assert(FROM_JUST(char,a) == 'x'); assert(FROM_JUST(int, b) == 0); assert(FROM_JUST(int, c) == -1); assert(FROM_JUST(int, d) == -2); assert(FROM_JUST(long long int, f) == 0); assert(FROM_JUST(long long int, g) == 1); assert(FROM_JUST(long long int, h) == -1); }
static uint64_t ip_ttl(arguments_t args, struct qbuff * buff) { struct iphdr _iph; const struct iphdr *ip; ip = qbuff_ip_header_pointer(buff, 0, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; return (uint64_t)JUST(ip->ttl); }
static uint64_t ip_frag(arguments_t args, struct qbuff * buff) { struct iphdr _iph; const struct iphdr *ip; ip = qbuff_ip_header_pointer(buff, 0, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; return (uint64_t)JUST(be16_to_cpu(ip->frag_off)); }
static uint64_t ip_tos(arguments_t args, SkBuff skb) { if (eth_hdr(PFQ_SKB(skb))->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; ip = skb_header_pointer(PFQ_SKB(skb), skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; return JUST(ip->tos); } return NOTHING; }
static uint64_t ip_id(arguments_t args, SkBuff b) { if (eth_hdr(b.skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; ip = skb_header_pointer(b.skb, b.skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; return JUST(ntohs(ip->id)); } return NOTHING; }
static uint64_t ip_ttl(arguments_t args, struct sk_buff const *skb) { if (eth_hdr(skb)->h_proto == __constant_htons(ETH_P_IP)) { struct iphdr _iph; const struct iphdr *ip; ip = skb_header_pointer(skb, skb->mac_len, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; return JUST(ip->ttl); } return NOTHING; }
static uint64_t udp_len(arguments_t args, struct qbuff * buff) { struct iphdr _iph; const struct iphdr *ip; struct udphdr _udp; const struct udphdr *udp; ip = qbuff_ip_header_pointer(buff, 0, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_UDP) return NOTHING; udp = qbuff_ip_header_pointer(buff, (ip->ihl<<2), sizeof(_udp), &_udp); if (udp == NULL) return NOTHING; return (uint64_t)JUST(be16_to_cpu(udp->len)); }
static uint64_t tcp_hdrlen_(arguments_t args, struct qbuff * buff) { struct iphdr _iph; const struct iphdr *ip; struct tcphdr _tcp; const struct tcphdr *tcp; ip = qbuff_ip_header_pointer(buff, 0, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_TCP) return NOTHING; tcp = qbuff_ip_header_pointer(buff, (ip->ihl<<2), sizeof(_tcp), &_tcp); if (tcp == NULL) return NOTHING; return (uint64_t)JUST(tcp->doff * 4); }
static uint64_t icmp_code(arguments_t args, struct qbuff * buff) { struct iphdr _iph; const struct iphdr *ip; struct icmphdr _icmp; const struct icmphdr *icmp; ip = qbuff_ip_header_pointer(buff, 0, sizeof(_iph), &_iph); if (ip == NULL) return NOTHING; if (ip->protocol != IPPROTO_ICMP) return NOTHING; icmp = qbuff_ip_header_pointer(buff, (ip->ihl<<2), sizeof(_icmp), &_icmp); if (icmp == NULL) return NOTHING; return (uint64_t)JUST(icmp->code); }
void TextBase :: getBBox() { if(!m_font || m_theText.empty()) return; std::vector<gem::any>atoms; float x0, y0, z0, x1, y1, z1; x0 = y0 = z0 = x1 = y1 = z1 = 0.f; for(int i=0; i<m_theText.size(); i++) { float _x0, _y0, _z0, _x1, _y1, _z1; float dist = m_lineDist[i]*m_fontSize*m_dist*m_precision; m_font->BBox(m_theText[i].c_str(), _x0, _y0, _z0, _x1, _y1, _z1); Justification just=justifyFont(_x0, _y0, _z0, _x1, _y1, _z1, dist); #define JUST(var, offset) var = (var - offset) * just.scale JUST(_x0, just.width); JUST(_x1, just.width); JUST(_y0, just.height); JUST(_y1, just.height); JUST(_z0, just.depth); JUST(_z1, just.depth); atoms.clear(); atoms.push_back(i); atoms.push_back(_x0); atoms.push_back(_y0); atoms.push_back(_z0); atoms.push_back(_x1); atoms.push_back(_y1); atoms.push_back(_z1); m_infoOut.send("bboxline", atoms); // get the bounding box for all lines x0 = MIN(x0, _x0); x1 = MAX(x1, _x1); y0 = MIN(y0, _y0); y1 = MAX(y1, _y1); z0 = MIN(z0, _z0); z1 = MAX(z1, _z1); } atoms.clear(); atoms.push_back(x0); atoms.push_back(y0); atoms.push_back(z0); atoms.push_back(x1); atoms.push_back(y1); atoms.push_back(z1); m_infoOut.send("bbox", atoms); }
void test_unsigned(void) { long long int a_ = JUST(10U); long long int b_ = JUST(0U); long long int c_ = JUST((unsigned int)-1); long long int d_ = NOTHING; long long int f_ = JUST(0ULL); long long int g_ = JUST(1ULL); long long int h_ = JUST(-1ULL); long long int i_ = NOTHING; assert(IS_JUST(a_)); assert(IS_JUST(b_)); assert(IS_JUST(c_)); assert(IS_NOTHING(d_)); assert(IS_JUST(f_)); assert(IS_JUST(g_)); assert(IS_JUST(h_)); assert(IS_NOTHING(i_)); }
static uint64_t get_mark(arguments_t args, struct sk_buff const *skb) { return JUST(get_state(skb)); }
static uint64_t __get_mark(arguments_t args, SkBuff b) { return JUST(get_mark(b)); }
static uint64_t __get_state(arguments_t args, struct qbuff * buff) { return (uint64_t)JUST(get_state(buff)); }