~ubuntu-branches/ubuntu/raring/exabgp/raring

« back to all changes in this revision

Viewing changes to lib/exabgp/bgp/protocol.py

  • Committer: Package Import Robot
  • Author(s): Henry-Nicolas Tourneur
  • Date: 2013-01-02 11:42:00 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20130102114200-heowva4yrqiiukc5
Tags: 3.1.1-1

* New upstream release
* Closes: #687134 debconf abuse, notice of software behavior take places under
  NEWS.Debian, not in a debconf screen, information moved accordingly.
* Closes: #693338 Japanese translation removed since debconf template is out.
* Closes: #697178 Russian translation removed since debconf template is out.
* Closes: #689533 UCF-based conf added. 
  No more manual changes to exabgp.env, thanks to Federico Ceratto.
          

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from exabgp.bgp.message.open.capability import Capabilities
21
21
from exabgp.bgp.message.open.capability.negociated import Negociated
22
22
from exabgp.bgp.message.update import Update
23
 
from exabgp.bgp.message.eor import EOR
 
23
from exabgp.bgp.message.update.eor import EOR
24
24
from exabgp.bgp.message.keepalive import KeepAlive
25
25
from exabgp.bgp.message.notification import Notification, Notify
26
26
from exabgp.bgp.message.refresh import RouteRefresh
44
44
                self.connection = connection
45
45
                self.negociated = Negociated()
46
46
 
47
 
                self._delta = Delta(Table(peer))
 
47
                self.delta = Delta(Table(peer))
48
48
                self._messages = []
49
49
                self._frozen = 0
50
50
                # The message size is the whole BGP message _without_ headers
67
67
                        if self.peer.neighbor.peer_updates:
68
68
                                message = 'neighbor %s connected\n' % self.peer.neighbor.peer_address
69
69
                                try:
70
 
                                        proc = self.peer.supervisor.processes
71
 
                                        for name in proc.notify(self.neighbor.peer_address):
72
 
                                                proc.write(name,message)
 
70
                                        for process in self.peer.supervisor.processes.notify(self.neighbor.peer_address):
 
71
                                                self.peer.supervisor.processes.write(process,message)
73
72
                                except ProcessError:
74
73
                                        raise Failure('Could not send message(s) to helper program(s) : %s' % message)
75
74
 
76
75
        def close (self,reason='unspecified'):
77
 
                #self._delta.last = 0
78
76
                if self.connection:
79
77
                        # must be first otherwise we could have a loop caused by the raise in the below
80
78
                        self.connection.close()
81
79
                        self.connection = None
82
80
 
83
81
                        if self.peer.neighbor.peer_updates:
84
 
                                message = 'neighbor %s down - %s\n' % (self.peer.neighbor.peer_address,reason)
85
82
                                try:
86
 
                                        proc = self.peer.supervisor.processes
87
 
                                        for name in proc.notify(self.neighbor.peer_address):
88
 
                                                proc.write(name,message)
 
83
                                        for process in self.peer.supervisor.processes.notify(self.neighbor.peer_address):
 
84
                                                self.peer.supervisor.processes.api.down(process,self.peer.neighbor.peer_address,reason)
89
85
                                except ProcessError:
90
86
                                        raise Failure('Could not send message(s) to helper program(s) : %s' % message)
91
87
 
112
108
                msg_length = unpack('!H',raw_length)[0]
113
109
                msg = data[18]
114
110
 
115
 
                if ( msg_length < 19 or msg_length > 4096):
 
111
                if (msg_length < 19 or msg_length > 4096):
116
112
                        # BAD Message Length
117
113
                        raise Notify(1,2)
118
114
 
186
182
                if message.router_id == self.neighbor.router_id and message.asn == self.neighbor.local_as:
187
183
                        raise Notify(2,3,'BGP Indendifier collision (%s) on IBGP according to RFC 6286' % message.router_id)
188
184
 
189
 
                if message.hold_time < 3:
 
185
                if message.hold_time and message.hold_time < 3:
190
186
                        raise Notify(2,6,'Hold Time is invalid (%d)' % message.hold_time)
191
187
 
192
188
                if self.negociated.multisession not in (True,False):
216
212
                        Capabilities().new(self.neighbor,restarted),
217
213
                        self.neighbor.hold_time
218
214
                )
219
 
                
 
215
 
220
216
                self.negociated.sent(sent_open)
221
217
 
222
218
                # we do not buffer open message in purpose
238
234
 
239
235
        def new_update (self):
240
236
                # XXX: This should really be calculated once only
241
 
                for number in self._announce('UPDATE',self._delta.updates(self.negociated,self.neighbor.group_updates)):
 
237
                for number in self._announce('UPDATE',self.peer.bgp.delta.updates(self.negociated,self.neighbor.group_updates)):
242
238
                        yield number
243
239
 
244
240
        def new_eors (self):
290
286
                                        raise Failure('Can not send BGP update larger than %d bytes on this connection.' % size)
291
287
                                if len(chunk) + len(data) <= size:
292
288
                                        chunk += data
293
 
                                        number += 1
 
289
                                        number += 1
294
290
                                        continue
295
291
                                yield number,chunk
296
292
                                chunk = data