Browse Source

added an XXX note to handle before release

Caleb James DeLisle 9 years ago
parent
commit
68df7bc4fe
5 changed files with 30 additions and 16 deletions
  1. 2 2
      dht/Pathfinder.c
  2. 13 3
      net/ConverterV15.c
  3. 12 9
      net/InterfaceController.c
  4. 2 1
      net/SessionManager.c
  5. 1 1
      wire/DataHeader.h

+ 2 - 2
dht/Pathfinder.c

@@ -104,10 +104,10 @@ static int incomingFromDHT(struct DHTMessage* dmessage, void* vpf)
     if (dmessage->replyTo) {
         // see incomingMsg
         dmessage->replyTo->pleaseRespond = true;
-        Log_debug(pf->log, "DHT reply");
+        Log_debug(pf->log, "send DHT reply");
         return 0;
     }
-    Log_debug(pf->log, "DHT request");
+    Log_debug(pf->log, "send DHT request");
 
     Iface_send(&pf->eventIf, msg);
     return 0;

+ 13 - 3
net/ConverterV15.c

@@ -101,6 +101,7 @@ static Iface_DEFUN incomingFromUpperDistributorIf(struct Message* msg,
     if (type == ContentType_CJDHT) {
         struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) &ip6[1];
         ip6->nextHeader = 17;
+        ip6->hopLimit = 0;
         udp->srcPort_be = 0;
         udp->destPort_be = 0;
         udp->length_be = Endian_hostToBigEndian16(msg->length -
@@ -125,10 +126,11 @@ static Iface_DEFUN incomingFromUpperDistributorIf(struct Message* msg,
 
 #define tryConvertDHT_OVERHEAD \
     (RouteHeader_SIZE + Headers_IP6Header_SIZE + Headers_UDPHeader_SIZE)
-static inline bool tryConvertDHT(struct Message* msg, struct Headers_IP6Header* ip6)
+static inline bool tryConvertDHT(struct Message* msg)
 {
     if (msg->length < tryConvertDHT_OVERHEAD) { return false; }
     struct RouteHeader* bih = (struct RouteHeader*) msg->bytes;
+    struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) &bih[1];
     struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) &ip6[1];
     if (udp->srcPort_be || udp->destPort_be) { return false; }
     Message_shift(msg, -tryConvertDHT_OVERHEAD, NULL);
@@ -167,16 +169,24 @@ static Iface_DEFUN incomingFromSessionManagerIf(struct Message* msg, struct Ifac
         return Iface_next(&conv->pub.upperDistributorIf, msg);
     }
 
-    if (ipVer == 6) {
+    if (ipVer == 0) {
         if (msg->length < RouteHeader_SIZE + Headers_IP6Header_SIZE) {
             Log_debug(conv->log, "DROP runt");
             return NULL;
         }
         struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) ipPtr;
         if (ip6->sourceAddr[0] == 0xfc && ip6->destinationAddr[0] == 0xfc) {
-            if (tryConvertDHT(msg, ip6)) {
+            if (tryConvertDHT(msg)) {
                 return Iface_next(&conv->pub.upperDistributorIf, msg);
             }
+        }
+    } else if (ipVer == 6) {
+        if (msg->length < RouteHeader_SIZE + Headers_IP6Header_SIZE) {
+            Log_debug(conv->log, "DROP runt");
+            return NULL;
+        }
+        struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) ipPtr;
+        if (ip6->sourceAddr[0] == 0xfc && ip6->destinationAddr[0] == 0xfc) {
             Message_pop(msg, NULL, RouteHeader_SIZE + Headers_IP6Header_SIZE, NULL);
             struct DataHeader dh = {
                 .contentType_be = Endian_hostToBigEndian16(ip6->nextHeader),

+ 12 - 9
net/InterfaceController.c

@@ -326,6 +326,9 @@ static void iciPing(struct InterfaceController_Iface_pvt* ici, struct InterfaceC
             // our link to the peer is broken...
             sendPeer(0xffffffff, PFChan_Core_PEER_GONE, ep);
 
+            // XXX(cjd): we need to tell the switch about this because packets to this if
+            // should be responded to with error packets.
+
             // Lets skip 87% of pings when they're really down.
             if (ep->pingCount % 8) {
                 ep->pingCount++;
@@ -681,8 +684,8 @@ static Iface_DEFUN handleIncomingFromWire(struct Message* msg, struct Iface* add
 }
 
 struct InterfaceController_Iface* InterfaceController_newIface(struct InterfaceController* ifc,
-                                                 String* name,
-                                                 struct Allocator* alloc)
+                                                               String* name,
+                                                               struct Allocator* alloc)
 {
     struct InterfaceController_pvt* ic = Identity_check((struct InterfaceController_pvt*) ifc);
 
@@ -776,11 +779,11 @@ int InterfaceController_beaconState(struct InterfaceController* ifc,
 }
 
 int InterfaceController_bootstrapPeer(struct InterfaceController* ifc,
-                               int interfaceNumber,
-                               uint8_t* herPublicKey,
-                               const struct Sockaddr* lladdrParm,
-                               String* password,
-                               struct Allocator* alloc)
+                                      int interfaceNumber,
+                                      uint8_t* herPublicKey,
+                                      const struct Sockaddr* lladdrParm,
+                                      String* password,
+                                      struct Allocator* alloc)
 {
     struct InterfaceController_pvt* ic = Identity_check((struct InterfaceController_pvt*) ifc);
 
@@ -853,8 +856,8 @@ int InterfaceController_bootstrapPeer(struct InterfaceController* ifc,
 }
 
 int InterfaceController_getPeerStats(struct InterfaceController* ifController,
-                              struct Allocator* alloc,
-                              struct InterfaceController_PeerStats** statsOut)
+                                     struct Allocator* alloc,
+                                     struct InterfaceController_PeerStats** statsOut)
 {
     struct InterfaceController_pvt* ic =
         Identity_check((struct InterfaceController_pvt*) ifController);

+ 2 - 1
net/SessionManager.c

@@ -199,7 +199,8 @@ static struct SessionManager_Session_pvt* getSession(struct SessionManager_pvt*
     sess->alloc = alloc;
     sess->sessionManager = sm;
     sess->pub.version = version;
-    //sess->pub.timeOfCreation = Time_currentTimeMilliseconds(sm->eventBase);
+    sess->pub.timeOfLastIn = Time_currentTimeMilliseconds(sm->eventBase);
+    sess->pub.timeOfLastOut = Time_currentTimeMilliseconds(sm->eventBase);
     sess->pub.sendSwitchLabel = label;
     //Allocator_onFree(alloc, sessionCleanup, sess);
     sendSession(sess, label, 0xffffffff, PFChan_Core_SESSION);

+ 1 - 1
wire/DataHeader.h

@@ -41,7 +41,7 @@ struct DataHeader
 #define DataHeader_SIZE 4
 Assert_compileTime(sizeof(struct DataHeader) == DataHeader_SIZE);
 
-#define DataHeader_CURRENT_VERSION 0
+#define DataHeader_CURRENT_VERSION 1
 
 
 static inline enum ContentType DataHeader_getContentType(struct DataHeader* hdr)