📄 rsvp-objects.cc
字号:
/* * Copyright (c) 1998 The University of Bonn * All rights reserved. * * Permission to use and copy this software in source and binary forms * is hereby granted, provided that the above copyright notice, this * paragraph and the following disclaimer are retained in any copies * of any part of this software and that the University of Bonn is * acknowledged in all documentation pertaining to any such copy * or derivative work. The name of the University of Bonn may not * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL * THE UNIVERSITY OF BONN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */#include "rsvp-objects.h"#include <stdio.h>void RSVPobject::dump_object() { printf(" RSVPobject: Class-Num: %d C-Type: %d Conlength: %d Length: %d\n", header->classnum, header->ctype, header->conlength, header->length);}SESSION::SESSION(nsaddr_t dst, char fl, int f, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (!ip6) { header->ctype = 1; header->length = 12; } else { header->ctype = 2; header->length = 24; } con->fid = f; con->dest = dst; header->classnum = 1; header->conlength = cl;}SESSION::SESSION(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void SESSION::dump_object() { RSVPobject::dump_object(); printf(" SESSION: dest: %d fid: %d\n", con->dest, con->fid);}RSVP_HOP::RSVP_HOP(nsaddr_t h, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (!ip6) { header->ctype = 1; header->length = 12; } else { header->ctype = 2; header->length = 24; } con->hop = h; header->classnum = 3; header->conlength = cl;}RSVP_HOP::RSVP_HOP(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void RSVP_HOP::dump_object() { RSVPobject::dump_object(); printf(" RSVP_HOP: hop: %d\n", con->hop);}TIME_VALUES::TIME_VALUES(double refresh) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); header->ctype = 1; header->length = 8; con->r = refresh; header->classnum = 5; header->conlength = cl;}TIME_VALUES::TIME_VALUES(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void TIME_VALUES::dump_object() { RSVPobject::dump_object(); printf(" TIME_VALUES: r: %f\n", con->r);}ERROR_SPEC::ERROR_SPEC(nsaddr_t node, char fl, char code, int value, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (ip6) { header->ctype = 2; header->length = 24; } else { header->ctype = 1; header->length = 12; } con->errnode = node; con->flags = fl; con->errcode = code; con->errvalue = value; header->classnum = 6; header->conlength = cl;}ERROR_SPEC::ERROR_SPEC(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void ERROR_SPEC::dump_object() { RSVPobject::dump_object(); printf(" ERROR_SPEC: node: %d flags: %d code: %d value: %d\n", con->errnode, con->flags, con->errcode, con->errvalue);}STYLE::STYLE(long st) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); header->ctype = 1; header->length = 8; con->style = st; header->classnum = 8; header->conlength = cl;}STYLE::STYLE(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void STYLE::dump_object() { RSVPobject::dump_object(); printf(" STYLE: style: %ld\n", con->style);}FLOWSPEC::FLOWSPEC(double r, long s) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); header->ctype = 2; header->length = 36; con->rate = r; con->size = s; header->classnum = 9; header->conlength = cl;}FLOWSPEC::FLOWSPEC(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void FLOWSPEC::dump_object() { RSVPobject::dump_object(); printf(" FLOWSPEC: rate: %3.3f size: %ld\n", con->rate, con->size);}FILTER_SPEC::FILTER_SPEC(nsaddr_t src, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (ip6) { header->ctype = 3; header->length = 24; } else { header->ctype = 1; header->length = 12; } con->addr = src; header->classnum = 10; header->conlength = cl;}FILTER_SPEC::FILTER_SPEC(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void FILTER_SPEC::dump_object() { RSVPobject::dump_object(); printf(" FILTER_SPEC : addr: %ld\n", con->addr);}SENDER_TEMPLATE::SENDER_TEMPLATE(nsaddr_t src, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (ip6) { header->ctype = 3; header->length = 24; } else { header->ctype = 1; header->length = 12; } con->addr = src; header->classnum = 11; header->conlength = cl;}SENDER_TEMPLATE::SENDER_TEMPLATE(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void SENDER_TEMPLATE::dump_object() { RSVPobject::dump_object(); printf(" SENDER_TEMPLATE: addr: %ld\n", con->addr);}SENDER_TSPEC::SENDER_TSPEC(double r, long s) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); header->ctype = 2; header->length = 36; con->rate = r; con->size = s; header->classnum = 12; header->conlength = cl;}SENDER_TSPEC::SENDER_TSPEC(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void SENDER_TSPEC::dump_object() { RSVPobject::dump_object(); printf(" SENDER_TSPEC: rate: %3.3f size: %ld\n", con->rate, con->size);}RESV_CONFIRM::RESV_CONFIRM(nsaddr_t a, char ip6) { int cl; cl = sizeof(struct objheader) + sizeof(struct construct); contents = new unsigned char[cl]; header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader)); if (ip6) { header->ctype = 2; header->length = 20; } else { header->ctype = 1; header->length = 8; } con->addr = a; header->classnum = 15; header->conlength = cl;}RESV_CONFIRM::RESV_CONFIRM(unsigned char *cont) { header = (objheader *)cont; contents = new unsigned char[header->conlength]; memcpy(contents, cont, header->conlength); header = (objheader *)contents; con = (construct *)(contents + sizeof(struct objheader));}void RESV_CONFIRM::dump_object() { RSVPobject::dump_object(); printf(" RESV_CONFIRM: addr: %ld\n", con->addr);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -