]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfclient/ospf_apiclient.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfclient / ospf_apiclient.c
index 1908604bd9c5217c2a1186854054057ea173a04d..c5bbc01501595abcaf13e722bed76830b0755941 100644 (file)
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Client side of OSPF API.
  * Copyright (C) 2001, 2002, 2003 Ralph Keller
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
 
 #include "ospf_apiclient.h"
 
-/* *sigh* ... can't find a better way to hammer this into automake */
-#include "ospfd/ospf_dump_api.c"
-#include "ospfd/ospf_api.c"
-
 XREF_SETUP();
 
 DEFINE_MGROUP(OSPFCLIENT, "libospfapiclient");
@@ -124,7 +105,7 @@ struct ospf_apiclient *ospf_apiclient_connect(char *host, int syncport)
 
        /* Prepare socket for asynchronous messages */
        /* Initialize async address structure */
-       memset(&myaddr_async, 0, sizeof(struct sockaddr_in));
+       memset(&myaddr_async, 0, sizeof(myaddr_async));
        myaddr_async.sin_family = AF_INET;
        myaddr_async.sin_addr.s_addr = htonl(INADDR_ANY);
        myaddr_async.sin_port = htons(syncport + 1);
@@ -219,7 +200,7 @@ struct ospf_apiclient *ospf_apiclient_connect(char *host, int syncport)
           want the sync port number on a fixed port number. The reverse
           async channel will be at this port+1 */
 
-       memset(&myaddr_sync, 0, sizeof(struct sockaddr_in));
+       memset(&myaddr_sync, 0, sizeof(myaddr_sync));
        myaddr_sync.sin_family = AF_INET;
        myaddr_sync.sin_port = htons(syncport);
 #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
@@ -439,6 +420,12 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
        struct lsa_header *lsah;
        uint32_t tmp;
 
+       /* Validate opaque LSA length */
+       if ((size_t)opaquelen > sizeof(buf) - sizeof(struct lsa_header)) {
+               fprintf(stderr, "opaquelen(%d) is larger than buf size %zu\n",
+                       opaquelen, sizeof(buf));
+               return OSPF_API_NOMEMORY;
+       }
 
        /* We can only originate opaque LSAs */
        if (!IS_OPAQUE_LSA(lsa_type)) {
@@ -475,8 +462,9 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
 }
 
 int ospf_apiclient_lsa_delete(struct ospf_apiclient *oclient,
-                             struct in_addr area_id, uint8_t lsa_type,
-                             uint8_t opaque_type, uint32_t opaque_id)
+                             struct in_addr addr, uint8_t lsa_type,
+                             uint8_t opaque_type, uint32_t opaque_id,
+                             uint8_t flags)
 {
        struct msg *msg;
        int rc;
@@ -490,8 +478,8 @@ int ospf_apiclient_lsa_delete(struct ospf_apiclient *oclient,
 
        /* opaque_id is in host byte order and will be converted
         * to network byte order by new_msg_delete_request */
-       msg = new_msg_delete_request(ospf_apiclient_get_seqnr(), area_id,
-                                    lsa_type, opaque_type, opaque_id);
+       msg = new_msg_delete_request(ospf_apiclient_get_seqnr(), addr, lsa_type,
+                                    opaque_type, opaque_id, flags);
 
        rc = ospf_apiclient_send_request(oclient, msg);
        return rc;