def _translate2v2(ip, community, pdu):
    """Translate an SNMPv1 trap to an SNMPv2 trap per RFC2576. This is
    done so that the rest of the API only has to deal with V2 traps.
    """
    varbinds = pdu.varbinds
    # 3.1.(1)
    varbinds.insert(0, sysUpTime(pdu.time_stamp).varbind)
    # 3.1.(2)
    if pdu.generic == 6:  # enterpriseSpecific(6)
        trapoid = ObjectIdentifier(pdu.enterprise+[0, pdu.specific])
    else: # 3.1.(3)
        trapoid = _TRAPMAP[pdu.generic]
    varbinds.insert(1, snmpTrapOID(trapoid).varbind)
    # 3.1.(4)
    try:
        varbinds.append(snmpTrapAddress(pdu.agent).varbind)
    except __HOLE__:
        varbinds.append(snmpTrapAddress(ip).varbind)
    varbinds.append(snmpTrapCommunity(community).varbind)
    varbinds.append(snmpTrapEnterprise(pdu.enterprise).varbind)
    return SNMPv2TrapPDU(varbinds=varbinds)


# all trap callbacks should match this signature.
dataset/ETHPy150Open kdart/pycopia/SNMP/pycopia/SNMP/traps.py/_translate2v2