Skip to content

Commit

Permalink
MAC's hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddavo committed Aug 15, 2016
1 parent 6edc26b commit d438e51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Interface2.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ http://ddavo.me</property>
<object class="GtkToolButton" id="toolbutton3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">toolbutton3</property>
<property name="label" translatable="yes">Router</property>
<property name="use_underline">True</property>
<property name="icon_name">network-server</property>
</object>
Expand Down
12 changes: 6 additions & 6 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def clicked_on_grid(self, widget, event, *args):
if self.searchforobject(self.gridparser(event.x, self.wres), self.gridparser(event.y, self.hres)) == False:
if clicked == 1:
push_elemento("Clicked: " + str(clicked) + " bttnclicked: " + str(bttnclicked))
if bttnclicked == "toolbutton3":
if bttnclicked == "Router":
Router(self.gridparser(event.x, self.wres), self.gridparser(event.y, self.hres))
push_elemento("Creado objeto router")
elif bttnclicked == "toolbutton4":
Expand Down Expand Up @@ -965,13 +965,13 @@ def packet_received(self, pck):
ttlnew = "{0:08b}".format(ttl-1)
pck.str = "".join(( pck.str[:64], ttlnew, pck.str[72:] ))

print("self.macdir",self.macdir[0], int("{0:0112b}".format(pck.frame)[6*8+1:6*16+1],2))
print("self.macdir",int(self.macdir), int("{0:0112b}".format(pck.frame)[6*8+1:6*16+1],2))
print("TTL:", int(pck.str[64:72],2), pck.str[64:72])

print("Soy un switch y mi deber es entregar el paquete a {}".format(int(macd,2)))
dic = {}
for i in self.connections:
dic[i.macdir[0]] = i
dic[int(i.macdir)] = i
print("Connections MAC's:", dic)

#Cambiamos los bits de macs
Expand All @@ -990,7 +990,7 @@ def packet_received(self, pck):
tmplst = self.connections[:] #Crea una nueva copia de la lista
print(tmplst)
for i in tmplst:
if int(macs,2) == i.macdir[0]:
if int(macs,2) == int(i.macdir):
print("REMOVING", i)
tmplst.remove(i)
try:
Expand Down Expand Up @@ -1156,7 +1156,7 @@ def send_pck(self, *widget, to=None):
print("PCK IPHEADER:", "{0:0160b}".format(ping.ip_header))

print("MAC's:", self.macdir, to.macdir)
frame = eth(to.macdir[0], self.macdir[0], ping)
frame = eth(int(to.macdir), int(self.macdir), ping)
frame.applytopack(ping)
print("Pck frame:", ping.frame)

Expand Down Expand Up @@ -1196,7 +1196,7 @@ def packet_received(self, pck):
if ty == 8:
print("El paquete era para mí, voy a responder un gracias :D")
ping = Ping.create(1, self.IP, int(pck.str[96:128],2))
frame = eth(int("{0:011b}".format(pck.frame)[6*8+1:6*16+1],2), self.macdir[0], ping)
frame = eth(int("{0:011b}".format(pck.frame)[6*8+1:6*16+1],2), int(self.macdir), ping)
frame.applytopack(ping)

ping.animate(self, self.connections[0])
Expand Down

0 comments on commit d438e51

Please sign in to comment.