OSSP CVS Repository

ossp - Check-in [1479]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1479
Date: 2002-Jan-02 14:08:13 (local)
2002-Jan-02 13:08:13 (UTC)
User:rse
Branch:
Comment: use faster IPPROTO_XXX instead of getprotobyname if available
Tickets:
Inspections:
Files:
ossp-pkg/sa/sa.c      1.42 -> 1.43     12 inserted, 4 deleted

ossp-pkg/sa/sa.c 1.42 -> 1.43

--- sa.c 2002/01/02 12:43:50     1.42
+++ sa.c 2002/01/02 13:08:13     1.43
@@ -859,7 +859,6 @@
     int nType;
     int nProto;
     struct protoent *pe;
-    char *cpProto;
 
     /* argument sanity check(s) */
     if (sa == NULL)
@@ -885,15 +884,24 @@
 #else
     else if (nFamily == AF_INET) {
 #endif
+#if defined(IPPROTO_TCP) && defined(IPPROTO_UDP)
         if (nType == SOCK_STREAM)
-            cpProto = "tcp";
+            nProto = IPPROTO_TCP;
         else if (nType == SOCK_DGRAM)
-            cpProto = "udp";
+            nProto = IPPROTO_UDP;
         else
             return SA_ERR_INT;
-        if ((pe = getprotobyname(cpProto)) == NULL)
+#else
+        if (nType == SOCK_STREAM)
+            pe = getprotobyname("tcp");
+        else if (nType == SOCK_DGRAM)
+            pe = getprotobyname("udp");
+        else
+            return SA_ERR_INT;
+        if (pe == NULL)
             return SA_ERR_SYS;
         nProto = pe->p_proto;
+#endif
     }
     else
         return SA_ERR_INT;

CVSTrac 2.0.1