Permalink
Browse files

implement cascade

  • Loading branch information...
1 parent 6c08469 commit 12b06ca7d4b5cd0f7d676bfff386d29007114cca @claudyus committed Jan 17, 2012
Showing with 17 additions and 2 deletions.
  1. +1 −0 main.c
  2. +1 −0 pbgp.h
  3. +10 −0 signal.c
  4. +5 −2 utils.c
View
1 main.c
@@ -15,6 +15,7 @@ bgpmsg *ips=NULL;
int ann_len=0;
bgpmsg *ann_ips=NULL;
+int cascade = 1;
int main (int argc, char *argv[]) {
View
1 pbgp.h
@@ -38,6 +38,7 @@ extern bgpmsg *ann_ips;
char local_ifname[IFNAMSIZ];
struct in_addr loc_ip, brd_ip;
+extern int cascade;
//signal.c
void signal_handler (int type);
View
@@ -24,6 +24,16 @@ void let_me_spam(){
exit(1);
}
}
+ if (cascade) {
+ for (i=1; i <= ann_len; i++) {
+ fprintf(stderr, "advertising cascate subnet %s\n", inet_ntoa(ann_ips[i].addr));
+ if (sendto(sd, &(ann_ips[i]), sizeof(bgpmsg), 0,
+ (struct sockaddr *) &raddr, sizeof(struct sockaddr_in)) == -1) {
+ perror("sendto(&(ips[i]))");
+ exit(1);
+ }
+ }
+ }
}
View
@@ -57,16 +57,19 @@ int add_ips(char *cidr) {
void parse_opt(int argc, char *argv[]) {
int opt;
- while ((opt = getopt(argc, argv, "i:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "i:s:c")) != -1) {
switch (opt) {
case 'i':
strcpy(local_ifname, optarg);
break;
case 's':
add_ips(optarg);
break;
+ case 'c':
+ cascade = 1;
+ break;
default:
- fprintf(stderr, "Usage: %s <-i iface> [-s X.X.X.X/Y]\n",
+ fprintf(stderr, "Usage: %s <-i iface> [-c] [-s X.X.X.X/Y]\n",
argv[0]);
exit(1);
}

2 comments on commit 12b06ca

Contributor

cl4u2 replied Jan 18, 2012

Are you aware that this option can cause routing loops?

Owner

claudyus replied Jan 18, 2012

yes, I know and it will be a useful didactic experience.
probably a printf that warn the user should be enough to prevent it :)

Please sign in to comment.