From e6f07ae1c028003b284eae836dc1cab8efb3a4fd Mon Sep 17 00:00:00 2001 From: Alexandre Cassen Date: Wed, 14 Aug 2024 18:36:01 +0200 Subject: [PATCH] cosmetics: restore Copyright for files coming from old zebra code Important to give credits back to original author ! so Kunihiro, here we go. I did some extensions and improvements, but to be honnest I just didnt fully remind what and which part was modified... --- lib/Makefile | 2 +- lib/buffer.c | 21 +--- lib/buffer.h | 21 +--- lib/command.c | 21 +--- lib/command.h | 21 +--- lib/list_head.h | 2 + lib/mpool.c | 208 ---------------------------------------- lib/mpool.h | 68 ------------- lib/prefix.c | 22 +---- lib/prefix.h | 22 +---- lib/rt_table.c | 22 +---- lib/rt_table.h | 22 +---- lib/vector.c | 22 +---- lib/vector.h | 22 +---- lib/vty.c | 22 +---- lib/vty.h | 22 +---- src/include/gtp_guard.h | 1 - 17 files changed, 39 insertions(+), 502 deletions(-) delete mode 100644 lib/mpool.c delete mode 100644 lib/mpool.h diff --git a/lib/Makefile b/lib/Makefile index fb10674..cdc7219 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -26,7 +26,7 @@ CFLAGS = -g -O2 $(INCLUDES) -Werror -Wall -Wunused -Wstrict-prototypes DEFS = -D_GNU_SOURCE COMPILE = $(CC) $(CFLAGS) $(DEFS) -OBJS = memory.o mpool.o utils.o timer.o vector.o rbtree.o daemon.o \ +OBJS = memory.o utils.o timer.o vector.o rbtree.o daemon.o \ scheduler.o md5.o list_head.o pidfile.o prefix.o rt_table.o \ signals.o process.o logger.o buffer.o command.o vty.o \ pkt_buffer.o json_reader.o json_writer.o diff --git a/lib/buffer.c b/lib/buffer.c index 4d1d230..5b452c0 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -1,22 +1,7 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, + * Buffering of output and input. + * Copyright (C) 1998 Kunihiro Ishiguro */ #include diff --git a/lib/buffer.h b/lib/buffer.h index 4022b5e..e35ac0d 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -1,22 +1,7 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, + * Buffering of output and input. + * Copyright (C) 1998 Kunihiro Ishiguro */ #ifndef _BUFFER_H diff --git a/lib/command.c b/lib/command.c index 1830cae..7030919 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1,22 +1,7 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, + * Zebra configuration command interface routine + * Copyright (C) 1997, 98 Kunihiro Ishiguro */ #include diff --git a/lib/command.h b/lib/command.h index e4be6b3..c1a77db 100644 --- a/lib/command.h +++ b/lib/command.h @@ -1,22 +1,7 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, + * Zebra configuration command interface routine + * Copyright (C) 1997, 98 Kunihiro Ishiguro */ #ifndef _COMMAND_H diff --git a/lib/list_head.h b/lib/list_head.h index b4d2f3f..b8e82a9 100644 --- a/lib/list_head.h +++ b/lib/list_head.h @@ -19,6 +19,8 @@ * Copyright (C) 2023-2024 Alexandre Cassen, */ +/* This file is copied from the Linux kernel include/linux/list.h file */ + #ifndef _LIST_HEAD_H #define _LIST_HEAD_H diff --git a/lib/mpool.c b/lib/mpool.c deleted file mode 100644 index 47b0886..0000000 --- a/lib/mpool.c +++ /dev/null @@ -1,208 +0,0 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, - */ - -/* global includes */ -#include -#include - -/* local includes */ -#include "memory.h" -#include "mpool.h" - - -/* - * Dump memory pool - */ -void -mpool_dump(mem_pool_t *mpool) -{ - mem_t *mem; - int i = 0; - - printf("mpool size = %d\n", MPOOL_SIZE(mpool)); - - for (mem = mpool->head; mem; mem = mem->next) - printf(" %.2d size=%d offset=%d\n", ++i, mem->size, mem->offset); -} - -/* - * Queue memory element - */ -void -mpool_queue_tail(mem_pool_t *mpool, mem_t *mem) -{ - /* Return on empty stuff */ - if (!mpool || !mem) - return; - - /* Queue this mem */ - mem->prev = mpool->tail; - mem->next = NULL; - - if (mpool->head == NULL) - mpool->head = mem; - else - mpool->tail->next = mem; - - mpool->tail = mem; - mpool->count++; -} - -/* - * Dequeue a memory element - */ -mem_t * -mpool_dequeue(mem_pool_t *mpool) -{ - mem_t *mem; - - /* Queue is empty */ - if (MPOOL_ISEMPTY(mpool)) - return NULL; - - /* Fetch head */ - mem = mpool->head; - mpool->head = mem->next; - if (mem->next) - mem->next->prev = NULL; - mpool->count--; - - return mem; -} - -/* - * Allocate new memory element - */ -mem_t * -mpool_allocate_mem(int size) -{ - mem_t *mem = (mem_t *) MALLOC(sizeof(mem_t)); - mem->data = (char *) MALLOC(size); - mem->size = size; - return mem; -} - -/* - * Create a new memory element - */ -mem_t * -mpool_create_mem(char *buffer, int size) -{ - mem_t *mem = (mem_t *) MALLOC(sizeof(mem_t)); - mem->data = (char *) MALLOC(size); - mem->size = mem->offset = size; - memcpy(mem->data, buffer, size); - return mem; -} - -/* - * Duplicate memory element - */ -mem_t * -mpool_dup_mem(mem_t *mem) -{ - mem_t *new = (mem_t *) MALLOC(sizeof(mem_t)); - new->data = (char *) MALLOC(mem->size); - new->size = mem->size; - new->offset = mem->offset; - memcpy(new->data, mem->data, mem->offset); - return new; -} - - -/* - * Release a memory element - */ -void -mpool_release_mem(mem_t *mem) -{ - FREE(mem->data); - FREE(mem); -} - -/* - * Fill mempool with brand new mem bucket - */ -void -mpool_fill(mem_pool_t *mpool, int count, int size) -{ - mem_t *mem; - int i; - - /* Pre-allocate pool element */ - for (i=0; i < count; i++) { - mem = mpool_allocate_mem(size); - mpool_queue_tail(mpool, mem); - } -} - -/* - * Initialize a New memory Pool - */ -mem_pool_t * -mpool_init(void) -{ - mem_pool_t *mpool; - - /* Allocate root pool */ - mpool = (mem_pool_t *) MALLOC(sizeof(mem_pool_t)); - mpool->head = mpool->tail = NULL; - - return mpool; -} - -/* - * Destroy a memory pool - */ -void -mpool_destroy(mem_pool_t *mpool) -{ - mem_t *mem = NULL; - mem_t *next = NULL; - - if (!mpool) - return; - - for (mem = mpool->head; mem; mem = next) { - next = mem->next; - mpool_release_mem(mem); - } - - FREE(mpool); -} - -/* - * Flush and merge memory pool - */ -void -mpool_move(mem_pool_t *src, mem_pool_t *dst) -{ - mem_t *mem = NULL; - - if (!src || MPOOL_ISEMPTY(src)) - return; - - while ((mem = mpool_dequeue(src))) - mpool_queue_tail(dst, mem); - - src->tail = src->head = NULL; - src->count = 0; -} diff --git a/lib/mpool.h b/lib/mpool.h deleted file mode 100644 index 0c45d4f..0000000 --- a/lib/mpool.h +++ /dev/null @@ -1,68 +0,0 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, - */ - -#ifndef _MPOOL_H -#define _MPOOL_H - -/* Defines */ -#define MEM_DEFAULT_SIZE 65541 -#define MPOOL_DEFAULT_SIZE 10 - -/* Types */ -typedef struct _mem { - struct _mem *next; - struct _mem *prev; - - void *data; /* Raw data pointer */ - unsigned int size; /* Raw data size */ - unsigned int offset; /* Offset of data used */ - int type; -} mem_t; - -typedef struct _mem_pool { - mem_t *head; - mem_t *tail; - - unsigned int count; -} mem_pool_t; - - -/* Macros */ -#define MPOOL_SIZE(P) ((P)->count) -#define MPOOL_ISEMPTY(P) ((P)->count == 0) -#define MPOOL_TAIL(P) ((P)->tail) -#define MPOOL_DATA(P) ((P)->data) - - -/* Prototypes */ -extern void mpool_dump(mem_pool_t *); -extern void mpool_queue_tail(mem_pool_t *, mem_t *); -extern mem_t *mpool_dequeue(mem_pool_t *); -extern mem_t *mpool_allocate_mem(int); -extern mem_t *mpool_dup_mem(mem_t *); -extern mem_t *mpool_create_mem(char *, int); -extern void mpool_release_mem(mem_t *); -extern void mpool_fill(mem_pool_t *, int, int); -extern mem_pool_t *mpool_init(void); -extern void mpool_destroy(mem_pool_t *); -extern void mpool_move(mem_pool_t *, mem_pool_t *); - -#endif diff --git a/lib/prefix.c b/lib/prefix.c index ffca242..bbb39bf 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* IP prefix implementation + * Copyright (C) 1997 Kunihiro Ishiguro */ #include diff --git a/lib/prefix.h b/lib/prefix.h index 9787810..a229ac9 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* IP prefix implementation + * Copyright (C) 1997 Kunihiro Ishiguro */ #ifndef _PREFIX_H diff --git a/lib/rt_table.c b/lib/rt_table.c index 52a1ac7..8a865be 100644 --- a/lib/rt_table.c +++ b/lib/rt_table.c @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Routing table implementation + * Copyright (C) 1997 Kunihiro Ishiguro */ #include diff --git a/lib/rt_table.h b/lib/rt_table.h index ff07322..b3b95b8 100644 --- a/lib/rt_table.h +++ b/lib/rt_table.h @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Routing table implementation + * Copyright (C) 1997 Kunihiro Ishiguro */ #ifndef _RT_TABLE_H diff --git a/lib/vector.c b/lib/vector.c index e6f7db3..3476997 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Generic vector interface routine + * Copyright (C) 1997 Kunihiro Ishiguro */ #include "vector.h" diff --git a/lib/vector.h b/lib/vector.h index 99d7b96..84da099 100644 --- a/lib/vector.h +++ b/lib/vector.h @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Generic vector interface routine + * Copyright (C) 1997 Kunihiro Ishiguro */ #ifndef _VECTOR_H diff --git a/lib/vty.c b/lib/vty.c index b56c6d2..5fa3ba0 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Virtual terminal [aka TeletYpe] interface routine + * Copyright (C) 1997 Kunihiro Ishiguro */ #include diff --git a/lib/vty.h b/lib/vty.h index eb398f4..4711c48 100644 --- a/lib/vty.h +++ b/lib/vty.h @@ -1,22 +1,6 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* - * Soft: The main goal of gtp-guard is to provide robust and secure - * extensions to GTP protocol (GPRS Tunneling Procol). GTP is - * widely used for data-plane in mobile core-network. gtp-guard - * implements a set of 3 main frameworks: - * A Proxy feature for data-plane tweaking, a Routing facility - * to inter-connect and a Firewall feature for filtering, - * rewriting and redirecting. - * - * Authors: Alexandre Cassen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public - * License Version 3.0 as published by the Free Software Foundation; - * either version 3.0 of the License, or (at your option) any later - * version. - * - * Copyright (C) 2023-2024 Alexandre Cassen, +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Virtual terminal [aka TeletYpe] interface routine + * Copyright (C) 1997 Kunihiro Ishiguro */ #ifndef _VTY_H diff --git a/src/include/gtp_guard.h b/src/include/gtp_guard.h index 45c43da..788ee55 100644 --- a/src/include/gtp_guard.h +++ b/src/include/gtp_guard.h @@ -34,7 +34,6 @@ #include "timer.h" #include "timer_thread.h" #include "scheduler.h" -#include "mpool.h" #include "vector.h" #include "command.h" #include "rbtree.h"