rendered paste body#!/usr/bin/env python
# -*- coding: utf-8 -*-
import const
import message
from log import debug, info, warn, err
<<<<<<< HEAD
def build_error_message(self, conf, dst_addr, code):
reason = ""
if code == const.ERR_TTL_EXPIRED:
reason = "ttl expiré"
elif code == const.ERR_UNKNOWN_DEST:
reason = "destination inconnue"
elif code == const.ERR_MALFORMED:
reason = "message mal formé"
elif code == const.ERR_UNKNOWN_TYPE:
reason = "message de type inconnu"
elif code == const.ERR_OTHER:
reason = "autre erreur"
return Message(conf.router_address, dst_addr,
const.DEFAULT_TTL, "ERREUR",
len(reason), reason)
=======
class Erreur:
def __init__(self, paquet = ""):
if not paquet:
self.msg = None
else:
self.msg = message.Message(paquet)
def constr_msg(self, contenu, code, message):
#useless?
pass
def build_error_message(self, conf, dst_addr, code):
reason = ""
if code == const.ERR_TTL_EXPIRED:
reason = "ttl expiré"
elif code == const.ERR_UNKNOWN_DST:
reason = "destination inconnue"
elif code == const.ERR_MALFORMED:
reason = "message mal formé"
elif code == const.ERR_UNKNOWN_TYPE:
reason = "message de type inconnu"
elif code == const.ERR_OTHER:
reason = "autre erreur"
self.msg = Message(conf.router_address, dst_addr,
const.DEFAULT_TTL, "ERREUR",
len(reason), reason)
>>>>>>> 4aa8c4fdef8b1031d28fde3ae5b5630f48ef3a43