int as_path_get_first(struct adata *path, u32 *last_as) { u8 *p = path->data; if ((path->length == 0) || (p[0] != AS_PATH_SEQUENCE) || (p[1] == 0)) return 0; else { *last_as = get_as(p+2); return 1; } }
void as_path_format(struct adata *path, byte *buf, unsigned int size) { byte *p = path->data; byte *e = p + path->length; byte *end = buf + size - 16; int sp = 1; int l, isset; while (p < e) { if (buf > end) { strcpy(buf, " ..."); return; } isset = (*p++ == AS_PATH_SET); l = *p++; if (isset) { if (!sp) *buf++ = ' '; *buf++ = '{'; sp = 0; } while (l-- && buf <= end) { if (!sp) *buf++ = ' '; buf += bsprintf(buf, "%u", get_as(p)); p += BS; sp = 0; } if (isset) { *buf++ = ' '; *buf++ = '}'; sp = 0; } } *buf = 0; }
int as_path_contains(struct adata *path, u32 as, int min) { u8 *p = path->data; u8 *q = p+path->length; int num = 0; int i, n; while (p<q) { n = p[1]; p += 2; for(i=0; i<n; i++) { if (get_as(p) == as) if (++num == min) return 1; p += BS; } } return 0; }
int as_path_get_last(struct adata *path, u32 *orig_as) { int found = 0; u32 res = 0; u8 *p = path->data; u8 *q = p+path->length; int len; while (p<q) { switch (*p++) { case AS_PATH_SET: if (len = *p++) { found = 0; p += BS * len; } break; case AS_PATH_SEQUENCE: if (len = *p++) { found = 1; res = get_as(p + BS * (len - 1)); p += BS * len; } break; default: bug("as_path_get_first: Invalid path segment"); } } if (found) *orig_as = res; return found; }
double ConstantSet::get_as(std::string const &name, std::string const &sunits) const { UTUnit units(ut_system->parse(sunits)); return get_as(name, units); }
A_Zoomdlg::A_Zoomdlg(wxWindow* parent, wxWindowID id) : A_Spintextdialog(parent, id, _("Set Scale"), 2 , get_as(), _("Set scale (zoom) as percent:")) { }