Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 5f8c1bb

Browse files
Base OSPF code compiling inside Docker container
1 parent b90e17d commit 5f8c1bb

27 files changed

+69
-6338
lines changed

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:16.04
2+
3+
# Ubuntu 16.04 or earlier is required, as in more recent Linux kernel versions linux/ip.h and netinet/ip.h (included by
4+
# linux/if_tunnel.h) enter in conflict by defining data structure with same name 'iphdr'
5+
6+
WORKDIR /ospf
7+
8+
# DEBIAN_FRONTEND environement variable set to "noninteractive" to overcome tzdata prompt
9+
# tcl is used by the base OSPF implementation - Development package is required
10+
11+
RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install --yes python3 \
12+
python3-pip \
13+
iproute2 \
14+
iputils-ping \
15+
traceroute \
16+
tcl-dev
17+
18+
VOLUME /ospf

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# ospf_cplusplus_python_integration
2-
Experiments on integration of Python extensions with C++ OSPF base implementation
2+
Experiments on integration of Python extensions with C++ OSPF base implementation.
33

4-
The base code is the Release 2.0 of the ospfd routing software, created by John T. Moy, available at <http://www.ospf.org>.
4+
The base code is the Release 2.16 of the ospfd routing software created by John T. Moy, and described in the book [OSPF Complete Implementation](https://dl.acm.org/doi/book/10.5555/1481642).
5+
6+
Executed in Docker containers running Ubuntu 16.04.
7+
8+
## See also
9+
10+
* <http://www.ospf.org> - Original source code by John T. Moy, and respective patches
11+
12+
* <https://github.com/pfa/ospfd-diffs> - Most of required patches to run base code in Ubuntu 16.04

linux/linux.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ InMask masks[33] = {
228228
0xffffffffL
229229
};
230230

231-
bool get_prefix(char *prefix, InAddr &net, InMask &mask)
231+
bool get_prefix(const char *prefix, InAddr &net, InMask &mask)
232232

233233
{
234234
char *string;
235235
char netstr[16];
236236
int len;
237237

238-
if (!(string = index(prefix, '/')))
238+
if (!(string = index((char *) prefix, '/')))
239239
return(false);
240240
memcpy(netstr, prefix, string-prefix);
241241
netstr[string-prefix] = '\0';

linux/lsa_prn.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <sys/types.h>
2323
#include <sys/time.h>
2424
#include <unistd.h>
25-
#include <tcl.h>
25+
#include <tcl/tcl.h>
2626
#include <sys/socket.h>
2727
#include <netinet/in.h>
2828
#include <arpa/inet.h>

linux/machdep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ inline uns16 hton16(uns16 value)
9090
}
9191

9292
// External definitions
93-
extern "C" char *strptime(char *buf, const char *format, const struct tm *tm);
93+
//extern "C" char *strptime(char *buf, const char *format, const struct tm *tm);

linux/ospfd_browser.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <sys/types.h>
2323
#include <sys/time.h>
2424
#include <unistd.h>
25-
#include <tcl.h>
25+
#include <tcl/tcl.h>
2626
#include <sys/socket.h>
2727
#include <netinet/in.h>
2828
#include <arpa/inet.h>
@@ -1786,11 +1786,11 @@ char *page_footer = "\
17861786

17871787
char *error_page = "\
17881788
<table cellpadding=0 cellspacing=0 border=0 width=400>\n\
1789-
<center>
1789+
<center>\
17901790
<tr>\n\
17911791
<td align=\"center\">\n\
17921792
Data connection error:\n\
1793-
<br>
1793+
<br>\
17941794
$operation$: $errno$\n\
17951795
</td>\n\
17961796
</tr>\n\

linux/ospfd_linux.C

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <sys/time.h>
2424
#include <sys/resource.h>
2525
#include <unistd.h>
26-
#include <tcl.h>
26+
#include <tcl/tcl.h>
2727
#if LINUX_VERSION_CODE >= LINUX22
2828
#include <asm/types.h>
2929
#include <sys/socket.h>
@@ -61,7 +61,7 @@ LinuxOspfd *ospfd_sys;
6161
char buffer[MAX_IP_PKTSIZE];
6262

6363
// External declarations
64-
bool get_prefix(char *prefix, InAddr &net, InMask &mask);
64+
bool get_prefix(const char *prefix, InAddr &net, InMask &mask);
6565

6666
/* Signal handlers
6767
*/
@@ -497,16 +497,16 @@ LinuxOspfd::~LinuxOspfd()
497497
* application.
498498
*/
499499

500-
int SetRouterID(ClientData, Tcl_Interp *, int, char *argv[]);
501-
int SendGeneral(ClientData, Tcl_Interp *, int, char *argv[]);
502-
int SendArea(ClientData, Tcl_Interp *, int, char *argv[]);
503-
int SendAggregate(ClientData, Tcl_Interp *, int, char *argv[]);
504-
int SendHost(ClientData, Tcl_Interp *, int, char *argv[]);
505-
int SendInterface(ClientData, Tcl_Interp *, int, char *argv[]);
506-
int SendVL(ClientData, Tcl_Interp *, int, char *argv[]);
507-
int SendNeighbor(ClientData, Tcl_Interp *, int, char *argv[]);
508-
int SendExtRt(ClientData, Tcl_Interp *, int, char *argv[]);
509-
int SendMD5Key(ClientData, Tcl_Interp *, int, char *argv[]);
500+
int SetRouterID(ClientData, Tcl_Interp *, int, const char *argv[]);
501+
int SendGeneral(ClientData, Tcl_Interp *, int, const char *argv[]);
502+
int SendArea(ClientData, Tcl_Interp *, int, const char *argv[]);
503+
int SendAggregate(ClientData, Tcl_Interp *, int, const char *argv[]);
504+
int SendHost(ClientData, Tcl_Interp *, int, const char *argv[]);
505+
int SendInterface(ClientData, Tcl_Interp *, int, const char *argv[]);
506+
int SendVL(ClientData, Tcl_Interp *, int, const char *argv[]);
507+
int SendNeighbor(ClientData, Tcl_Interp *, int, const char *argv[]);
508+
int SendExtRt(ClientData, Tcl_Interp *, int, const char *argv[]);
509+
int SendMD5Key(ClientData, Tcl_Interp *, int, const char *argv[]);
510510

511511
/* Read the ospfd config out of the file /etc/ospfd.conf
512512
*/
@@ -813,7 +813,7 @@ void LinuxOspfd::add_direct(BSDPhyInt *phyp, InAddr addr, InMask mask)
813813
* or a name like "eth0".
814814
*/
815815

816-
bool LinuxOspfd::parse_interface(char *arg, in_addr &addr, BSDPhyInt *&phyp)
816+
bool LinuxOspfd::parse_interface(const char *arg, in_addr &addr, BSDPhyInt *&phyp)
817817

818818
{
819819
phyp = 0;
@@ -851,7 +851,7 @@ bool LinuxOspfd::parse_interface(char *arg, in_addr &addr, BSDPhyInt *&phyp)
851851
* been set.
852852
*/
853853

854-
int SetRouterID(ClientData, Tcl_Interp *, int, char *argv[])
854+
int SetRouterID(ClientData, Tcl_Interp *, int, const char *argv[])
855855

856856
{
857857
new_router_id = ntoh32(inet_addr(argv[1]));
@@ -865,7 +865,7 @@ int SetRouterID(ClientData, Tcl_Interp *, int, char *argv[])
865865
* If first time, create OSPF protocol instance.
866866
*/
867867

868-
int SendGeneral(ClientData, Tcl_Interp *, int, char *argv[])
868+
int SendGeneral(ClientData, Tcl_Interp *, int, const char *argv[])
869869

870870
{
871871
CfgGen m;
@@ -890,7 +890,7 @@ int SendGeneral(ClientData, Tcl_Interp *, int, char *argv[])
890890
/* Dowload configuration of a single area
891891
*/
892892

893-
int SendArea(ClientData, Tcl_Interp *, int, char *argv[])
893+
int SendArea(ClientData, Tcl_Interp *, int, const char *argv[])
894894

895895
{
896896
CfgArea m;
@@ -904,7 +904,7 @@ int SendArea(ClientData, Tcl_Interp *, int, char *argv[])
904904
return(TCL_OK);
905905
}
906906

907-
int SendAggregate(ClientData, Tcl_Interp *, int, char *argv[])
907+
int SendAggregate(ClientData, Tcl_Interp *, int, const char *argv[])
908908
{
909909
CfgRnge m;
910910
InAddr net;
@@ -921,7 +921,7 @@ int SendAggregate(ClientData, Tcl_Interp *, int, char *argv[])
921921
return(TCL_OK);
922922
}
923923

924-
int SendHost(ClientData, Tcl_Interp *, int, char *argv[])
924+
int SendHost(ClientData, Tcl_Interp *, int, const char *argv[])
925925
{
926926
CfgHost m;
927927
InAddr net;
@@ -943,7 +943,7 @@ int SendHost(ClientData, Tcl_Interp *, int, char *argv[])
943943
* for point-to-point addresses, the other end of the link.
944944
*/
945945

946-
int SendInterface(ClientData, Tcl_Interp *, int, char *argv[])
946+
int SendInterface(ClientData, Tcl_Interp *, int, const char *argv[])
947947

948948
{
949949
CfgIfc m;
@@ -999,7 +999,7 @@ int SendInterface(ClientData, Tcl_Interp *, int, char *argv[])
999999
return(TCL_OK);
10001000
}
10011001

1002-
int SendVL(ClientData, Tcl_Interp *, int, char *argv[])
1002+
int SendVL(ClientData, Tcl_Interp *, int, const char *argv[])
10031003
{
10041004
CfgVL m;
10051005

@@ -1016,7 +1016,7 @@ int SendVL(ClientData, Tcl_Interp *, int, char *argv[])
10161016
return(TCL_OK);
10171017
}
10181018

1019-
int SendNeighbor(ClientData, Tcl_Interp *, int, char *argv[])
1019+
int SendNeighbor(ClientData, Tcl_Interp *, int, const char *argv[])
10201020
{
10211021
CfgNbr m;
10221022

@@ -1027,7 +1027,7 @@ int SendNeighbor(ClientData, Tcl_Interp *, int, char *argv[])
10271027
return(TCL_OK);
10281028
}
10291029

1030-
int SendExtRt(ClientData, Tcl_Interp *, int, char *argv[])
1030+
int SendExtRt(ClientData, Tcl_Interp *, int, const char *argv[])
10311031
{
10321032
CfgExRt m;
10331033
InAddr net;
@@ -1049,7 +1049,7 @@ int SendExtRt(ClientData, Tcl_Interp *, int, char *argv[])
10491049
return(TCL_OK);
10501050
}
10511051

1052-
int SendMD5Key(ClientData, Tcl_Interp *, int, char *argv[])
1052+
int SendMD5Key(ClientData, Tcl_Interp *, int, const char *argv[])
10531053
{
10541054
CfgAuKey m;
10551055
in_addr addr;

linux/ospfd_linux.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class LinuxOspfd : public Linux {
7070
void rtentry_prepare(InAddr, InMask, MPath *mpp);
7171
void add_direct(class BSDPhyInt *, InAddr, InMask);
7272
int get_phyint(InAddr);
73-
bool parse_interface(char *, in_addr &, BSDPhyInt * &);
73+
bool parse_interface(const char *, in_addr &, BSDPhyInt * &);
7474
void raw_receive(int fd);
7575
void netlink_receive(int fd);
7676
void process_routerid_change();
@@ -85,12 +85,16 @@ class LinuxOspfd : public Linux {
8585
*/
8686

8787
class BSDPhyInt : public AVLitem {
88-
char *phyname;
88+
public:
89+
inline int phyint();
8990
InAddr addr;
90-
short flags;
9191
InMask mask;
92-
InAddr dstaddr; // Other end of p-p link
9392
int mtu;
93+
short flags;
94+
95+
private:
96+
char *phyname;
97+
InAddr dstaddr; // Other end of p-p link
9498
bool tunl;
9599
int vifno;
96100
InAddr tsrc; // Tunnel endpoint addresses
@@ -100,7 +104,6 @@ class BSDPhyInt : public AVLitem {
100104
friend class LinuxOspfd;
101105
friend int SendInterface(void *,struct Tcl_Interp *, int,char *[]);
102106
friend int SendMD5Key(void *, Tcl_Interp *, int, char *argv[]);
103-
inline int phyint();
104107
};
105108

106109
inline BSDPhyInt::BSDPhyInt(int index) : AVLitem(index, 0)

linux/ospfd_mon.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <sys/types.h>
2323
#include <sys/time.h>
2424
#include <unistd.h>
25-
#include <tcl.h>
25+
#include <tcl/tcl.h>
2626
#include <sys/socket.h>
2727
#include <netinet/in.h>
2828
#include <arpa/inet.h>

ospf_sim/icmp.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)