Exemple #1
0
bool ScenargieRouteMgr::DeleteRoute(
    const ProtoAddress& destinationProtoAddress,
    unsigned int prefixLength,
    const ProtoAddress& gatewayProtoAddress,
    unsigned int protoInterfaceIndex)
{
    bool routeIsDeletedFromProtoRouteTable = protoRouteTable.DeleteRoute(
        destinationProtoAddress,
        prefixLength,
        &gatewayProtoAddress);

    if(routeIsDeletedFromProtoRouteTable){

        NetworkAddress destinationNetworkAddress(
            destinationProtoAddress.SimGetAddress());

        NetworkAddress destinationNetworkAddressSubnetMask =
            NetworkAddress(0xFFFFFFFF << (32 - prefixLength));

        shared_ptr<RoutingTable> routingTablePtr =
            networkLayerPtr->GetRoutingTableInterface();

        routingTablePtr->DeleteRoute(
            destinationNetworkAddress,
            destinationNetworkAddressSubnetMask);

        nrlolsrProtocolPtr->OutputTraceAndStatsForDeleteRoutingTableEntry(
            destinationNetworkAddress,
            destinationNetworkAddressSubnetMask);

    }//if//

    return routeIsDeletedFromProtoRouteTable;
}//DeleteRoute//
Exemple #2
0
/*
 * Class:     javm_nativeimp_NsDatagramSocketImpl
 * Method:    peek
 * Signature: (Ljavm/net/InetAddress;)I
 */
JNIEXPORT jint JNICALL Java_agentj_nativeimp_NsDatagramSocketImpl_peek
(JNIEnv *env, jobject javaobj, jobject longAddress) {
    PLOG(PL_DEBUG, "Java_agentj_nativeimp_NsDatagramSocketImpl_peek: Entering\n");

    ProtoSocket *socket = (ProtoSocket *)getSocket(env, javaobj); // gets the socket...
    int len=1;
    char *bdata = new char[len];
    unsigned int actualRead=len;

    socket->Recv(bdata, actualRead);
    delete []bdata;

    char sendersAddress[5];
    int sendersPort;

    ProtoAddress sendersProtoAddress = socket->GetDestination();
    sendersPort = sendersProtoAddress.GetPort();
    sendersProtoAddress.GetHostString(sendersAddress, strlen(sendersAddress));

    jclass longClass = env->FindClass("java/lang/Long");
    jmethodID setAddressID = env->GetMethodID(longClass, "<init>", "(J)V");

    longAddress = env->NewObject(longClass, setAddressID, (jlong)sendersProtoAddress.SimGetAddress());

    return 0;
}
Exemple #3
0
bool ScenargieRouteMgr::SetRoute(
    const ProtoAddress& destinationProtoAddress,
    unsigned int prefixLength,
    const ProtoAddress& gatewayProtoAddress,
    unsigned int protoInterfaceIndex,
    int metric)
{
    bool routeIsSetToProtoRouteTable = protoRouteTable.SetRoute(
        destinationProtoAddress,
        prefixLength,
        gatewayProtoAddress,
        protoInterfaceIndex,
        metric);

    if (routeIsSetToProtoRouteTable){

        NetworkAddress destinationNetworkAddress(
            destinationProtoAddress.SimGetAddress());

        NetworkAddress destinationNetworkAddressSubnetMask =
            NetworkAddress(0xFFFFFFFF << (32 - prefixLength));

        SIMADDR gatewayRawAddress = gatewayProtoAddress.SimGetAddress();
        NetworkAddress nextHopNetworkAddress(gatewayRawAddress);
        if(gatewayRawAddress == 0){
            nextHopNetworkAddress = destinationNetworkAddress;
        }

        shared_ptr<RoutingTable> routingTablePtr =
            networkLayerPtr->GetRoutingTableInterface();

        routingTablePtr->AddOrUpdateRoute(
            destinationNetworkAddress,
            destinationNetworkAddressSubnetMask,
            nextHopNetworkAddress,
            interfaceIndex);

        nrlolsrProtocolPtr->OutputTraceAndStatsForAddRoutingTableEntry(
            destinationNetworkAddress,
            destinationNetworkAddressSubnetMask,
            nextHopNetworkAddress);

    }//if//

    return routeIsSetToProtoRouteTable;
}//SetRoute//